C# Class YetAnotherRelogger.Helpers.Tools.Impersonator

Allows code to be executed under the security context of a specified user account.
Implements IDispose, so can be used via a using-directive or method calls; ... var imp = new Impersonator( "myUsername", "myDomainname", "myPassword" ); imp.UndoImpersonation(); ... var imp = new Impersonator(); imp.Impersonate("myUsername", "myDomainname", "myPassword"); imp.UndoImpersonation(); ... using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) ) { ... [code that executes under the new context] ... } ...
Inheritance: IDisposable
Mostra file Open project: sinterlkaas/YetAnotherRelogger Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Impersonate ( string userName, string domainName, string password ) : void

Impersonates the specified user account.

Impersonate ( string userName, string domainName, string password, LogonType logonType, LogonProvider logonProvider ) : void

Impersonates the specified user account.

Impersonator ( ) : System

Initializes a new instance of the Impersonator class.

Impersonator ( string userName, string domainName, string password ) : System

Begins impersonation with the given credentials.

Impersonator ( string userName, string domainName, string password, LogonType logonType, LogonProvider logonProvider ) : System

Begins impersonation with the given credentials, Logon type and Logon provider.

Private Methods

Method Description
UndoImpersonation ( ) : void

Stops impersonation.

Method Details

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Impersonate() public method

Impersonates the specified user account.
public Impersonate ( string userName, string domainName, string password ) : void
userName string Name of the user.
domainName string Name of the domain.
password string The password.
return void

Impersonate() public method

Impersonates the specified user account.
public Impersonate ( string userName, string domainName, string password, LogonType logonType, LogonProvider logonProvider ) : void
userName string Name of the user.
domainName string Name of the domain.
password string The password.
logonType LogonType Type of the logon.
logonProvider LogonProvider The logon provider.
return void

Impersonator() public method

Initializes a new instance of the Impersonator class.
public Impersonator ( ) : System
return System

Impersonator() public method

Begins impersonation with the given credentials.
public Impersonator ( string userName, string domainName, string password ) : System
userName string Name of the user.
domainName string Name of the domain.
password string The password.
return System

Impersonator() public method

Begins impersonation with the given credentials, Logon type and Logon provider.
public Impersonator ( string userName, string domainName, string password, LogonType logonType, LogonProvider logonProvider ) : System
userName string Name of the user.
domainName string Name of the domain.
password string The password.
logonType LogonType Type of the logon.
logonProvider LogonProvider The logon provider.
return System