C# Class Aspose.Pdf.Examples.CSharp.AsposePDFFacades.Printing.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.
Inheritance: IDisposable
显示文件 Open project: aspose-pdf/Aspose.Pdf-for-.NET

Public Methods

Method Description
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.

Private Methods

Method Description
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.

Method Details

Dispose() public method

public Dispose ( ) : void
return void

Impersonator() public method

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.
return System