我遇到以下VBS的问题
set conn = createobject("ADODB.Connection")
Conn.Provider = "ADsDSOObject"
Conn.Open "ADs Provider"
strQueryDL = "<LDAP://company.address.com/cn=address>;(&(objectCategory=person)(objectClass=user));distinguishedName,adspath;subtree"
set objCmd = createobject("ADODB.Command")
objCmd.ActiveConnection = Conn
objCmd.Properties("SearchScope") = 2 ' we want to search everything
objCmd.Properties("Page Size") = 500 ' and we want our records in lots of 500
objCmd.CommandText = strQueryDL
Set objRs = objCmd.Execute
While Not objRS.eof
wscript.echo objRS.Fields("distinguishedName")
' do something with objRS.Fields("distinguishedName")'
objRS.MoveNext
Wend
请帮助我,我刚刚开始使用vbscripting,这来自本网站的答案。
wscript.echo objRS.Fields("distinguishedName")
错误来自上面的行/代码。如何显示字段或将其转换为显示?
答案 0 :(得分:0)
LDAP://company.address.com/cn=address
不是有效的LDAP网址(请参阅here)。搜索库必须是可分辨名称,例如:
LDAP://company.address.com/cn=address,dc=address,dc=com
域名(dc=address,dc=com
)的可分辨名称可以这样获得:
Set rootDSE = GetObject("LDAP://RootDSE")
WScript.Echo rootDSE.Get("defaultNamingContext")