Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get available com ports? Pin
ThatsAlok27-Mar-05 23:20
ThatsAlok27-Mar-05 23:20 
AnswerRe: How to get available com ports? Pin
Joel Holdsworth27-Mar-05 23:21
Joel Holdsworth27-Mar-05 23:21 
Generalplease help Pin
khyap27-Mar-05 22:55
khyap27-Mar-05 22:55 
GeneralRe: please help Pin
Joel Holdsworth27-Mar-05 22:58
Joel Holdsworth27-Mar-05 22:58 
GeneralRe: please help Pin
ThatsAlok27-Mar-05 23:11
ThatsAlok27-Mar-05 23:11 
GeneralRe: please help Pin
Alexander M.,28-Mar-05 13:44
Alexander M.,28-Mar-05 13:44 
GeneralRe: please help Pin
David Crow28-Mar-05 2:36
David Crow28-Mar-05 2:36 
GeneralAdjustTokenPrivileges failing with SE_TCB_NAME enabled - repost Pin
ruharish27-Mar-05 21:35
ruharish27-Mar-05 21:35 
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
GeneralVideo Broadcasting Pin
Naru Patel27-Mar-05 21:15
Naru Patel27-Mar-05 21:15 
Questionhow to overwrite a string in a file in vc++? Pin
nehathoma27-Mar-05 20:22
nehathoma27-Mar-05 20:22 
AnswerRe: how to overwrite a string in a file in vc++? Pin
Aamir Butt28-Mar-05 2:16
Aamir Butt28-Mar-05 2:16 
GeneralMD5 Result Pin
Monty227-Mar-05 19:46
Monty227-Mar-05 19:46 
GeneralRe: MD5 Result Pin
Michael Dunn27-Mar-05 20:15
sitebuilderMichael Dunn27-Mar-05 20:15 
GeneralCTwain : With ActiveX control. It does not working ! . Help me please. Pin
Anand for every one27-Mar-05 18:55
Anand for every one27-Mar-05 18:55 
Generalaccess to windows desktop explorer Pin
seethat27-Mar-05 18:54
seethat27-Mar-05 18:54 
GeneralRe: access to windows desktop explorer Pin
Aamir Butt28-Mar-05 2:18
Aamir Butt28-Mar-05 2:18 
GeneralDrawing Lines Pin
frankieb27-Mar-05 18:32
frankieb27-Mar-05 18:32 
GeneralRe: Drawing Lines Pin
Joel Holdsworth27-Mar-05 22:46
Joel Holdsworth27-Mar-05 22:46 
GeneralEnable/Disable DirectX Pin
sachinsharma27-Mar-05 17:28
sachinsharma27-Mar-05 17:28 
GeneralIMAGES TO MOVIE file Pin
Emiliano27-Mar-05 14:15
Emiliano27-Mar-05 14:15 
GeneralRe: IMAGES TO MOVIE file Pin
Steve Mayfield27-Mar-05 16:33
Steve Mayfield27-Mar-05 16:33 
QuestionIs my application causing cluster server crash? Pin
adnbsn27-Mar-05 14:14
adnbsn27-Mar-05 14:14 
GeneralNested For Loop Program Pin
bigsing27-Mar-05 13:42
bigsing27-Mar-05 13:42 
GeneralRe: Nested For Loop Program Pin
Yulianto.27-Mar-05 13:57
Yulianto.27-Mar-05 13:57 
GeneralRe: Nested For Loop Program Pin
Ravi Bhavnani28-Mar-05 3:06
professionalRavi Bhavnani28-Mar-05 3:06 

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.