Jump to content
  • Advertisement
Sign in to follow this  
JohnnyCode

impersonating nt user, permission fail

This topic is 2491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,

In my application, if I do not impersonate a certain user, and run process as is, all works and my assemblies get loaded.
But when I log and impersonate the certain user, I get "could not load assembly or one of its dependencies, access denied".
I am realizing that some of dependencies may not by accessible to the user policy. Before I started investigating which and where, I added the user to Administrators group and removed the user from previous group. I still get the access denied if my proccess impersonates to that user. I am so lost, the user is administrator after all. Do you have any suggestions? If I do not impersonate to the user all works.

Share this post


Link to post
Share on other sites
Advertisement
I have disabled UAC on the computer by draging the slider in user account control, and checked the registry value is being zero, just the procedure for disabling UAC. Yet still my logon function seems to return a restricted token. this is how I impersonate




IntPtr token1 = new IntPtr(0);
IntPtr tokenDuplicate = IntPtr.Zero;

token1 = IntPtr.Zero;
string strNewUserName = host.m_sNTUser;//((CRequest)parameters[0]).m_pCurrentHost.m_sNTUser;
string strMachineName = System.Environment.MachineName;
string strNewPassword = host.m_sNTPass;// ((CRequest)parameters[0]).m_pCurrentHost.m_sNTPass;
const int LOGON32_PROVIDER_DEFAULT = 0;
const int LOGON32_LOGON_INTERACTIVE = 2;


bool loggedOn = CNTUsersUtility.LogonUser(strNewUserName, strMachineName, strNewPassword, 2, 0, ref token1);
int r=CNTUsersUtility.DuplicateToken(token1, 2, ref tokenDuplicate);

IntPtr token2 = token1;
WindowsIdentity mWI2 = new WindowsIdentity(tokenDuplicate);
WindowsImpersonationContext mWIC = mWI2.Impersonate();
//////////// run as new user
mWIC.Undo(); // get back to previous identity

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!