I am having a very strange result of some scripts. The issue is that it returns NO values even though I know it should. Here is some info:
Environment: W2k3, Exch2k3 – Multiple Domains with Empty Forest Root
Desktop: Vista and XP
I am using ADO with the LDAP query to AD that I have used thousands of times. There are no errors. I can take out the LDAP filter and use it in ADUC with no problems. I have removed everything and it still does not work.
I am logged into “Domain A”. I use the RootDSE to get the defaultnamingcontext, so it dynamically would get his domain. There were no results, so I backed up and tried to get a record count from the ADO and it was coming back 0. So I hard-coded the DC and DN of the root search and it still was 0. I then hard-coded the root to a specific OU and it showed a large record count, but none of the values were echoed out. So it is finding results finally, but it refuses to echo them out. Have any of you had this happen?
Here is an example of the parts I mentioned:
Filter: LDAP://OU=UserStuff,DC=sub,DC=domain,DC=com
For example, this very generic script returns NO results:
Any ideas? I was puzzled why no records were found and then even when they are found, it refuses to echo out the varaibles or anything else in the loop.
Environment: W2k3, Exch2k3 – Multiple Domains with Empty Forest Root
Desktop: Vista and XP
I am using ADO with the LDAP query to AD that I have used thousands of times. There are no errors. I can take out the LDAP filter and use it in ADUC with no problems. I have removed everything and it still does not work.
I am logged into “Domain A”. I use the RootDSE to get the defaultnamingcontext, so it dynamically would get his domain. There were no results, so I backed up and tried to get a record count from the ADO and it was coming back 0. So I hard-coded the DC and DN of the root search and it still was 0. I then hard-coded the root to a specific OU and it showed a large record count, but none of the values were echoed out. So it is finding results finally, but it refuses to echo them out. Have any of you had this happen?
Here is an example of the parts I mentioned:
Filter: LDAP://OU=UserStuff,DC=sub,DC=domain,DC=com
For example, this very generic script returns NO results:
Code:
Option Explicit
Dim objRootDSE, strDNSDomain, objCommand, objConnection, strQuery, strBase, strFilter, strAttributes
Dim objRecordSet, strAlias, strName, strSAM
Dim blnFlag
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use ADO to search Active Directory.
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
' Search for all user objects. Return Values.
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user))"
strAttributes = "displayName,mailNickname,sAMAccountName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Sort On") = "displayName"
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strName = objRecordSet.Fields("displayName")
strAlias = objRecordSet.Fields("mailNickname")
strSAM = objRecordSet.Fields("sAMAccountName")
Wscript.Echo strSAM & " ; " & strAlias & " ; " & strName
objRecordSet.MoveNext
Loop
objConnection.Close
Any ideas? I was puzzled why no records were found and then even when they are found, it refuses to echo out the varaibles or anything else in the loop.