About Terminal Server, Citrix, Delphi and other stuff
19 Oct
Ever tried to run a VBS scripts that queries Active Directory in another domain or from a workstation that is not a domain member? Than you have probably seen this error before:
![]()
![]()

This is because the default settings for Chasing referrals is set to ADS_CHASE_REFERRALS_NEVER.
Add the line below to your script to make it work.
So in a script it would look like this:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.Properties("Chase referrals") = ADS_CHASE_REFERRALS_ALWAYS
objCommand.CommandText = _
"Select distinguishedName from " & _
"’LDAP://cn=Configuration,DC=MyDomain,DC=Local’ " _
& "where objectClass=’nTDSDSA’"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & _
objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
6 Responses for "A referral was returned from the server"
Great hint!
I’ve searched a while to find a solution for this problem!
Dude, you rock! I have been struggling with this one for days and your solution nailed the problem!! Thanks.
Thanks for this hint
I was looking for a solution for this problem long !!
This was an excellent post. Thanks so much for the help.
I’ve been searching and searching for over 6 hours and you solved my problem!!! THANK YOU!
I’ve been really stuck with this problem. You really have dug me out of a very BIG hole. Many thanks for this post. Thank you
Leave a reply