On 17/1/06 10:22, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I am having a problem getting a base64 encoded attribute from an ldap
> server. 
> 
> When I am doing an ldapsearch from a unix commandline I get the attribute
> correctly:
> 
> QWxhZGRpbjpvcGVuIHNlc2FtZQ==
> 
> decoding ( decode_base64($encoded) ) it gives me the rigt content
> 
> Carlsson Bil Âerebro AB
> 
> 
> When getting it from Ldap using Net::Ldap I get unencryted somthing like
> this 
> 
> Carlsson Bil ™erebro
> 
> I have read nearly everything a could find but didn't anything how to
> extract the attribute correctly as a base64 as which it is saved in the
> ldap directory.
> 
> Can anybody please give me a hint?

LDAP does *not* encode attribute values using base-64, as it is a binary
protocol. What you are seeing from "ldapsearch" is LDIF output - because
LDIF is a text file format it requires that certain kinds of values be
base-64 encoded *in the file*. For the definition of "certain kinds of
values", see the LDIF spec - RFC 2849. A good approximation is "non-ASCII",
but see the RFC for details.

Net::LDAP returns you the actual attribute value. Perl scalars can hold
binary values, so what you get is what the server sends you. In this case,
an LDAPv3 server should be sending you UTF-8 (or if you're sufficiently
unlucky to be using an LDAPv2 server you should be getting T.61.
Non-conformant LDAPv2 servers will send you ISO-8859-1 instead.)

Cheers,

Chris


Reply via email to