.net WinForms application use domain credentials of another username and password
I want to create a program that will allow someone to add a user to a group. I don't want to give the user the ability to do this on the domain through their account. I want to us开发者_JAVA技巧e a separate username and password stored in the program that will be used. What documentation should I be reviewing?
You could look at MSDN documentation for WindowsIdentity.Impersonate
to see how to impersonate a different account.
As for storing the username and password in the program, the general advice is "don't do it", because it's insecure. Anyone who can reverse engineer your code will be able to discover the username and password.
For the actual domain operations, you'll probably want the System.Management assembly (which basically wraps WMI). http://msdn.microsoft.com/en-us/library/dwd0y33x.aspx
For the authentication prior to performing operations using System.Management, you should probably use a WindowsImpersonationContext: http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx
精彩评论