0

我在使用以下 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")

错误来自上面的行/代码。如何显示字段或将其转换为显示?

4

1 回答 1

0

LDAP://company.address.com/cn=address不是有效的 LDAP URL(请参阅此处)。搜索库必须是专有名称,例如:

LDAP://company.address.com/cn=address,dc=address,dc=com

域的可分辨名称 ( dc=address,dc=com) 可以这样获得:

Set rootDSE = GetObject("LDAP://RootDSE")
WScript.Echo rootDSE.Get("defaultNamingContext")
于 2013-05-21T12:00:19.657 回答