AI摘要

本文介绍了如何在Delphi中集成Windows验证登录函数。在Windows NT和2000系统中,调用LogonUser过程需要SE_TCB_NAME特权,因此建议从具有此特权的本地系统账户运行服务。文章提供了Delphi代码实现,包括定义VerifyWindowsUser函数,使用LogonUser验证用户凭证,并在成功时关闭句柄。
本文介绍了如何在Delphi中集成Windows验证登录函

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.  

delphi代码
  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;     


最后修改:2009 年 08 月 16 日
点赞的人是最酷的