Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Why isn't this LDAP query working on the other domain in the fores

Reply
 
Old 12-16-2008   #1 (permalink)
Larry


 
 

Why isn't this LDAP query working on the other domain in the fores

I'm executing a query against two different domains in the same forest (US
and MX). The query for the domain I'm in (US) works fine. The other domain
(MX) query returns 0 records. I do have security access to the other domain
and I've changed the search parameters to the other domain.

'*********CODE FOR MY DOMAIN (US) *********
Dim objConnection, objCommand
Set objConnection = CreateObject ("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject ("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties ("Asynchronous") = True
objCommand.Properties ("Cache Results") = True
objCommand.Properties ("Page Size") = 10
objCommand.Properties ("Size Limit") = 100

Dim objRecordSet

objCommand.CommandText = "<LDAP://dc=us, dc=fabrikam,
dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
Server*));name;subtree"

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
WScript.Echo objRecordSet.Fields ("name") & vbCr
objRecordSet.MoveNext
Wend

objConnection.Close

'*********CODE FOR DOMAIN THAT DOESN'T WORK (MX)*********
Set objConnection = CreateObject ("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject ("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties ("Asynchronous") = True
objCommand.Properties ("Cache Results") = True
objCommand.Properties ("Page Size") = 10
objCommand.Properties ("Size Limit") = 100

objCommand.CommandText = "<LDAP://dc=mx, dc=fabrikam,
dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
Server*));name;subtree"

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
WScript.Echo objRecordSet.Fields ("name") & vbCr
objRecordSet.MoveNext
Wend

objConnection.Close

'*********END CODE *********

Is this a binding issue to the MX domain?

My System SpecsSystem Spec
Old 12-17-2008   #2 (permalink)
HAL07


 
 

Re: Why isn't this LDAP query working on the other domain in thefores

Try to authenticate using username and password to ensure that the other domain know where to look for credentials.

Larry wrote:
Quote:

> I'm executing a query against two different domains in the same forest (US
> and MX). The query for the domain I'm in (US) works fine. The other domain
> (MX) query returns 0 records. I do have security access to the other domain
> and I've changed the search parameters to the other domain.
>
> '*********CODE FOR MY DOMAIN (US) *********
> Dim objConnection, objCommand
> Set objConnection = CreateObject ("ADODB.Connection")
> objConnection.Open "Provider=ADsDSOObject;"
>
> Set objCommand = CreateObject ("ADODB.Command")
> objCommand.ActiveConnection = objConnection
> objCommand.Properties ("Asynchronous") = True
> objCommand.Properties ("Cache Results") = True
> objCommand.Properties ("Page Size") = 10
> objCommand.Properties ("Size Limit") = 100
>
> Dim objRecordSet
>
> objCommand.CommandText = "<LDAP://dc=us, dc=fabrikam,
> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> Server*));name;subtree"
>
> Set objRecordSet = objCommand.Execute
>
> While Not objRecordSet.EOF
> WScript.Echo objRecordSet.Fields ("name") & vbCr
> objRecordSet.MoveNext
> Wend
>
> objConnection.Close
>
> '*********CODE FOR DOMAIN THAT DOESN'T WORK (MX)*********
> Set objConnection = CreateObject ("ADODB.Connection")
> objConnection.Open "Provider=ADsDSOObject;"
>
> Set objCommand = CreateObject ("ADODB.Command")
> objCommand.ActiveConnection = objConnection
> objCommand.Properties ("Asynchronous") = True
> objCommand.Properties ("Cache Results") = True
> objCommand.Properties ("Page Size") = 10
> objCommand.Properties ("Size Limit") = 100
>
> objCommand.CommandText = "<LDAP://dc=mx, dc=fabrikam,
> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> Server*));name;subtree"
>
> Set objRecordSet = objCommand.Execute
>
> While Not objRecordSet.EOF
> WScript.Echo objRecordSet.Fields ("name") & vbCr
> objRecordSet.MoveNext
> Wend
>
> objConnection.Close
>
> '*********END CODE *********
>
> Is this a binding issue to the MX domain?

--
-- HAL07, Engineering Services, Norway
My System SpecsSystem Spec
Old 12-17-2008   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Why isn't this LDAP query working on the other domain in the fores

Some info on alternate credentials that might help:

http://www.rlmueller.net/ADOAltCredentials.htm

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"HAL07" <yahoohal@xxxxxx> wrote in message
news:ulle%23VEYJHA.5156@xxxxxx
Quote:

> Try to authenticate using username and password to ensure that the other
> domain know where to look for credentials.
>
> Larry wrote:
Quote:

>> I'm executing a query against two different domains in the same forest
>> (US and MX). The query for the domain I'm in (US) works fine. The other
>> domain (MX) query returns 0 records. I do have security access to the
>> other domain and I've changed the search parameters to the other domain.
>>
>> '*********CODE FOR MY DOMAIN (US) *********
>> Dim objConnection, objCommand
>> Set objConnection = CreateObject ("ADODB.Connection")
>> objConnection.Open "Provider=ADsDSOObject;"
>>
>> Set objCommand = CreateObject ("ADODB.Command")
>> objCommand.ActiveConnection = objConnection
>> objCommand.Properties ("Asynchronous") = True
>> objCommand.Properties ("Cache Results") = True
>> objCommand.Properties ("Page Size") = 10
>> objCommand.Properties ("Size Limit") = 100
>>
>> Dim objRecordSet
>>
>> objCommand.CommandText = "<LDAP://dc=us, dc=fabrikam,
>> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
>> Server*));name;subtree"
>>
>> Set objRecordSet = objCommand.Execute
>>
>> While Not objRecordSet.EOF
>> WScript.Echo objRecordSet.Fields ("name") & vbCr
>> objRecordSet.MoveNext
>> Wend
>>
>> objConnection.Close
>>
>> '*********CODE FOR DOMAIN THAT DOESN'T WORK (MX)*********
>> Set objConnection = CreateObject ("ADODB.Connection")
>> objConnection.Open "Provider=ADsDSOObject;"
>>
>> Set objCommand = CreateObject ("ADODB.Command")
>> objCommand.ActiveConnection = objConnection
>> objCommand.Properties ("Asynchronous") = True
>> objCommand.Properties ("Cache Results") = True
>> objCommand.Properties ("Page Size") = 10
>> objCommand.Properties ("Size Limit") = 100
>>
>> objCommand.CommandText = "<LDAP://dc=mx, dc=fabrikam,
>> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
>> Server*));name;subtree"
>>
>> Set objRecordSet = objCommand.Execute
>>
>> While Not objRecordSet.EOF
>> WScript.Echo objRecordSet.Fields ("name") & vbCr
>> objRecordSet.MoveNext
>> Wend
>>
>> objConnection.Close
>>
>> '*********END CODE *********
>>
>> Is this a binding issue to the MX domain?
>
>
> --
> -- HAL07, Engineering Services, Norway

My System SpecsSystem Spec
Old 12-17-2008   #4 (permalink)
Larry


 
 

Re: Why isn't this LDAP query working on the other domain in the f

Thanks for the help HAL07 and Richard. I'll try that and see what happens. I
suspect it will work as "advertised".

It's interesting that credentials have to be explicitly defined to the other
domain. The trust relationship is there so this isn't exactly what I thought
would be the issue. I don't have to explicitly define them when using the AD
Users and Computers MMC for that domain. I'll have to track down more
information on the authentication token and process to better understand this.

"Richard Mueller [MVP]" wrote:
Quote:

> Some info on alternate credentials that might help:
>
> http://www.rlmueller.net/ADOAltCredentials.htm
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "HAL07" <yahoohal@xxxxxx> wrote in message
> news:ulle%23VEYJHA.5156@xxxxxx
Quote:

> > Try to authenticate using username and password to ensure that the other
> > domain know where to look for credentials.
> >
> > Larry wrote:
Quote:

> >> I'm executing a query against two different domains in the same forest
> >> (US and MX). The query for the domain I'm in (US) works fine. The other
> >> domain (MX) query returns 0 records. I do have security access to the
> >> other domain and I've changed the search parameters to the other domain.
> >>
> >> '*********CODE FOR MY DOMAIN (US) *********
> >> Dim objConnection, objCommand
> >> Set objConnection = CreateObject ("ADODB.Connection")
> >> objConnection.Open "Provider=ADsDSOObject;"
> >>
> >> Set objCommand = CreateObject ("ADODB.Command")
> >> objCommand.ActiveConnection = objConnection
> >> objCommand.Properties ("Asynchronous") = True
> >> objCommand.Properties ("Cache Results") = True
> >> objCommand.Properties ("Page Size") = 10
> >> objCommand.Properties ("Size Limit") = 100
> >>
> >> Dim objRecordSet
> >>
> >> objCommand.CommandText = "<LDAP://dc=us, dc=fabrikam,
> >> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> >> Server*));name;subtree"
> >>
> >> Set objRecordSet = objCommand.Execute
> >>
> >> While Not objRecordSet.EOF
> >> WScript.Echo objRecordSet.Fields ("name") & vbCr
> >> objRecordSet.MoveNext
> >> Wend
> >>
> >> objConnection.Close
> >>
> >> '*********CODE FOR DOMAIN THAT DOESN'T WORK (MX)*********
> >> Set objConnection = CreateObject ("ADODB.Connection")
> >> objConnection.Open "Provider=ADsDSOObject;"
> >>
> >> Set objCommand = CreateObject ("ADODB.Command")
> >> objCommand.ActiveConnection = objConnection
> >> objCommand.Properties ("Asynchronous") = True
> >> objCommand.Properties ("Cache Results") = True
> >> objCommand.Properties ("Page Size") = 10
> >> objCommand.Properties ("Size Limit") = 100
> >>
> >> objCommand.CommandText = "<LDAP://dc=mx, dc=fabrikam,
> >> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> >> Server*));name;subtree"
> >>
> >> Set objRecordSet = objCommand.Execute
> >>
> >> While Not objRecordSet.EOF
> >> WScript.Echo objRecordSet.Fields ("name") & vbCr
> >> objRecordSet.MoveNext
> >> Wend
> >>
> >> objConnection.Close
> >>
> >> '*********END CODE *********
> >>
> >> Is this a binding issue to the MX domain?
> >
> >
> > --
> > -- HAL07, Engineering Services, Norway
>
>
>
My System SpecsSystem Spec
Old 12-17-2008   #5 (permalink)
Larry


 
 

Re: Why isn't this LDAP query working on the other domain in the f

I used your code for that and it resolved my problem. I also learned some new
properties. I need to find that info on MSDN so I have all of the properties.

Thanks for posting those spreadsheets too. That's a lot more convenient than
working off the MSDN site and following links all over the place.

"Richard Mueller [MVP]" wrote:
Quote:

> Some info on alternate credentials that might help:
>
> http://www.rlmueller.net/ADOAltCredentials.htm
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "HAL07" <yahoohal@xxxxxx> wrote in message
> news:ulle%23VEYJHA.5156@xxxxxx
Quote:

> > Try to authenticate using username and password to ensure that the other
> > domain know where to look for credentials.
> >
> > Larry wrote:
Quote:

> >> I'm executing a query against two different domains in the same forest
> >> (US and MX). The query for the domain I'm in (US) works fine. The other
> >> domain (MX) query returns 0 records. I do have security access to the
> >> other domain and I've changed the search parameters to the other domain.
> >>
> >> '*********CODE FOR MY DOMAIN (US) *********
> >> Dim objConnection, objCommand
> >> Set objConnection = CreateObject ("ADODB.Connection")
> >> objConnection.Open "Provider=ADsDSOObject;"
> >>
> >> Set objCommand = CreateObject ("ADODB.Command")
> >> objCommand.ActiveConnection = objConnection
> >> objCommand.Properties ("Asynchronous") = True
> >> objCommand.Properties ("Cache Results") = True
> >> objCommand.Properties ("Page Size") = 10
> >> objCommand.Properties ("Size Limit") = 100
> >>
> >> Dim objRecordSet
> >>
> >> objCommand.CommandText = "<LDAP://dc=us, dc=fabrikam,
> >> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> >> Server*));name;subtree"
> >>
> >> Set objRecordSet = objCommand.Execute
> >>
> >> While Not objRecordSet.EOF
> >> WScript.Echo objRecordSet.Fields ("name") & vbCr
> >> objRecordSet.MoveNext
> >> Wend
> >>
> >> objConnection.Close
> >>
> >> '*********CODE FOR DOMAIN THAT DOESN'T WORK (MX)*********
> >> Set objConnection = CreateObject ("ADODB.Connection")
> >> objConnection.Open "Provider=ADsDSOObject;"
> >>
> >> Set objCommand = CreateObject ("ADODB.Command")
> >> objCommand.ActiveConnection = objConnection
> >> objCommand.Properties ("Asynchronous") = True
> >> objCommand.Properties ("Cache Results") = True
> >> objCommand.Properties ("Page Size") = 10
> >> objCommand.Properties ("Size Limit") = 100
> >>
> >> objCommand.CommandText = "<LDAP://dc=mx, dc=fabrikam,
> >> dc=com>;(&(objectCategory=computer)(operatingSystem=Windows
> >> Server*));name;subtree"
> >>
> >> Set objRecordSet = objCommand.Execute
> >>
> >> While Not objRecordSet.EOF
> >> WScript.Echo objRecordSet.Fields ("name") & vbCr
> >> objRecordSet.MoveNext
> >> Wend
> >>
> >> objConnection.Close
> >>
> >> '*********END CODE *********
> >>
> >> Is this a binding issue to the MX domain?
> >
> >
> > --
> > -- HAL07, Engineering Services, Norway
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
working LDAP query, well almost.. 800A000D VB Script
Query LDAP to get user Telephone VB Script
How can I query LDAP in WLM? Live Mail
Not all users are retrieved in an LDAP query via ASP VB Script
help with LDAP query PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46