RevertToSelf function

The RevertToSelf function terminates the impersonation of a client application.

Syntax

BOOL RevertToSelf(

);

Parameters

This function has no parameters.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

A process should call the RevertToSelf function after finishing any impersonation begun by using the DdeImpersonateClient, ImpersonateDdeClientWindow, ImpersonateLoggedOnUser, ImpersonateNamedPipeClient, ImpersonateSelf, ImpersonateAnonymousToken or SetThreadToken function.

An RPC server that used the RpcImpersonateClient function to impersonate a client must call the RpcRevertToSelf or RpcRevertToSelfEx to end the impersonation.

If RevertToSelf fails, your application continues to run in the context of the client, which is not appropriate. You should shut down the process if RevertToSelf fails.

Examples

For an example that uses this function, see Verifying Client Access with ACLs.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header securitybaseapi.h (include Windows.h)
Library Advapi32.lib
DLL Advapi32.dll

See Also

Client/Server Access Control Functions

Client/Server Access Control Overview

DdeImpersonateClient

ImpersonateAnonymousToken

ImpersonateDdeClientWindow

ImpersonateLoggedOnUser

ImpersonateNamedPipeClient

ImpersonateSelf

RpcImpersonateClient

RpcRevertToSelf

RpcRevertToSelfEx

SetThreadToken