3

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
0

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.

3
  • I have tried your code but unfortunately, I m still getting an empty string – Abdul Qadir May 11 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? – Peter Kjaer May 11 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 – Abdul Qadir May 15 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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