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

LDAP and Characters with Accents

Status
Not open for further replies.

SW2004

Technical User
Jul 13, 2004
24
GB
Hi all,

I’m using the following VBscript to find a user within Active Directory which works fine so long as the CN value doesn’t contain a character with an accent (French, German etc), in the example below I’ve used Léo Apotheker, unfortunately the letter é produces an ‘Object not found error’. Does anyone have any idea what is going on here? I suspect this is an LDAP AD problem but I'm not sure.

Many thanks
Steven

Set dso = GetObject("LDAP:")
Set objUser = dso_OpenDSObject( _
"LDAP://APHRODITE/CN=LéoApotheker,OU=Staff,DC=Domain,DC=Com", _
"Domain\User", _
"password", _
ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
objUser.AllowLogon = Disabled
objUser.SetInfo

 
Non-ascii character have to be utf-8 encoded like this for e-acute. Try this. (But, must admit this matter is confusing.)
"LDAP://APHRODITE/CN=LéoApotheker,OU=Staff,DC=Domain,DC=Com", _
[tt]"LDAP://APHRODITE/CN=L[blue]\E9[/blue]oApotheker,OU=Staff,DC=Domain,DC=Com", _[/tt]
 
Hi tsuji,

Thanks for that, as there are so many characters that aren't ascii is there a way to tell VBScript to process this line in UTF-8? Otherwise I would need to check for all characters with accents etc and replace them with the UTF-8 code, would I?

Many thanks.

Steven
 
A quick way to prepare the data is like this. (My invention, no guarantee of universality.)
[tt]
function sdata_utf8(sdata)
'[green]sdata: the original data[/green]
'[green]output: the transformed data ready for ldap query[/green]
dim rx, rxx, t
set rx=new regexp
with rx
.global=true
.pattern="%([0-9A-F]{2})"
end with
set rxx=new regexp
with rxx
.global=true
.pattern="%u([0-9A-F]{2})([0-9A-F]{2})"
end with
t=rx.replace(escape(sdata),"\$1")
t=rxx.replace(t,"\$1\$2")
sdata_utf8=t
end function
[/tt]
 
Hi tsuji,

Many thanks for the code, would you mind describing how it works?

Thanks for your time.

Steven
 
Such as this.
[tt]
s="Caña"
t=sdata_utf8(s)
wscript.echo t 'showing Ca\F1a
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top