Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7912359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:34:51+00:00 2026-06-03T13:34:51+00:00

I have code that runs as part of an event handler and need to

  • 0

I have code that runs as part of an event handler and need to create a new TOM.NET session (I can’t reuse subject.Session). This event handler is loaded into many Tridion processes (TcmServiceHost, COM+, Publisher, TcmTemplateDebugHost, IIS Application Pool) and these processes may:

  • run under an identity that has access to Tridion (e.g. the COM+ application runs under MTSUser, which is a Tridion administrator)
  • run under an identity that doesn’t have access to Tridion, but is allowed to impersonate Tridion users (e.g. TcmServiceHost runs as NetworkService, which is configured as a Tridion Impersonation User).

I try to cater for both cases with this TOM.NET code:

Session session = null;
try
{
    session = new Session();
}
catch (AccessDeniedException ex)
{
    // this process doesn't have TCM access, so impersonate a user that does
    session = new Session("Administator");
}
if (session != null)
{
    var item = session.GetObject(id);
    ...

Is this the right way to check whether my code is running under a process that has access to Tridion (ignoring the fact that I hard-coded “Administrator”)? The code works, but I just wonder if there is a more efficient way to perform a “has access to Tridion” check?

Note: the same question arises when I use the Core Service to access Tridion, so the question is not whether the TOM.NET is the right API to use here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:34:53+00:00Added an answer on June 3, 2026 at 1:34 pm

    I would not use this code. Exception catching is slow and you are currently giving (Administrator) access to anyone who cannot access the system – which is a big security hole to have.

    Instead, I would look at who the current user is and figure out if he is an impersonation user or not. You could read the impersonation users from the Tridion.ContentManager.config file directly, if there isn’t an API for it (I haven’t checked).

    var isImpersonationUser = IsImpersonationUser(WindowsIdentity.GetCurrent());
    var session = isImpersonationUser ? new Session("Administrator") : new Session();
    var item = session.GetObject(id);
    

    Or you would have it be configurable separately for your event code. Or even hard-coded, if you don’t care about the code being generic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

below i have a code that runs in most of my simple programs ..
I have some jQuery code that runs fine until I add the jQuery UI
I have a simple jQuery code that runs on a web page that has
I have the following SQL code that runs against a Change Request database. Each
I have some code that compiles and runs on MSVC++ but will not compile
I have this small piece of code that basically takes a list and runs
I have code that uses jquery.slideup and jquery.slidedown How can i know that div
I have some code that runs fairly well, but I would like to make
I have a problem with a piece of legacy c++/winsock code that is part
I have code that looks like this: template<class T> class list { public: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.