Re: Conversion question

Rich Megginson <[email protected]> Thu, 05 Nov 2009 12:58:47 -0700
Newsgroups gmane.comp.mozilla.devel.directory
Message-ID <[email protected]>
Markus Moeller wrote:
> 
> If I use ldapsearch  for example I get
> 
> 
> ldapsearch -LLL -H ldap://w2k3r2.win2003r2.home -s sub -b
> dc=win2003r2,dc=home "(cn=markus a*)" memberof
> SASL/GSSAPI authentication started
> SASL username: [email protected]
> SASL SSF: 56
> SASL data security layer installed.
> dn: CN=Markus A Moeller,CN=Users,DC=win2003r2,DC=home
> memberOf:: Q049TcO2bGxlcixPVT1UZXN0R3JvdXBzLERDPXdpbjIwMDNyMixEQz1ob21l
> memberOf: CN=SQUID_ALLOW,CN=Users,DC=win2003r2,DC=home
> memberOf: CN=Administrators,CN=Builtin,DC=win2003r2,DC=home
> #
> refldap://ForestDnsZones.win2003r2.home/DC=ForestDnsZones,DC=win2003r2,DC=home 
> 
> #
> refldap://DomainDnsZones.win2003r2.home/DC=DomainDnsZones,DC=win2003r2,DC=home 
> 
> # refldap://win2003r2.home/CN=Configuration,DC=win2003r2,DC=home
> 
> 
> I get entries which are Octet Strings. Is there a ldap function to 
> convert to the real string ?

Firstly, it looks as though you are using openldap.  Your questions 
would be better posted on one of the openldap lists.

For good or bad, ldapsearch by default will base64 encode any 
non-printable characters.

 > python
 >>> import base64
 >>> 
base64.b64decode('Q049TcO2bGxlcixPVT1UZXN0R3JvdXBzLERDPXdpbjIwMDNyMixEQz1ob21l')
'CN=M\xc3\xb6ller,OU=TestGroups,DC=win2003r2,DC=home'

In addition, LDAP uses utf8, so you'll also have to convert the utf8 
values to your local charset.

> 
> What would I need to do to use the result in a filter for a new query ?  

http://www.ietf.org/rfc/rfc4515.txt

> Can I just use the octet string ?
> 
> Thank you
> Markus
> 
> "Markus Moeller" <[email protected]> wrote in message 
> news:[email protected]...
>> I have a program which does an ldap search and then prints the found 
>> attribute values. Thsi works fine for english character sets. But when 
>> the ldap server contains accents or umlauts I get unreadable strings. 
>> How do I convert them ?
>>
>> Thank you
>> Markus 
>