Compartir a través de


IServerSecurity::RevertToSelf (Windows CE 5.0)

Send Feedback

This method restores a thread's authentication information.

HRESULT RevertToSelf( )

Parameters

None.

Return Values

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::RevertToSelf sets the thread token to NULL. In Windows 2000, RevertToSelf restores the thread's authentication information. This behavior is described as follows.

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

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

A subsequent call to RevertToSelf restores the saved token, and IsImpersonating will then return false. This means that if a series of impersonation calls are made using different IServerSecurity objects, RevertToSelf will restore the token that was on the thread when the first call to ImpersonateClient was made.

Also, only one RevertToSelf call is needed to undo any number of ImpersonateClient calls.

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

RevertToSelf affects 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 CoRevertToSelf or IServerSecurity::RevertToSelf was called).

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

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 IServerSecurity instance to call IServerSecurity::ImpersonateClient, one thread can call RevertToSelf without affecting the other.

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

Requirements

OS Versions: Windows CE 3.0 and later.
Header: Objidl.h, Objidl.idl.
Link Library: Ole32.lib, Uuid.lib.

See Also

CoRevertToSelf

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.