H
HeXiang Lee
Unregistered / Unconfirmed
GUEST, unregistred user!
困扰了N天的问题,LogonUser在XP下可以正常使用, 在Win2000下不行,<br>查了MSDN,说是要设置SE_TCB_NAME Privilige,我设了,照样不行。代码如下<br><br> HANDLE hToken;<br><br> TOKEN_PRIVILEGES tkp;<br> OpenProcessToken(GetCurrentProcess(),<br> TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);<br><br> LookupPrivilegeValue(NULL, SE_TCB_NAME , &tkp.Privileges[0].Luid );<br><br> tkp.PrivilegeCount = 1;<br> tkp.Privileges [0].Attributes = tkp.Privileges [0].Attributes | SE_PRIVILEGE_ENABLED;<br> AdjustTokenPrivileges(hToken,FALSE,&tkp,sizeof(tkp),(PTOKEN_PRIVILEGES)NULL,0);<br><br> CloseHandle(hToken);<br><br> bool Flag=LogonUser((char*)pUserName, (char*)pDomain, (char*)pPassword,LOGON32_LOGON_INTERACTIVE,<br> LOGON32_PROVIDER_DEFAULT,&hToken);<br><br> if (Flag)<br> {<br> ImpersonateLoggedOnUser(hToken);<br> CloseHandle (hToken);<br> }<br> else<br> {<br> if (GetLastError()==ERROR_PRIVILEGE_NOT_HELD)<br> {<br> ShowMessage("SE_TCB_NAME error"<br> }<br> }<br> return Flag;