Delphi集成Windows验证登录函数

samool 发布暂无评论11040 阅读

AI摘要

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

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;     
  1. 01Golang 汇编入门知识总结2020-09-27
  2. 02未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序2020-09-22
  3. 03DELPHI实现关机,兼容全部WINDOWS系统2015-09-07
  4. 04Windows Phone 8 发布2012-10-30
  5. 05mysql笔记(5)--集合函数,时间日期函数,字符串匹配函数2012-03-01
  6. 06SQL自定义函数实现特殊功能2011-09-07
  7. 07nginx 1.0.0终于发布了2011-04-12
  8. 08IdHTTP组件提交表单及登录源码(强制使用http 1.1)2010-08-04
  9. 09Delphi常用的函数库2008-03-11
  10. 10汇编级超快字符串替换函数2007-10-23
COMMENTS / 一纸留言

读者留言 0 条

一纸留言,便是山水间的一次相逢。

还没有留言,欢迎写下第一段交流。

WRITE A COMMENT

写下你的留言