Click here to Skip to main content
15,914,767 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Export templates from DLL Pin
includeh1027-Mar-05 7:15
includeh1027-Mar-05 7:15 
GeneralRe: Export templates from DLL Pin
MMansonFan2529-Mar-05 23:05
MMansonFan2529-Mar-05 23:05 
QuestionHow to start/stop service Pin
Iliya Yordanov26-Mar-05 23:08
Iliya Yordanov26-Mar-05 23:08 
AnswerRe: How to start/stop service Pin
Graham Bradshaw26-Mar-05 23:32
Graham Bradshaw26-Mar-05 23:32 
AnswerRe: How to start/stop service Pin
ThatsAlok28-Mar-05 1:15
ThatsAlok28-Mar-05 1:15 
QuestionWhat is the best C/C++ code optimizer? Pin
Vimvq198726-Mar-05 23:07
Vimvq198726-Mar-05 23:07 
AnswerRe: What is the best C/C++ code optimizer? Pin
Joel Holdsworth27-Mar-05 8:57
Joel Holdsworth27-Mar-05 8:57 
GeneralAdjustTokenPrivileges failing with SE_TCB_NAME enabled Pin
ruharish26-Mar-05 22:15
ruharish26-Mar-05 22:15 
Hi,

After many years, I've started developing C++ app to log into another server and perform some tasks. I'm getting the error 1314 (A required privilege is not held by the client), when I execute LogonUser function. Before I'm getting error 1300 (Not all privileges referenced are assigned to the caller), when I execute AdjustTokenPrivileges. I'm thinking that this error 1300 is triggering the error 1314. How can I get rid of these errors? FYI, I'm trying to log into my local machine with the local username/password (LOGIN/PASSWORD). This is a Win 2k pro machine, which is not part of any domain. I'm observing all these error codes while stepping thru the code in MS Visual env.

Last point is, LookupPrivilegeValue is returning an error code of 997 (Overlapped I/O operation is in progress). Could this also be causing the current problem?

Any help or pointer in resolving my current issue is greatly appreciated. Have a nice day & week ahead!

Code snippet:
char *szUserName = (char*)malloc(65);
char *szDomain = (char*)malloc(65);
char *szPassword = (char*)malloc(65);

strcpy(szUserName, "LOGIN");
strcpy(szDomain, ".");
strcpy(szPassword, "PASSWORD");

DWORD dwSize = 50+1;
char szUser[50+1]={0};

PROFILEINFO MyProfile = {0};
LUID Luid;

//The following stmt is throwing error 997 (Overlapped I/O operation is in progress)

if(!LookupPrivilegeValue(NULL, SE_TCB_NAME, &Luid))
{
OutputDebugString("LookupPrivilegeValue failed.\n");
iLastError = GetLastError();
goto Exit;
}

HANDLE hProcToken;

if(!OpenProcessToken(
GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY|TOKEN_DUPLICATE,
&hProcToken))
{
OutputDebugString("OpenProcessToken failed.\n");
iLastError = GetLastError();
goto Exit;
}

TOKEN_PRIVILEGES TokenPriv;
TokenPriv.PrivilegeCount = 1;
TokenPriv.Privileges[0].Luid = Luid;
TokenPriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

//The following stmt is throwing error 1300 (Not all privileges referenced are assigned to the caller)

if(!AdjustTokenPrivileges(
hProcToken,
FALSE,
&TokenPriv,
0,
NULL,
NULL))
{
OutputDebugString("AdjustTokenPrivileges failed\n");
iLastError = GetLastError();
goto Exit;
}

// Log on as user with valid credentials for accessing the Exchange server.
//The following stmt is throwing error 1314 (A required privilege is not held by the client)

if (!LogonUser(
szUserName,
szDomain,
szPassword,
LOGON32_LOGON_SERVICE,
//LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&hToken))
{
OutputDebugString("LogonUser failed.\n");
iLastError = GetLastError();
goto Exit;
}

Thanx,
harish
GeneralStupid question Pin
eli1502197926-Mar-05 21:49
eli1502197926-Mar-05 21:49 
GeneralRe: Stupid question Pin
Graham Bradshaw26-Mar-05 23:35
Graham Bradshaw26-Mar-05 23:35 
GeneralRe: Stupid question Pin
eli1502197927-Mar-05 3:11
eli1502197927-Mar-05 3:11 
GeneralRe: Stupid question Pin
David.Kelly4-Apr-05 11:04
David.Kelly4-Apr-05 11:04 
Generalchange bitmap button during runtime Pin
Yaron Abershitz26-Mar-05 21:49
Yaron Abershitz26-Mar-05 21:49 
GeneralRe: change bitmap button during runtime Pin
namaskaaram27-Mar-05 16:50
namaskaaram27-Mar-05 16:50 
GeneralEvent Threading Pin
zx2c426-Mar-05 16:30
zx2c426-Mar-05 16:30 
GeneralLinked Lists & Arrays and Locality of Reference Pin
Ziro_026-Mar-05 16:28
Ziro_026-Mar-05 16:28 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Michael Dunn26-Mar-05 20:33
sitebuilderMichael Dunn26-Mar-05 20:33 
GeneralRe: Linked Lists & Arrays and Locality of Reference Pin
Anonymous27-Mar-05 6:05
Anonymous27-Mar-05 6:05 
GeneralVC++ relationship between low-level objkects and GUI interfaces Pin
Anonymous26-Mar-05 10:41
Anonymous26-Mar-05 10:41 
GeneralRe: VC++ relationship between low-level objkects and GUI interfaces Pin
PJ Arends26-Mar-05 11:12
professionalPJ Arends26-Mar-05 11:12 
GeneralGlobal Function Pin
Static(x)26-Mar-05 9:49
Static(x)26-Mar-05 9:49 
GeneralRe: Global Function Pin
PJ Arends26-Mar-05 11:18
professionalPJ Arends26-Mar-05 11:18 
GeneralRestarting the process!! Pliz help Pin
mpapeo26-Mar-05 9:41
mpapeo26-Mar-05 9:41 
GeneralRe: Restarting the process!! Pliz help Pin
Gary R. Wheeler26-Mar-05 13:53
Gary R. Wheeler26-Mar-05 13:53 
GeneralRe: Restarting the process!! Pliz help Pin
mpapeo27-Mar-05 3:04
mpapeo27-Mar-05 3:04 

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.