标题: [转贴] VBS使用LDAP验证域用户账号 [打印本页]
作者: yu2n 时间: 2013-8-1 21:44 标题: VBS使用LDAP验证域用户账号
VBS使用LDAP验证域用户账号
功能:验证域用户账号
环境:WinXP域内主机、WinXP域外主机、Win2003
作者:yu2n
引用: http://www.oocities.org/calinradoni/vbLDAPAuth.html- If WScript.Arguments.Count = 3 Then
- Msgbox LDAP_Authenticate(WScript.Arguments.item(0), WScript.Arguments.item(1), WScript.Arguments.item(2))
- Else
- sTip = "验证域用户账号:" & vbCrLf
- sTip = sTip & " LDAP_Authenticate.VBS <LDAPServer> <User> <Password>" & vbCrLf & vbCrLf
- sTip = sTip & " LDAPServer:域DC服务器如 dc1.demo.com" & vbCrLf
- sTip = sTip & " User:域用户名" & vbCrLf
- sTip = sTip & " Password:域用户密码" & vbCrLf
- Msgbox sTip
- End If
-
- ' LDAP Authentication to Active Directory in VBScript
- ' http://www.oocities.org/calinradoni/vbLDAPAuth.html
- ' LDAP_Authenticate texdgdc01.texwinca.com texwinca\af071 Ct123456
- Function LDAP_Authenticate(ByVal sLDAPServer, ByVal sADUserName, ByVal sADPassword)
- Const ADS_SECURE_AUTHENTICATION = &h0001
- Const ADS_SERVER_BIND = &h0200
- Dim sRoot, dso, xResult
- sRoot = "LDAP://" & sLDAPServer
- Set dso = GetObject("LDAP:")
- On Error Resume Next
- Set xResult = dso.OpenDSObject(sRoot, sADUserName, sADPassword, ADS_SECURE_AUTHENTICATION Or ADS_SERVER_BIND)
- If Err.number = 0 Then
- LDAP_Authenticate = True
- Else
- LDAP_Authenticate = False
- End If
- End Function
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |