views:

1144

answers:

3

Hi,

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#.

+1  A: 

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.

Jakob Christensen
+2  A: 

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.

Moose
I want login with another user from C# without logout from current user.
Ibrahim AKGUN
Impersonation makes the current running process look like it is running as the user ID impersonated. If you want a full login kicked off from your process, I'm not sure how that would be done.
Moose
A: 

i create an asp.net with c# application,in application in login page i use default login control but when i tick in rember me next time checkbox and login then it donot work next time.please give sugession for that. mayur

mayur