MailBee.NET Objects 4.0

Impersonation.LogonAs Method 

Makes the current thread impersonate the specified user account.

public bool LogonAs(
   string accountName,
   string domainName,
   string password
);

Parameters

accountName
The name of the account being impersonated.
domainName
The name of the domain the specified account belongs to.
password
The password of the specified account.

Return Value

true if succeeded; otherwise, false.

Remarks

The impersonation lasts until the current thread exits or Logoff method gets called.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException accountName is a null reference (Nothing in Visual Basic) or an empty string.
MailBeeImpersonationWin32Exception Win32 returned an error on attempt to complete impersonation and ThrowExceptions is true.

See Also

Impersonation Class | MailBee.Security Namespace