Access is denied in WindowsIdentity.GetCurrent

R

Robert Phillips

I am suddenly getting this on a couple of Windows XP (.NET 1.1) machines in
my environment. The machines haven't change, and my code hasn't changed.

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;

I originally thought it was a CAS issue, but SetPrincipalPolicy works which
means that the ControlPrincipal SecurityPermission is not the issue.
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top