RevertToSelf (advapi32)
Last changed: -174.46.8.250

.
Summary
Terminates the impersonation of a client application

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
static extern bool RevertToSelf();

VB Signature:

Declare Function RevertToSelf Lib "advapi32.dll" () As Integer

User-Defined Types:

None.

Notes:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/reverttoself.asp

Tips & Tricks:

Make sure you catch errors correctly:

if (!RevertToSelf())
{
    int win32error = Marshal.GetLastWin32Error();
    throw new System.ComponentModel.Win32Exception(win32error);
}

Sample Code:

See ImpersonateLoggedOnUser

Alternative Managed API:

Do you know one? Please contribute it!

Documentation