Question

How can i login without logout from current user to another Active Directory user with C#. ; 1-Getting new user's access 2- doing my work and than logout with c# same way.

For example i am a user at blabla.com domain.I have logged in a Power User.But i need Admin Rights for something so i need to logout and change user to Administrator do my job and relogin with Power User again.I wanna do it with C#.

I heard something like that Impersonate User but i think this is not what i want.

Edited : I want login with another user and get this user's permissions without logout from my current user in c#.

Was it helpful?

Solution

Your question is not very clear. If what you want to be doing is querying/modifying AD, then t4zsan's answer is correct.

If you just need the other user's groups/security permissions, then Impersonation is the way to go. This article will give you a good foundation on it.

Caveats: The user you wish to impersonate must be able to logon to the machine you are running the code on. You can't impersonate a user in another domain if that domain is not trusted. Nor can you impersonate a local user on another machine, obviously.

OTHER TIPS

When using the classes in System.DirectoryServices to connect to AD you have the option of specifying user credentials. For example when using DirectoryEntry there is a constructor overload taking username and password that lets you connect as a different user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top