Click here to Skip to main content
15,911,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGet a pointer from another function Pin
4-Jul-01 6:37
suss4-Jul-01 6:37 
GeneralRe: Get a pointer from another function Pin
Paolo Messina4-Jul-01 6:57
professionalPaolo Messina4-Jul-01 6:57 
GeneralRe: Get a pointer from another function Pin
Oscar Londono4-Jul-01 7:07
Oscar Londono4-Jul-01 7:07 
GeneralRe: Get a pointer from another function Pin
Mike Burston4-Jul-01 12:41
Mike Burston4-Jul-01 12:41 
GeneralRe: Get a pointer from another function Pin
Oscar Londono4-Jul-01 13:56
Oscar Londono4-Jul-01 13:56 
GeneralWTL CIPAddressCtrl Pin
4-Jul-01 6:08
suss4-Jul-01 6:08 
GeneralRe: WTL CIPAddressCtrl Pin
4-Jul-01 6:33
suss4-Jul-01 6:33 
GeneralRegSaveKey and RegRestoreKey Advanced Privilege problems Pin
4-Jul-01 5:43
suss4-Jul-01 5:43 
I have created a Registry Backup program that restores and saves certain registry files. However, it only works fine when logged on as an administrator. When logged on with less rights I have the following error:

1314 : A required privilege is not held by the client.

I know from previous investigations that privileges need to be set which I have done as follows:-

BOOL CRegistryBackupDlg::EnableBackupPrivilege()
{
HANDLE hToken = NULL;

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

TOKEN_PRIVILEGES tkp;
LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

BOOL bOk = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
CloseHandle(hToken);

return bOk;

}

and

BOOL CRegistryBackupDlg::EnableRestorePrivilege()
{
HANDLE hToken = NULL;

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

TOKEN_PRIVILEGES tkp;
LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

BOOL bOk = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
CloseHandle(hToken);

return bOk;

}
These usually allow to perform the functions. However I have pinpointed my problems down to RegSaveKey and RegRestoreKey not having sufficient privileges when not logged on as administrator.

My two regsitry calls look like this :-

lResult = RegSaveKey(hKey, m_current_path , NULL);

or

lResult = RegRestoreKey(hKey, m_current_path, NULL);


Like I said it usually works when logged on as administrator so I know that the majority of my code works it just a slight tweak of the privileges that is required but I really don't what is needed. Can you help?

Thanks in advance. Smile | :)











GeneralRe: RegSaveKey and RegRestoreKey Advanced Privilege problems Pin
Michael Dunn4-Jul-01 7:18
sitebuilderMichael Dunn4-Jul-01 7:18 
GeneralRe: RegSaveKey and RegRestoreKey Advanced Privilege problems Pin
5-Jul-01 0:01
suss5-Jul-01 0:01 
QuestionWhere do I start? Pin
MolleX4-Jul-01 5:33
MolleX4-Jul-01 5:33 
AnswerRe: Where do I start? Pin
4-Jul-01 5:45
suss4-Jul-01 5:45 
GeneralStatic Text and CStatic Pin
4-Jul-01 5:08
suss4-Jul-01 5:08 
GeneralRe: Static Text and CStatic Pin
Tomasz Sowinski4-Jul-01 5:18
Tomasz Sowinski4-Jul-01 5:18 
Generalfatal error c1189 Pin
Gérald Mercet4-Jul-01 4:56
Gérald Mercet4-Jul-01 4:56 
GeneralRe: fatal error c1189 Pin
Tomasz Sowinski4-Jul-01 5:12
Tomasz Sowinski4-Jul-01 5:12 
Questionhow to get access to the previous document in MDI Pin
mr20034-Jul-01 2:14
mr20034-Jul-01 2:14 
AnswerRe: how to get access to the previous document in MDI Pin
l a u r e n4-Jul-01 11:13
l a u r e n4-Jul-01 11:13 
Generaltwo string tables Pin
Maham Gilani4-Jul-01 2:00
Maham Gilani4-Jul-01 2:00 
GeneralRe: two string tables Pin
Tomasz Sowinski4-Jul-01 2:11
Tomasz Sowinski4-Jul-01 2:11 
GeneralRe: two string tables Pin
Maham Gilani4-Jul-01 2:17
Maham Gilani4-Jul-01 2:17 
GeneralRe: two string tables Pin
Tomasz Sowinski4-Jul-01 4:34
Tomasz Sowinski4-Jul-01 4:34 
GeneralRe: two string tables Pin
Erik Funkenbusch4-Jul-01 9:28
Erik Funkenbusch4-Jul-01 9:28 
GeneralCHttpFile::ReadString Pin
Winston,Dang3-Jul-01 23:43
Winston,Dang3-Jul-01 23:43 
GeneralRe: CHttpFile::ReadString Pin
Anders Molin4-Jul-01 2:02
professionalAnders Molin4-Jul-01 2:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.