| velkur 2005-03-28, 8:58 am |
| Hi,
I'm getting the error 1314 (A required privilege is not held by the client),
when I execute LogonUser function. Before that, 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.
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|TOKE
N_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.
|