Home All Groups Group Topic Archive Search About

WindowsIdentity._GetCurrentToken() Access is denied

Author
13 Jan 2005 7:27 PM
Robert Phillips
I periodically get an ApplicationException "access is denied" in the
WindowsIdentity._GetCurrentToken() method.   Reflector shows the
_GetCurrentToken() method as

[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr _GetCurrentToken();

which i believe means it is an internal call into the CLR.Does anyone have
any thoughts on why this would be happening?

The call stack is

ExceptionType="System.ApplicationException"
Message="Access is denied."
TargetSite="IntPtr _GetCurrentToken()"
Source="mscorlib"
   at System.Security.Principal.WindowsIdentity._GetCurrentToken()
   at System.Security.Principal.WindowsIdentity.GetCurrent()
   at System.AppDomain.GetThreadPrincipal()
   at System.Threading.Thread.get_CurrentPrincipal()
   at my code.....

my code is:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

//exception happens here
string user = System.Threading.Thread.CurrentPrincipal.Identity.Name;

AddThis Social Bookmark Button