Troubleshooting Code 8007202B - A referral was returned from the server
Introduction to error Error Code 8007202B
This error code, 8007202B occurs when you execute a VBScript.
My suggestion is that there is a typo in the domain name reference in your script.
Error messages beginning 8007xxxx mean there is an external problem with Windows rather
than syntax in the VBScript itself.
The Symptoms You Get 8007202B
The script does not execute as you
hoped, instead you get a WSH error message.
One possibility is that you are using a WSH object and the LDAP
reference: dc = value which has
been misspelled.
The Cause of Code 8007202B
Your VBScript contains an illegal dc= domain reference, probably a typing
mistake, an extra letter. Check the spelling of your LDAP objects.
In the example the Line: 6 is where the error is to be found.
Ideas for Solutions
A wild guess is that you copied the script, but did not change the domain references which are hard-coded in the script.
Check the spelling of your LDAP objects. Look for clues particularly
the Line: number. In this case it Char: 1 is not to blame. When
none of the line can execute, the error gets charged to the first character.
In the case of runtime errors if you are desperate then use this work around. Add this
line: On Error Resume Next
‡
Example 1 - Add the name of your domain control server.
Bryan Fuehrer writes in with a great idea; add the name of your domain controller to the script. Instead of a
command such as:
Set objCOmmand.ActiveConnection = objConnection objCommand.CommandText = _ "Select Name from 'LDAP://DC=CEC,DC=root,DC=xyz,DC=com' " _ & "Where
objectClass='group'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute
Try this, add the name of the domain contoller, and solve Code 8007202B errors
Set objCOmmand.ActiveConnection = objConnection objCommand.CommandText = _ "Select Name from 'LDAP://bigserver/DC=CEC,DC=root,DC=xyzd,DC=com' " _
& "Where objectClass='group'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute
Note that in Bryan's example the source is Provider, whereas in my original example
the source was (null). My point is always check your error message carefully. In this instance there is a different solution depending on what Source: says. Incidentally, the first 11
lines of Bryan's script are not shown that is why the error message reports line 14 (not line 3).
Example 2: Typo in the DC=
Error dc= c0p (Where did that zero come from?)
It should be dc= cp
'Script to Create a new Contact account in the
BulkImport OU
'Script created by Guy Thomas
'Feel free to adapt names
Set objOU = GetObject("LDAP://OU=BulkImport, dc=c0p, dc=com")
Set objUser = objOU.Create("contact", "cn=SaleMen")
objUser.SetInfo
Wscript.Echo "Success new Contact - Remember F5"
Corrected Version
'Script to Create a new Contact account in the
BulkImport OU
'Script created by Guy Thomas
'Feel free to adapt names
Set objOU = GetObject("LDAP://OU=BulkImport, dc=cp, dc=com")
Set objUser = objOU.Create("contact", "cn=SaleMen")
objUser.SetInfo
Wscript.Echo "Success new Contact - Remember F5"
Check all the domain references in your script. If necessary check ADUC or the System Properties, Computer name tab for the correct domain name.
Try
a different solution, download SolarWinds ipMonitor
Here is my thinking,
ipMonitor will give you valuable data about your network and servers.
This extra information just may unlock the solution to your error code.
One more thing, sometimes when troubleshooting you go around in circles;
therefore if you try a different, but related approach, you may just crack the
problem.
Free Download
of SolarWinds ipMonitor (21 day eval).
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
The extra features you get in your eBook
include, more pages full of detailed examples. Also, ten 'how to...'
sections, with screen shots showing which menus to use. Go for Guy's
eBook - and get a printable version with copy enabled and no expiry date.