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

{

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;

 

 

posted @ 2013-06-08 11:50  自由的企鹅  阅读(630)  评论(0编辑  收藏  举报