views:

177

answers:

2

I have code that uses Win API function RegSaveKeyEx to save registry entries to a file. However, RegSaveKeyEx returns ERROR_PRIVILEGE_NOT_HELD when run on Win Vista or Win 7. The code enables security privilege SE_BACKUP_NAME using code Microsoft provides in example function SetPrivilege.

Everything works fine on Win XP (admin user) or if I disable UAC on Win Vista or Win 7. Is it not possible to use RegSaveKeyEx on Vista without elevating the process?

+1  A: 

Standard users do not have SE_BACKUP_NAME privilege, so no, RegSaveKeyEx will not work on Vista without elevation.

Backup is one of the very "dangerous" privileges - it enables you to basically read anything on disk regardless of ACL's.

Michael
A: 

You could give permission the specific user (or group) by going to the following ...

Control Panel->
  Administrative Tools->
    Local Security Policy->
      Local Policies->
        User Rights Assignment-> Back up files and directories (SE_BACKUP_NAME)

... and adding the user (or group) you want. Or you could add the users to Backup Operators.

But, you should be cautious here. See great comment below by Michael.

JP Alioto
I'd be very cautious granting users backup privilege - it allows them to bypass ACL's for all file read operations. This would mean an unprivileged user would be able to read anything on disk - even cached password data.
Michael