The first and biggest of these restrictions is that on Windows NT and Windows 2000, the process that is calling LogonUser must have the SE_TCB_NAME privilege (in User Manager, this is the ""Act as part of the Operating System"" right). The SE_TCB_NAME privilege is very powerful and should not be granted to any arbitrary user just so that they can run an application that needs to validate credentials. The recommended method is to call LogonUser from a service that is running in the local system account, because the local system account already has the SE_TCB_NAME privilege.  

  1. function   VerifyWindowsUser(const   Machine,Username,Password:String):boolean;      
  2.   var   hToken:THandle;      
  3.   begin      
  4.     hToken:=0;      
  5.     Result:=LogonUser(PChar(UserName),PChar(Machine),PChar(Password),LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,hToken);      
  6.     if(hToken<>0)then      
  7.       CloseHandle(hToken);      
  8.   end;     
Posted in 软件开发 by 傻猫 at October 17, 2007.
Tags: 函数, windows, 验证, 登录