Windows Identity

  • Thread starter Thread starter Ivan G.
  • Start date Start date
I

Ivan G.

Hi.

How can I create an instance of WindowsIdentity class knowing user
samaccountname and domain password?

Thanx.
 
If you are using Win2003 you could use:
new WindowsIdentity(string upn)

Note that this does not even require the password - it implies that you
trust the process that is doing this.
The ramifications of this are described in detail here:
http://msdn.microsoft.com/msdnmag/issues/03/04/SecurityBriefs/default.aspx

The constructor will throw an exception if you call it on XP (which makes
things difficult if that's your development platform).


The other approach is to use WindowsIdentity.Impersonate.
You first need to get hold of the security token for the user by calling the
LoginUser Win32 API function.
There's a complete code listing on MSDN:
http://msdn.microsoft.com/library/d...cipalWindowsIdentityClassImpersonateTopic.asp

Note that LogonUser requires SE_TCB privilege on Win2K

Hope that helps.
Richard.
 

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

Back
Top