In ASP.NET or WCF is it safe to use ServiceSecurityContext.Current.WindowsIdentity.Name
to get the current username that 开发者_JS百科executes the current thread?
I want to ensure that the correct user is impersonated in my WCF Service.
WindowsIdentity.GetCurrent().Name
is probably a better alternative, as I don't think that ServiceSecurityContext.Current
is available in ASP.NET.
You may also want to consider
Thread.CurrentPrincipal.Identity.Name
if you care about the user instead of the process identity.
精彩评论