通过VBscript/ADO访问LDAP服务器
当绑定到LDAP服务器时,ADO可以访问ADsPath和名称以外的属性吗 下面是我用来绑定和查询internet上LDAP服务器的代码:通过VBscript/ADO访问LDAP服务器,vbscript,ldap,ado,Vbscript,Ldap,Ado,当绑定到LDAP服务器时,ADO可以访问ADsPath和名称以外的属性吗 下面是我用来绑定和查询internet上LDAP服务器的代码: Set ado = CreateObject("ADODB.Connection") ado.Provider = "ADSDSOObject" ado.Properties("User ID") = "" ado.Properties("Password
Set ado = CreateObject("ADODB.Connection")
ado.Provider = "ADSDSOObject"
ado.Properties("User ID") = ""
ado.Properties("Password") = ""
ado.Properties("Encrypt Password") = False
ado.Open "NameSearch"
serverName = "xxxxxx.xxxx.xxx"
filterStr = "(objectClass=*)"
Set Ol= ado.Execute("<LDAP://" & serverName & ">;" & filterStr & ";ADsPath;SubTree")
While Not Ol
WScript.Echo Ol.Fields(0).value
Ol.MoveNext
Wend
Set ado=CreateObject(“ADODB.Connection”)
ado.Provider=“ADSDSOObject”
ado.Properties(“用户ID”)=“”
ado.Properties(“密码”)=“”
ado.Properties(“加密密码”)=False
ado.打开“名称搜索”
serverName=“xxxxxx.xxxx.xxx”
filterStr=“(objectClass=*)”
Set Ol=ado.Execute(“;”&filterStr&“ADsPath;子树”)
而不是Ol
WScript.Echo Ol.Fields(0).value
下一个
温德
另外,如何将上述代码中的搜索库分配给“o=xxxxxx大学;c=US”?请参阅
连接对象执行方法的
CommandText(第一个对象)是LDAP
由四个元素组成的查询
以分号分隔,在
以下格式:
<LDAP://server/adsidn>;ldapfilter;attributescsv;scope
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = New ADODB.Connection
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
Set rs = conn.Execute( _
"<LDAP://server/o=organization/o=xxxxxx University/c=US>;" _
& "(objectClass=*);ADsPath,objectClass,cn;subtree")
While Not rs.EOF
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, _
rs.Fields(2).Value
rs.MoveNext
Wend
conn.Close