Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't pass a "/" through in AD query

Status
Not open for further replies.

wlfpackr

IS-IT--Management
May 3, 2003
161
0
0
US
I'm attempting to gather a large quantity of data from the group objects in our AD using vbScript. So far the script keeps failing on the same group object. In someone's infinite wisdom they've put a "/" character in a group's name which means the group's DN also has the "/". When I pass along the "/" to query AD the script errors out.

Hopefully the below code will show a little more insight.

Code:
strGroupDN = "CN=DVD/CD,DC=domain,DC=com"
'strGroupDN = "CN=USERS,DC=domain,DC=com"

Set objGroup = GetObject("LDAP://" & strGroupDN)
	
'RETRIEVE GROUP ATTRIBUTES
strGroupName = objGroup.Name	        'Group Name.
strGroupManager = objGroup.managedBy	'Group Manager.

Wscript.echo "Name: " & strGroupName & vbcrlf & "Manager: " & strGroupManager

Now if I use:

Code:
strGroupDN = "CN=DVD/CD,DC=domain,DC=com"

The script errors out on this line:

Code:
Set objGroup = GetObject("LDAP://" & strGroupDN)

If I use the DN:

Code:
strGroupDN = "CN=USERS,DC=domain,DC=com"

I don't get any issues.

I'm 99.99% sure it is b/c of the "/" character. The script runs through 3,100+ groups without an error until it sees this one with the "/" character.

Anyone have any suggestions or workarounds other than just skipping it?



=================
There are 10 kinds of people in this world, those that understand binary and those that do not.
 
Hmm. Well, that wasn't very smart on the part of whoever set up the groups.

What about using the character code? chr(47)

Or, perhaps the GetObject request is misinterpreting the LDAP string. What about ecapsluating the container name in quotes so the / isn't misinterpreted. Otherwise, I'm no sure.
Code:
strGroupDN = "CN=[red]""[/red]DVD/CD[red]""[/red],DC=domain,DC=com
-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top