[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-ldap-dev
Subject:    Re: Problem adding non-ascii characters to Active Directory
From:       Chris Ridd <chrisridd () mac ! com>
Date:       2004-01-09 7:57:58
Message-ID: BC240F86.C7E53%chrisridd () mac ! com
[Download RAW message or body]

On 8/1/04 9:29 pm, Ricardo Encarnação Carraretto <ricardo@ish.com.br> wrote:

> Hey folks,
> 
> I'm kinda new to Perl-LDAP and I'm having some problems to add attributes with
> non-ascii values into Active Directory.
> 
> For example, setting and user geographic location attribut to:
> 
> l => 'Vitória',
> 
> when I connect to the directory (using AD Users and Computers), this attribute
> for the example users shows "Vitria" (missing ó). I have already tried to
> encode as UTF-8 or ISO-8859-1, but it seems AD uses another encoding, so the
> code bellow doesn't work either:
> 
> $locality = encode("iso-8859-1", "Vitória");
> 
> or
> 
> $locality = encode("utf8", "Vitória");
> 
> Any tips on solving this?
> 
> Thanks
> Ricardo

As long as you bind to the server using LDAPv3 (i.e. version => 3), then you
should be able to pass UTF-8 encoded strings to the server.

Your last code snippet looks the safest. Assuming that encode() encodes the
second argument into UTF-8, the only question is how is it interpreting the
second argument. In other words, is it interpreting it as a Unicode string,
or a Latin-1 string, or ...?

How are you checking the value the server's returning? Make sure you're not
losing your "ó" because your check is wrong.

If you turn call $ldap->debug(12) before your add operation then you'll see
what bytes are actually being being sent on the network. Since the strings
*must* be UTF-8 encoded there, that will give you an extra way to analyze
the problem. (It can be hard working out if the bug's in your code, the
client SDK, or the server :-)

Cheers,

Chris


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic