如何进行WINDOWS集成身份验证? ( 积分: 200 )

  • 主题发起人 主题发起人 bundur
  • 开始时间 开始时间
B

bundur

Unregistered / Unconfirmed
GUEST, unregistred user!
客户机A 已经登录到 域 X<br>问题: 在 DELPHI 中如何进行确认 A 已经登录到 X ?<br><br>还有,如果 X 相对于 A 是在一个远程域, A 先登录到 本地的域, 再通过VPN登录到 X<br>这时 在 DELPHI 中如何进行确认 A 已经登录到 X ?<br><br>不够分可再加分!
 
客户机A 已经登录到 域 X<br>问题: 在 DELPHI 中如何进行确认 A 已经登录到 X ?<br><br>还有,如果 X 相对于 A 是在一个远程域, A 先登录到 本地的域, 再通过VPN登录到 X<br>这时 在 DELPHI 中如何进行确认 A 已经登录到 X ?<br><br>不够分可再加分!
 
不错的问题,帮你找找资料看
 
MSDN里面介绍ADSI就是所谓Active Directory Server Interfce,面向活动目录的编程接口<br><br>下面是整理的一些资料<br><br>1、获得AD对象<br>var <br> &nbsp;OU : OleVariant;<br>begin<br> &nbsp;OU := GetObject(&quot;ou=Finance, dc=fabrikam, dc=com&quot;);<br>{参数含义<br>User &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cn <br>Group/Container &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Cn <br>organizationalUnit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ou <br>Domain &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dc }<br><br>获得之后<br>操作 &nbsp; &nbsp; &nbsp;方法<br>Read &nbsp; &nbsp; &nbsp;Get &nbsp;<br>Create &nbsp; &nbsp;Createt <br>Modify &nbsp; &nbsp;Put &nbsp;<br>Delete &nbsp; &nbsp;Delete &nbsp;<br><br>如果打算使用其中任何一种方法,还需要在语句中以参数的形式提供相应的信息,比如“创建什么内容?”之类的。假设现在我们要在acme.com的Marketing OU中创建一个名为MSmith的用户,我们可以使用这段代码 。<br>OU := &nbsp;GetObject(&quot;LDAP://ou=Marketing, dc=acme, dc=com&quot;);<br>User := OU.Create(&quot;user&quot;, &quot;cn=MSmith&quot;);<br>User.Put(&quot;sAMAccountName&quot;, &quot;MSmith&quot;);<br>User.SetInfo;<br>详细请看<br>http://www.zdnet.com.cn/techupdate/implement/system/windows/story/0,3800072540,39292066,00.htm<br><br>2、刚刚找到的大牛的文章,还是Delphi的,里面有介绍使用这个ADSI的<br>http://www.csdn.com.cn/zmogxsojxzocxvoj/sjxxouofdzdsdsdd/vfovouxzojodxvogxzxu/dfdzdsdsdj/dsdx/cxdzdsdsdjdsdxdcdodcdrdvdrdzdxdzdvdodjdd.html<br><br>http://hubdog.csdn.net/Hubdog/AD.htm<br><br>里面写了如何获得用户,既然能获得用户了,当然知道他是否登录了,你只需要这个用户的用户名,然后去查询相应的LDAP(这里是AD)服务器就可以了,如果已经登录就不需要重新登录了<br><br>下面是个人看法:<br>LDAP的目的似乎为了单点登录,用户共享,某个LDAP服务器开起来之后,其他系统就可以不用自己建立用户权限了,因为这个LDAP服务器里面有了用户权限,只要引用就可以了,用户只要在一个地方登录,其他的地方就不需要重复登录了,所以如果能直接使用LDAP的服务协议可能根好,就象HTTP协议,FTP协议那样。这些估计是废话了,抛砖引玉,等楼下个高手
 
思路是对的,使用API取得连接相应的接口,不过GetObject是VB的。<br><br>你可以用ADsGetObject等系列的API。<br><br>有Delphi已经写好的API,要得话给个email,给你发过去
 
多谢上述各位指点, 但 ADsGetObject 只能取得域上的用户, 并不能说明当前用户是否登录,并且, 不是所有的用户都可以取得域的用户.
 
看来你还是不明白,去好好看看Binding to AD,怎样使用ADsGetObject、ADsOpenObject,DsBind等也瞧瞧
 
to: Bruce.xm,<br>您可能误解我的意思了, 我的目的是做到当一个用户登录后, 把他登录所用的用户名发到目标域上进行验证, 看他当前登录的域是否就是该域.<br><br>比如, 用户 A 在 域 Y 上有用户名, 但操作员 M 没有用户 A 在 Y 上的密码, 并想进入 XXX 系统, 可该系统是WINDOWS集成身份验证的, 这时如果 M 就在域 Z 上创建了一个用户 A, 他登录到 Z 上了, XXX系统进行身份验证时, 如何确认 A 登录的不是 Y 域, 以拒绝 A 运行系统 ? <br>现在我要做的就是 XXX 系统的身份验证 模块, 如何实现?<br>另. 我的 Email 地址是: ben1999@21cn.com 烦请把相关API发给我, 谢谢
 
NetWkstaUserGetInfo可以让你取得当前登陆的User和Domain和Server
 
WKSTA_USER_INFO_1<br>-------------------------<br>wkui1_username <br>Specifies the name of the user currently logged on to the workstation. <br>wkui1_logon_domain <br>Specifies the name of the domain in which the user is currently logged on. <br>wkui1_oth_domains <br>Specifies the list of operating system domains browsed by the workstation. The domain names are separated by blanks. <br>wkui1_logon_server <br>Specifies the name of the server that authenticated the user.
 
我的 Email 地址是: willing66@163.com 烦请把相关API发给我, 谢谢
 
邮件已发,希望对你有用
 
NetWkstaUserGetInfo 取不到 9x 下的登录用户.因为它只适用于 NT 架构的平台
 
欢迎加入Borland 一线程序员,参与群里技术讨论!欢迎女孩子,也欢迎男孩子参与技术讨论!群号15154361
 
这个好办,你参考下以下就可以了,祝你好运:<br><br>Determining the Validating Server on Windows 95/98/Me<br><br>Determining the Windows Server 2003 family, Windows 2000, or Windows NT domain server that validates a user's logon password from Windows 95/98/Me is an involved task. The code sample in this topic demonstrates how to determine the validating server for a Windows Me/98/95 user, using the 16-bit network management functions.<br><br><br>On Windows Server 2003 family, Windows XP, Windows 2000, and Windows NT, the 32-bit NetWkstaUserGetInfo function determines the validating server. The function uses level 1 to return a WKSTA_USER_INFO_1 structure. The wkui1_logon_server member will contain a pointer to a Unicode string specifying the validating server.<br><br>On Windows Me/98/95, there is no 32-bit function that will return the same information. You must use the 16-bit network management functions to retrieve the same information. The functions are exported from Netapi.dll. The link libraries are included with the 16-bit version of Microsoft&amp;reg; Visual C++ (version 1.5x).<br><br>To determine the validating server on Windows Me/98/95<br><br><br>Use the following basic steps, making calls to the 16-bit network management functions:<br><br><br>1、Determine the user's logon domain using NetWkstaGetInfo. <br>2、Find the primary domain controller (PDC) using NetGetDCName. <br>3、Get the user information from the PDC for comparison to the backup domain controller (BDC) data using NetUserGetInfo. <br>4、Get a list of BDCs using the NetServerEnum function. <br>5、Loop through the list of BDCs, using NetUserGetInfo to retrieve the specific user information, comparing each last logon time, searching for the greatest value. <br>The largest last logon value will be the latest logon time; it will be associated with the last server to validate the user's logon password.
 
它的例子也给你:<br>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;time.h&gt;<br>#define INCL_NET <br>#include &lt;lan.h&gt;<br><br>// Constant definitions.<br><br>#define LEVEL_01 1<br>#define LEVEL_11 11<br>#define LEVEL_10 10<br>#define LEVEL_00 0<br><br>#define SMALL_BUFFER 1024<br>#define MEDIUM_BUFFER 4*1024<br>#define SERVER_NAME &nbsp;50<br><br>// Buffer allocation performed globally for simplicity.<br><br>LPSTR bdcNames[SMALL_BUFFER];<br>LPSTR UserData[MEDIUM_BUFFER];<br>LPSTR WrkSta[SMALL_BUFFER];<br>LPSTR pdcName[SERVER_NAME];<br>LPSTR servername[SERVER_NAME]; <br><br>// Create a structure to hold the current server and <br>// &nbsp;the logon time so the values are together.<br><br>typedef struct svr_usr {<br> &nbsp; &nbsp;LPSTR server;<br> &nbsp; &nbsp;long logon_time;<br>} SVR_USR;<br><br>// Create typedefs for the larger structure names to <br>// &nbsp;shorten the number of characters to type.<br><br>typedef struct user_info_11 &nbsp;USER11;<br>typedef struct wksta_info_10 WORK10;<br>typedef struct wksta_info_1 WORK01;<br>typedef struct server_info_100 SERVER100;<br>typedef struct tm TIMER;<br><br>// Declare pointers so the buffers returned from the system<br>// &nbsp;functions can be cast to an appropriate value.<br><br>// &nbsp; Global variable descriptions.<br>// &nbsp; &nbsp; Users: &nbsp; Pointer to a USER_INFO_11 structure that contains user <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;information about the username derived from the Wksta <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;array. The element of interest is usri11_last_logon, the <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;time that the server last validated the user's <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;password.<br>// &nbsp; &nbsp; Wksta: &nbsp; Pointer to the WKSTA_INFO_10 structure that contains <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;information about the WFW workstation. This structure is <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;filled first, and the information placed there is used <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to get additional information. The domain name is used <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;to get a list of BDCs that will be queried for user <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data. The username is the element that will qualify the <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;user data request. The elements of interest are <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wki10_username, the current logged-on user, and <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wki10_logon_domain, the domain in which the user <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;has logged on.<br>// &nbsp; &nbsp; Servers: List of BDCs for the user's logon domain. Each <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;server in the array will be queried for information <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;about the current logged-on user as described <br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;in the user's variable comments.<br>//<br><br>TIMER &nbsp;*lpTime;<br>USER11 &nbsp;far *Users;<br>WORK10 &nbsp;far *Wksta;<br>SERVER0 far *Servers;<br>WORK01 &nbsp;far *Wksta01;<br><br>char * lpszTime;<br><br>// Declare values for use with the network management functions.<br><br>unsigned short svrEntries;<br>unsigned short svrRead;<br>unsigned short usrEntries;<br>unsigned short wkstaEntries;<br><br>// Create a temporary variable to use as a loop control variable.<br><br>unsigned short i;<br><br>char Message[256];<br><br>// Define a global variable to hold the validating server <br>// &nbsp;and the time the user last logged on.<br><br>SVR_USR validate = { NULL, 0 };<br><br>// Create a global variable for the return value of the function; <br>// &nbsp;this is used in error checking.<br><br>DWORD netRet;<br><br>// Bogus WinMain so you can step through the sample <br>// &nbsp;in a 16-bit debugger.<br><br>int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)<br>HANDLE hInstance; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// current instance <br>HANDLE hPrevInstance; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// previous instance <br>LPSTR lpCmdLine; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // command line <br>int nCmdShow; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// show-window type (open/icon) <br>{<br> &nbsp; // First, get the workstation information calling <br> &nbsp; // &nbsp;the NetWkstaGetInfo function at level 10. <br> &nbsp; // &nbsp;This will return the domain in which the user logged on.<br><br> &nbsp; netRet = NetWkstaGetInfo( NULL, &nbsp;// This workstation<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LEVEL_10, &nbsp;// Information requested<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (char far *)WrkSta, &nbsp;// Buffer<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SMALL_BUFFER, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;wkstaEntries); // Expecting only 1 entry<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; if( netRet != NERR_Success )<br> &nbsp; {<br> &nbsp; &nbsp; &nbsp;// A network error occurred. Print it to the stdout.<br><br> &nbsp; &nbsp; &nbsp;sprintf(Message,&quot;ERROR: NetWkstaGetInfo API Failed. Error Code: %d/n&quot;, netRet);<br> &nbsp; &nbsp; &nbsp;MessageBox( NULL, Message, &quot;NetWkstaGetInfo Error&quot;, MB_OK);<br> &nbsp; &nbsp; &nbsp;return(0);<br> &nbsp; }<br><br> &nbsp; // Now we must retrieve the BDCs and the PDC to check <br> &nbsp; // &nbsp;when the last user logon was validated. <br> &nbsp; //<br> &nbsp; // The argument list is set as follows:<br> &nbsp; // &nbsp; Execute on the local machine ( NULL )<br> &nbsp; // &nbsp; Pass the domain name of interest (Wksta[0].wki10_logon_domain)<br> &nbsp; // &nbsp; Pass a buffer to receive the PDC name<br> &nbsp; // &nbsp; Pass the size of the PDC name buffer<br> <br> &nbsp; Wksta = (WORK10 *)WrkSta;<br> &nbsp; netRet = NetGetDCName( NULL, &nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Wksta[0].wki10_logon_domain,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(char far *)pdcName,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SERVER_NAME);<br> &nbsp; if(netRet != NERR_Success )<br> &nbsp; {<br> &nbsp; &nbsp; &nbsp;// Could not locate a PDC. Something is wrong; end the program.<br><br> &nbsp; &nbsp; &nbsp;sprintf(Message,&quot;ERROR: NetGetDCName API Failed. Error Code: %d/n&quot;, netRet);<br> &nbsp; &nbsp; &nbsp;MessageBox( NULL, Message, &quot;NetGetDCName Error&quot;, MB_OK);<br> &nbsp; &nbsp; &nbsp;return(0);<br> &nbsp; }<br><br> &nbsp; // We have the PDC. Now, query for the user information, <br> &nbsp; // &nbsp; and store it temporarily for comparison to the BDC's data.<br><br> &nbsp; netRet = NetUserGetInfo( (char far *)pdcName, &nbsp;// Execute on the PDC<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Wksta[0].wki10_username, // User's name<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LEVEL_11,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(char far *)UserData, // Put structures here<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SMALL_BUFFER,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;usrEntries); // Expecting only one entry<br> &nbsp; if( netRet != NERR_Success )<br> &nbsp; {<br> &nbsp; &nbsp; &nbsp; // No user account on the PDC. End the program.<br><br> &nbsp; &nbsp; &nbsp;sprintf(Message,&quot;ERROR: NetUserGetInfo API Failed on PDC. Error Code: %d/n&quot;, netRet);<br> &nbsp; &nbsp; &nbsp;MessageBox( NULL, Message, &quot;NetUserGetInfo Error&quot;, MB_OK);<br> &nbsp; &nbsp; &nbsp;return(0);<br> &nbsp; }<br><br> &nbsp; // Set the structure so the PDC is the starting validating server.<br><br> &nbsp; validate.server = &nbsp;(char far *)pdcName;<br> &nbsp; Users = (USER11 * )UserData;<br> &nbsp; validate.logon_time = Users[0].usri11_last_logon;<br><br> &nbsp; // Now retrieve all of the BDCs.<br><br> &nbsp; netRet = NetServerEnum2( &nbsp;NULL,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LEVEL_00,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (char far *)bdcNames,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SMALL_BUFFER,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;svrRead,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;svrEntries,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SV_TYPE_DOMAIN_BAKCTRL,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Wksta[0].wki10_logon_domain);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; if( netRet != NERR_Success )<br> &nbsp; {<br> &nbsp; &nbsp; &nbsp;// No BDCs. This could be an error.<br><br> &nbsp; &nbsp; &nbsp;sprintf(Message,&quot;ERROR: NetServerEnum2 API Failed. Error Code: %d&quot;, netRet);<br> &nbsp; &nbsp; &nbsp;MessageBox( NULL, Message, &quot;NetServerEnum2&quot;, MB_OK);<br> &nbsp; &nbsp; &nbsp;return( 0 );<br> &nbsp; }<br><br> &nbsp; // We have a list of BDCs. <br> &nbsp; // If svrEntries &gt; 1<br> &nbsp; // &nbsp; &nbsp;loop through the list, checking the last logon against the<br> &nbsp; // &nbsp; &nbsp; current logon stored in validate.logon_time.<br><br> &nbsp; Servers =( SERVER0 * )bdcNames;<br> &nbsp; for( i = 0; i &lt; svrEntries; i++ )<br> &nbsp; {<br> &nbsp; &nbsp; &nbsp;// Must add the // to the names returned from the NetServerEnum function.<br><br> &nbsp; &nbsp; &nbsp;_fstrcpy( (LPSTR)servername,&quot;////&quot;);<br> &nbsp; &nbsp; &nbsp;_fstrcat( (LPSTR)servername,Servers.sv0_name);<br> &nbsp; &nbsp; &nbsp;netRet = NetUserGetInfo( (LPSTR)servername, &nbsp;// Execute on a BDC<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Wksta[0].wki10_username, &nbsp;// User's name<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LEVEL_11,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (char far *)UserData,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SMALL_BUFFER,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;usrEntries); // Expecting only one entry<br> &nbsp; &nbsp; &nbsp;Users = (USER11 *)UserData;<br> &nbsp; &nbsp; &nbsp;if( netRet == NERR_Success )<br> &nbsp; &nbsp; &nbsp;{ <br> &nbsp; &nbsp; &nbsp; &nbsp; // We found a user entry on this BDC. Compare the<br> &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;last logon time to the stored time. Replace the stored <br> &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;time if the time is greater.<br> &nbsp; &nbsp; &nbsp; &nbsp; //<br> &nbsp; &nbsp; &nbsp; &nbsp; // Replace the servername so the time and the server match.<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; if( Users[0].usri11_last_logon &gt; validate.logon_time)<br> &nbsp; &nbsp; &nbsp; &nbsp; {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;validate.server = (char far *)&amp;Servers;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;validate.logon_time = Users[0].usri11_last_logon;<br> &nbsp; &nbsp; &nbsp; &nbsp; } <br> &nbsp; &nbsp; &nbsp; &nbsp; else if( Users[0].usri11_last_logon == validate.logon_time )<br> &nbsp; &nbsp; &nbsp; &nbsp; { <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// This could indicate a problem.<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sprintf(Message,&quot;Values are the same. %ls %ls&quot;, Servers.sv0_name, validate.server);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox( NULL, Message, &quot;HMMMM...........&quot;,MB_OK);<br> &nbsp; &nbsp; &nbsp; &nbsp; }<br> &nbsp; &nbsp; &nbsp;}<br> &nbsp; } <br><br> &nbsp; // Convert the time in seconds to a time structure for display; <br> &nbsp; // &nbsp;build the output string.<br><br> &nbsp; &nbsp;lpTime = gmtime( &amp;validate.logon_time);<br> &nbsp; &nbsp;lpszTime = asctime( lpTime );<br> &nbsp; &nbsp;_fstrcpy((LPSTR)Message, (LPSTR)&quot;Username: &quot;);<br> &nbsp; &nbsp;_fstrcat((LPSTR)Message, (LPSTR)Wksta[0].wki10_username);<br> &nbsp; &nbsp;_fstrcat((LPSTR)Message, (LPSTR)&quot;/nLast Logon: &quot;);<br> &nbsp; &nbsp;_fstrcat((LPSTR)Message, (LPSTR)lpszTime);<br> &nbsp; &nbsp;_fstrcat((LPSTR)Message, (LPSTR)&quot;Logon Server: &quot;);<br> &nbsp; &nbsp;_fstrcat((LPSTR)Message, (LPSTR)validate.server);<br><br> &nbsp; &nbsp;// Display the information.<br><br> &nbsp; &nbsp;MessageBox(NULL,Message,&quot;Logon Validation Information&quot;, MB_OK);<br> &nbsp; &nbsp;return(0);<br>}
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3188621<br><br>可能有点参考价值
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部