• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

registry

I'm using RegRestoreKey, and the function fails on
error number 1314. I use it as an administrator and
while writing to a key in which I have full control.
help ?
0
lolik121999
Asked:
lolik121999
  • 3
  • 2
1 Solution
 
jkrCommented:
The user you're using it with has to hold 'SE_RESTORE_NAME', which is not automatically granted for Administrators, just bot Backup Operators. Go to the user manager and set this privilege manually (Policies -> Privileges). The clear text name is "SeRestorePrivilege". This can also be done programmatically, but is quite a hassle.

Feel free to ask if you need more information!
0
 
lolik121999Author Commented:
I tried this, but it still doesn't work.
I even added my user to Backup Operators group and
it's still giving me error 1314.
0
 
abdijCommented:
Hi,
 Why dont you set and disable the previliges using the
1. SetPrivilege();
2. LookupPrivilegeValue();
3. AdjustTokenPrivileges();

functions???

See MSDN for further details.
Or shall i paste its conetnt here???

Just a hint,
Hope this is useful
Bye,
ABdij
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
jkrCommented:
Abdij is (almost) right, sometimes it is necessary to also *enable* that privilege, e.g.

BOOL    EnablePriv  (   BOOL    bEnable)
{
   HANDLE           hToken;
   TOKEN_PRIVILEGES tp;

   if   (   !OpenProcessToken   (   GetCurrentProcess   (),
                                    TOKEN_ADJUST_PRIVILEGES,
                                    &hToken
                                )
        )   return  (   FALSE);


   tp.PrivilegeCount    =   1;
   
   LookupPrivilegeValue (   NULL,
                            SE_RESTORE_NAME,
                            &tp.Privileges  [   0].Luid
                        );

   tp.Privileges    [   0].Attributes   =       bEnable
                                            ?   SE_PRIVILEGE_ENABLED
                                            :   0;

   AdjustTokenPrivileges    (   hToken,
                                FALSE,
                                &tp,
                                sizeof  (   tp),
                                NULL,
                                NULL
                            );

   return   (   GetLastError()  ==   ERROR_SUCCESS);
}
0
 
lolik121999Author Commented:
jkr, thank u for the code, it really helped.
just ask a question and u get the points.
abdij : thank u too.
0
 
jkrCommented:
Thanx! Fine that I could help you!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now