We are using SDL Tridion 9.5 and we have configured Azure OpenIdConnect Authentication using Access management for login into CME. We are working on a Custom Page using core service client but we are unable to impersonate core service client since HttpContext.Current.User.Identity.Name always return empty. What is the correct way to impersonate a core service client? Any sample code will be very helpful


1 Answer 1


Try getting it from the CurrentPrincipal.Identity instead:

string userName = HttpContext.Current?.User?.Identity?.Name;
if (string.IsNullOrWhiteSpace(userName))
    userName = System.Threading.Thread.CurrentPrincipal.Identity.Name

Of course that's assuming you only need the name to impersonate correctly. If you want to use external groups for security, for instance, you should probably be using the ImpersonateWithToken or ImpersonateWithClaims methods instead.

  • I have tried your code but unfortunately, I m still getting an empty string May 11, 2021 at 10:56
  • Perhaps the issue is with the setup of the app for the custom page then? Maybe you could check that it has the same settings as the WebUI application, including modules and such? May 11, 2021 at 11:53
  • I m using the same application pool which is used by Tridion Site. Since the Authentication is done by Tridion Access Management I m getting System.Threading.Thread.CurrentPrincipal.Identity.Name as empty May 15, 2021 at 6:35
  • @Abdul: Can you create a Virtual Directory instead of a separate Web Application?
    – Velmurugan
    Oct 12, 2021 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.