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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple LDAP Query - Passing CN Which Contains a Comma 1

Status
Not open for further replies.

Armstrong

IS-IT--Management
May 15, 2001
34
0
0
US
Hi all,

I am trying a simple LDAP Query to get "Last Password Change" from 2000 Active Directory and I am having a problem passing the CN since it is using the display name which contains a comma. Here is my code:

Code:
'strNamValue = "PLAINUSER"
strNamValue = "LastName, FirstName" 
'NT AccountName = LastName_FirstName (doesn't work either)

Set objUser = GetObject ("LDAP://cn=" & strNamValue & ",ou=Users - ABC IBS,ou=Santa Ana,dc=corp,dc=RBB-inc,dc=com")
dtmValue = objUser.PasswordLastChanged
Wscript.echo "Password Last Changed: " & dtmvalue

This works for plainuser (which is also in the same location as all of the users I need to get to under the ABC IBS Group).

I am either getting "Invalid dn syntax" due to the comma, or I am getting "Object not on server" I don't know where to go with this.

Thanks in advance,
Armstrong


Greg Armstrong
A+ MCSE+I :)
 
Hello Armstrong,

Try this.
[tt] strNamValue = "LastName[red]\[/red], FirstName"
[/tt]
regards - tsuji
 
Thanks a million tsuji! I did not know that the backslash was an escape character in LDAP!! That worked flawlessly. Where did you find that infomration, or how did you learn that?

Thanks again, I really appreciate your expertise and assistance.

Best Regards,

Armstrong
 
Armstrong,

Thanks for the postback. If you have that strNamValue at its unescaped form as variable, thus not explicit, you can always use classic vbs function replace to do the blindly filtering.
strNamValue=replace(strNamValue,",","\,")

If you get the proper pathname, you can retrieve the escaped rdn. Though by reflection, it seem less useful? But, this is precisely the GetUnescapedElement method does!
and it is one place where you get a focused reference on the escape character.

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top