c++ - Loading user profile from a service -


In a service, I try to use the following code to launch the program:

< Pre> handles HPP; Handle sticken; PROFILEINFO stProfileInfo; Four szUserName [64]; DWORD dwUserNameSize = 64; // Identify the client ImpersonateNamedPipeClient (HPP); Recover // User Name to (DOMAIN \ USER) GetUserNameEx (NameSamCompatible, szUserName, and dwUserNameSize); // Get Cloning Token Openathtoken (GetCurrentThread (), TOKEN_ALL_ACCESS, TRUE, and HTToken); // Load user profile to giro (& amp; SteffileInfo, PROFILEINFO); StProfileInfo.dwSize = sizeof (PROFILEINFO); StProfileInfo.dwFlags = PI_NOUI; StProfileInfo.lpUserName = szUserName; LoadUserProfile (hToken & amp; stProfileInfo);

Unfortunately, LoadUserProfile call GetLastError = 5 (access denied) fails with . In userenv.log, I can find out:

  USERENV Load User Profiles: Yes, we can impersonate the user. Running as its own USERENV LoadUserProfile: Login, hToken = & lt; 0xc8 & gt;, lpProfileInfo = 0xb30aa4 USERENV load Upyogkrtaprofail: lpProfileInfo-> dwFlags = & lt; 0x1 & gt; USERENV Load User Profile: lpProfileInfo-> lpUserName = & lt; MYDOMAIN \ USERNAME & gt; USERENV LoadUserProfile: NULL central profile path USERENV LoadUserProfile: NULL USERENV default profile path LoadUserProfile: NULL server name USERENV LoadUserProfile: Restore failed to enable privileges error = C0000022 USERENV load Usrprofail: return FALSE. Error = 5  

Of course, I did Czech ongoing as my service (system) SE_RESTORE_NAME (and SE_BACKUP_NAME ) Privilege is enabled.

Any help would be greatly appreciated!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -