Re: Impersonating from a non admin user account
- From: Stefan Kuhr <kustt110@xxxxxx>
- Date: Tue, 31 Jul 2007 17:38:20 +0200
Hello Pradeep,
pradeep wrote:
I am trying to impersonate another user from a non admin account, but my code fails at 'LoadUserProfile' giving error 1314 : ERROR_PRIVILEGE_NOT_HELD
How do I elevate the privilege of process so that it performs the Impersonation?
Code:
if(!LogonUser(ui.userName,
pDomain,
ui.userPassword,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&tmpToken))
{
return FALSE;
}
memset (&pInfo, 0, sizeof (pInfo));
pInfo.dwSize = sizeof (pInfo);
pInfo.dwFlags = PI_NOUI;
_tcscpy (tmpBuf, (LPCTSTR)ui.userName);
pInfo.lpUserName = tmpBuf;
****This is where it fails,//same code works for admin account
if(!LoadUserProfile (tmpToken, &pInfo))
AfxMessageBox(_T("LoadUserProfile failed"));
if(!ImpersonateLoggedOnUser(tmpToken))
AfxMessageBox(_T("ImpersonateLoggedOnUser failed"));
I also tried using API's:
OpenProcessToken
LookupPrivilegeValue
AdjustTokenPrivileges (I there any API to add a privilege)
But I think this is to adjust already existing privileges.
Basically how do i Impersonate another user from a non-admin account?
Have you tried reverting the order of your LoadUserProfile and ImpsersonateLoggedOnUser calls?
--
Stefan
.
- Prev by Date: Re: Writing a Smart Card Minidriver (on PKCS#11)
- Next by Date: Re: Writing a Smart Card Minidriver (on PKCS#11)
- Previous by thread: Re: CPSetKeyParam question
- Next by thread: Re: Impersonating from a non admin user account
- Index(es):
Relevant Pages
|
|