Microsoft KB Archive/115233

DOCERR: References to APIs that Do Not Exist PSS ID Number: Q115233 Article last modified on 06-08-1994

3.10

WINDOWS NT

= SYMPTOMS =

The “Win32 Programmer’s Reference,” volume 2, section 54.4.3, “Changing User Profiles” (page 233), lists the following sequence of APIs that need to be called in order to change a user profile:

WriteProfileString RevertToSelf

However, ImpersonateClient, OpenProfileUserMapping, and CloseProfilerUserMapping are not documented Win32 APIs.

= RESOLUTION =

In a server application, if you want to change another user’s context, you must impersonate the user, using ImpersonateNamedPipeClient, ImpersonateDdeClientWindow, DdeImpersonateClient, or RpcImpersonateClient as appropriate.

At one point in time, Open/CloseProfileUserMapping were present in the Win32 API, but they were later removed. The printed documents do not reflect this change.

The correct sequence of APIs is as follows:

hPipe = CreateNamedPipe( … ); RegCloseKey( HKEY_CURRENT_USER ); ImpersonateNamedPipeClient( hPipe, … ); RegOpenKey( HKEY_CURRENT_USER, … );

// Make your modifications to client’s HKEY_CURRENT_USER.

RegCloseKey( HKEY_CURRENT_USER ); RevertToSelf; RegOpenKey( HKEY_CURRENT_USER, … ); CloseHandle( hPipe );

Additional reference words: 3.10 KBCategory: Ref KBSubcategory: BseMisc

=
================================================================

Copyright Microsoft Corporation 1994.