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 ?
lolik121999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.