Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This method restores a thread's authentication information.

Syntax

HRESULT RevertToSelf( )

Parameters

None.

Return Value

This method supports the standard return value E_FAIL, as well as the following:

S_OK

Success.

Remarks

In Windows NT® version 4.0, IServerSecurity::RevertToSelfsets the thread token to NULL. In Windows 2000, RevertToSelfrestores the thread's authentication information. This behavior is described as follows.

RevertToSelfrestores the authentication information on a thread to the authentication information on the thread before impersonation began. If the server does not call RevertToSelfbefore the end of the current call, it will be called automatically by COM.

When ImpersonateClientis called on a thread that is not currently impersonating, COM saves the token currently on the thread.

A subsequent call to RevertToSelfrestores the saved token, and IsImpersonatingwill then return false. This means that if a series of impersonation calls are made using different IServerSecurityobjects, RevertToSelfwill restore the token that was on the thread when the first call to ImpersonateClientwas made.

Also, only one RevertToSelfcall is needed to undo any number of ImpersonateClientcalls.

This method will only revert impersonation changes made by IServerSecurity::ImpersonateClient. If the thread token is modified by other means (through the SetThreadTokenor RpcImpersonateClientWin32 functions) the result of this function is undefined.

RevertToSelfaffects only the current method invocation. If there are nested method invocations, each invocation can have its own impersonation token and DCOM will correctly restore the impersonation token before returning to them (regardless of whether or not CoRevertToSelfor IServerSecurity::RevertToSelfwas called).

It is important to understand that an instance of IServerSecurityis valid on any thread in the apartment until the call represented by IServerSecuritycompletes.

However, impersonation is local to a particular thread for the duration of the current call on that thread. Therefore, if two threads in the same apartment use the same IServerSecurityinstance to call IServerSecurity::ImpersonateClient, one thread can call RevertToSelfwithout affecting the other.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header objidl.h, objidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

CoRevertToSelf