ImpersonateUser
ITcUserManager::ImpersonateUser
The invoking thread impersonates the user denoted by name and password.
HRESULT ImpersonateUser(
BSTR bstrUserName,
BSTR bstrPassword,
VARIANT varDomain
);
Parameters
bstrUserName | [in] Name of the user who is to be impersonated. |
bstrPassword | [in] Password of the user. |
varDomain | [in, optional] |
Return Values
HRESULT == S_OK | User account has successfully been created. |
HRESULT != S_OK | If an error occurs an error code generated by Windows NT appears in HRESULT. In order to instigate a COM/OLE error handling sequence, an HRESULT is created from the error code from HRESULT_FROM_NT(nErrror) or HRESULT_FROM_WIN32(nErrror). Here it should be noted that the Windows NT error code is displayed in low-order 16 bit format. |
Comments
The ImpersonateUser method assigns the ”impersonation“ token of the desired user to the invoking thread. For this purpose, the user is interactively logged in with username and password and the created token is used for impersonation. After a successful execution of ImpersonateUser the thread has adopted the identity of the user. This can be reversed by calling the method RevertToSelf . |