在过去的两天左右,我一直在反对这一点,并且没有太大的成功 - 无论我尝试什么。 当我运行查询以检索以特定结尾结束的共享卷时,我让它在ADSIEdit中正常工作 - 但不在我的VBScript中。真的很奇怪,因为我使用完全相同的查询。
ADSIEdit查询的配置如下:
查询范围:子树搜索。
如果我将查询字符串更改为(最后一部分)(uNCName = * \ 5cOst-gro)),这是我真正想要的(我给出的第一个查询字符串是用于测试目的),在ADSIEdit中我得到7行返回 - 在我的VBScript中没有!
这是我的(当前)VBScript代码:
Set objDomain = getObject("LDAP://RootDSE")
Set objSysInfo = CreateObject("ADSystemInfo")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
strDNSDomain = objDomain.Get("defaultNamingContext")
objCommand.CommandText = "Select Name, uNCName, ManagedBy from "_
& "'LDAP://DC=ad,DC=server,DC=com'" _
& " where objectClass='volume' and uNCName = '*\5cOst-gro'"
'The below is not working either!
'objCommand.CommandText = "<LDAP://DC=ad,DC=server,DC=com>;"_
' & "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5cOst-gro));"_
' & "name,uNCName;subtree"
Set objRecordSet = objCommand.Execute( , , adCmdTableDirect)
avarGetRowsArray = objRecordset.GetRows(intNumRows, BkMrk) ' returns 0 too
objRecordSet.MoveFirst ' Doesn't help
If objRecordSet.Supports(adApproxPosition)=True Then
nrRecords=objRecordSet.RecordCount
End If
if not objRecordSet.EOF Then
do While Not objRecordSet.EOF
MsgBox "Match found! " & objRecordSet.Fields("name").Value, vbOKOnly, "Match found"
objRecordSet.MoveNext
Loop
Else
MsgBox "No matches found. " & UBound(avarGetRowsArray), vbOKOnly, "No matches!"
end If
希望有人可以提供帮助。我read countless topics就可以了,但每个人都失败了:(
编辑:我认为我已将其钉在信任/许可问题上。当我在AD机器上运行adfind(或dsquery)时,它返回正确的行数。但是,如果我在客户端计算机上运行它,它将返回错误的行数。现在的问题是,我如何来解决它?SERVER:
D:\Tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5
cOst-gro))"
AdFind V01.45.00cpp Joe Richards (joe@joeware.net) March 2011
Using server: ad.server.com:389
Directory: Windows Server 2003
Base DN: DC=ad,DC=server,DC=com
7 Objects returned
D:\Tests>
客户端:
C:\tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5
cOst-gro))"
AdFind V01.45.00cpp Joe Richards (joe@joeware.net) March 2011
Using server: ad.server.com:389
Directory: Windows Server 2003
Base DN: DC= DC=ad,DC=server,DC=com
0 Objects returned
C:\tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(cn=K_*))"
AdFind V01.45.00cpp Joe Richards (joe@joeware.net) March 2011
Using server: ad.server.com:389
Directory: Windows Server 2003
Base DN: DC= DC=ad,DC=server,DC=com
1 Objects returned
答案 0 :(得分:0)
@exodus:你的逃避标志是错误。如果要搜索反斜杠,则必须使用“\ 5C”(大写)。 hier是更多详细信息的链接:http://www.rlmueller.net/CharactersEscaped.htm