Windows API 函数LogonUser问题(200分)

  • 主题发起人 主题发起人 HeXiang Lee
  • 开始时间 开始时间
H

HeXiang Lee

Unregistered / Unconfirmed
GUEST, unregistred user!
困扰了N天的问题,LogonUser在XP下可以正常使用, 在Win2000下不行,<br>查了MSDN,说是要设置SE_TCB_NAME Privilige,我设了,照样不行。代码如下<br><br> HANDLE hToken;<br><br> &nbsp;TOKEN_PRIVILEGES tkp;<br> &nbsp;OpenProcessToken(GetCurrentProcess(),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);<br><br> &nbsp;LookupPrivilegeValue(NULL, SE_TCB_NAME , &tkp.Privileges[0].Luid );<br><br> &nbsp;tkp.PrivilegeCount = 1;<br> &nbsp;tkp.Privileges [0].Attributes = &nbsp;tkp.Privileges [0].Attributes | SE_PRIVILEGE_ENABLED;<br> &nbsp;AdjustTokenPrivileges(hToken,FALSE,&tkp,sizeof(tkp),(PTOKEN_PRIVILEGES)NULL,0);<br><br> &nbsp;CloseHandle(hToken);<br><br> &nbsp;bool Flag=LogonUser((char*)pUserName, (char*)pDomain, (char*)pPassword,LOGON32_LOGON_INTERACTIVE,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LOGON32_PROVIDER_DEFAULT,&hToken);<br><br> &nbsp;if (Flag)<br> &nbsp;{<br> &nbsp; &nbsp;ImpersonateLoggedOnUser(hToken);<br> &nbsp; &nbsp;CloseHandle (hToken);<br> &nbsp;}<br> &nbsp;else<br> &nbsp;{<br> &nbsp; &nbsp;if (GetLastError()==ERROR_PRIVILEGE_NOT_HELD)<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp;ShowMessage(&quot;SE_TCB_NAME error&quot;);<br> &nbsp; &nbsp;}<br> &nbsp;}<br> &nbsp;return Flag;
 
人呢!都对这个不感兴趣吗?
 
呵呵,不太清楚,帮你顶一下
 
只有你一个人帮我顶了一下,谢谢你啦! 分全给你!
 
后退
顶部