C# 클래스 Tools.Impersonator

Impersonation of a user. Allows to execute code under another user context. Please note that the account that instantiates the Impersonator class needs to have the 'Act as part of operating system' privilege set.
This class is based on the information in the Microsoft knowledge base article http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158 Encapsulate an instance into a using-directive like e.g.: ... using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) ) { ... [code that executes under the new context] ... } ... Please contact the author Uwe Keim (mailto:[email protected]) for questions regarding this class.
상속: IDisposable
파일 보기 프로젝트 열기: davidadsit/TeamFoundationServerDesktopBuildMonitor 1 사용 예제들

공개 메소드들

메소드 설명
Dispose ( ) : void
Impersonator ( string userName, string domainName, string password ) : System

Constructor. Starts the impersonation with the given credentials. Please note that the account that instantiates the Impersonator class needs to have the 'Act as part of operating system' privilege set.

비공개 메소드들

메소드 설명
CloseHandle ( IntPtr handle ) : bool
DuplicateToken ( IntPtr hToken, int impersonationLevel, IntPtr &hNewToken ) : int
ImpersonateValidUser ( string userName, string domain, string password ) : void

Does the actual impersonation.

LogonUser ( string lpszUserName, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, IntPtr &phToken ) : int
RevertToSelf ( ) : bool
UndoImpersonation ( ) : void

Reverts the impersonation.

메소드 상세

Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void

Impersonator() 공개 메소드

Constructor. Starts the impersonation with the given credentials. Please note that the account that instantiates the Impersonator class needs to have the 'Act as part of operating system' privilege set.
public Impersonator ( string userName, string domainName, string password ) : System
userName string The name of the user to act as.
domainName string The domain name of the user to act as.
password string The password of the user to act as.
리턴 System