当 ADSIEdit 返回正确的行数时,VBScript 返回 0 行
在过去的两天左右的时间里,我一直在努力反对这个问题,但无论我做什么,都没有取得多大成功。 当我运行查询来检索以特定结尾结尾的共享卷时,它可以在 ADSIEdit 中正常工作,但不能在我的 VBScript 中正常工作。真的很奇怪,因为我使用完全相同的查询。
ADSIEdit 查询的配置如下:
- 名称:测试
- 搜索根:DC=ad,DC=server,DC=com
- 查询字符串:(&(objectCategory=volume)(objectClass=volume)(cn=K_*))
- < p>查询范围:子树搜索。
- 搜索结果:11条cn以K_开头的记录
- VbScript 结果:1 条记录 (!?!?)
如果我将查询字符串更改为(最后一部分)(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
希望有人可以提供帮助。我已经 阅读了无数主题,但每一个都失败了:(
编辑:我已经我认为我已经将其归结为信任/权限问题。当我在 AD 计算机上运行 adfind (或 dsquery)时,它会返回正确的行数,但是,如果我在客户端计算机上运行它,它会返回错误的行数。 如何解决它?
现在的
D:\Tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5
cOst-gro))"
AdFind V01.45.00cpp Joe Richards ([email protected]) 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 ([email protected]) 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 ([email protected]) March 2011
Using server: ad.server.com:389
Directory: Windows Server 2003
Base DN: DC= DC=ad,DC=server,DC=com
1 Objects returned
I've been banging my head against this for the last two days or so, and without much success - regardless what I try.
When I run a query to retrieve share volumes which ends with a specific ending, I get it to work properly in ADSIEdit - but not in my VBScript. Really odd, as I'm using exactly the same query.
The ADSIEdit query is configured like so:
- Name: Test
- Root of Search: DC=ad,DC=server,DC=com
- Query String: (&(objectCategory=volume)(objectClass=volume)(cn=K_*))
Query Scope: Subtree search.
- Search results: 11 records where the cn starts with K_
- VbScript results: 1 record (!?!?)
If I change the query string to (last part) (uNCName=*\5cOst-gro)) instead, which is what I really want (the first query string I gave was for testing purposes), in ADSIEdit I get 7 rows returned - in my VBScript none!
Here's my (current) VBScript code:
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
Hoping someone can help. I've read countless topics on it but failed with each and every one :(
EDIT: I've think I've nailed it down to a trust/permission issue. When I run adfind (or dsquery) on the AD machine, it returns the correct number of rows. However, if I run it on the client machine, it returns the wrong amount of rows. The question now is, how do I do to solve it?
SERVER:
D:\Tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5
cOst-gro))"
AdFind V01.45.00cpp Joe Richards ([email protected]) 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>
CLIENT:
C:\tests>adfind -c -f "(&(objectCategory=volume)(objectClass=volume)(uNCName=*\5
cOst-gro))"
AdFind V01.45.00cpp Joe Richards ([email protected]) 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 ([email protected]) March 2011
Using server: ad.server.com:389
Directory: Windows Server 2003
Base DN: DC= DC=ad,DC=server,DC=com
1 Objects returned
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@exodus:你的转义标志是错误。如果你想搜索反斜杠,你必须使用“\5C”(大写)。
hier 是更多详细信息的链接:http://www.rlmueller.net/CharactersEscaped.htm
@exodus: your escaping sign is the error. you have to use "\5C" (upper case) if you want to search for a backslash.
hier is a link for more details: http://www.rlmueller.net/CharactersEscaped.htm