信息系统中用户的域AD认证功能

本文详细介绍了LogonUser函数的功能及使用方法。该函数用于尝试将用户登录到本地计算机上,并通过用户名、域及明文密码来指定和验证用户。若成功,则返回一个代表已登录用户的令牌句柄。

{

The LogonUser function attempts to log a user on to the local computer. The local computer is the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote computer. You specify the user with a user name and domain and authenticate the user with a plaintext password. If the function succeeds, you receive a handle to a token that represents the logged-on user. You can then use this token handle to impersonate the specified user or, in most cases, to create a process that runs in the context of the specified user.

BOOL LogonUser(
  __in      LPTSTR lpszUsername,//UserName
  __in_opt  LPTSTR lpszDomain,//Domain
  __in_opt  LPTSTR lpszPassword,//password
  __in      DWORD dwLogonType,//Logon Type
  __in      DWORD dwLogonProvider,//LogonProvider
  __out     PHANDLE phToken//A pointer to a handle variable that receives a handle to a token that represents the specified user

);

}

 1 function   ValidateUserLogonAPI(const   UserName:   string; const   PassWord:   string):   boolean;
 2 
 3 var
 4 
 5     Retvar:   boolean;
 6 
 7     LHandle:   THandle;
 8 
 9 begin
10 
11     Retvar   :=   LogonUser(PChar(UserName),
12 
13         PChar(string(OP_ADDomain)),   PChar(PassWord),
14 
15         LOGON32_LOGON_NETWORK,//This logon type is intended for high performance servers to authenticate plaintext passwords. The LogonUser function does not                                              //cache credentials for this logon type.
16 
17         LOGON32_PROVIDER_DEFAULT,//Use the standard logon provider for the system.
18 
19         LHandle);
20 
21     if   Retvar   then
22 
23         CloseHandle(LHandle);//close the handle
24 
25     Result   :=   Retvar;
26 
27 end;

 

 

转载于:https://www.cnblogs.com/songrun/archive/2013/06/08/3125992.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值