C# Class Impersonation, code

Provides a mechanism for impersonating a user. This is intended to be disposable, and used in a using ( ) block.
Inheritance: IDisposable
Show file Open project: shendongnian/code Class Usage Examples

Public Methods

Method Description
impersonate ( string userName, string password, string domain, Action action, int logonType = 2, int logonProvider ) : void

impersonates a user based on username/password provided. executed method after impersonation and then reverts impersonation when task/method is complete.

Method Details

impersonate() public static method

impersonates a user based on username/password provided. executed method after impersonation and then reverts impersonation when task/method is complete.
public static impersonate ( string userName, string password, string domain, Action action, int logonType = 2, int logonProvider ) : void
userName string username to impersonate
password string password for user account
domain string domain of user to impersonate
action Action method to invoke after impersonation
logonType int LogonType to use, defaulted to Network
logonProvider int LogonProvider type, defaulted to default
return void