Net::LDAP::LDIF and UTF8 data

Hi!

Since attribute values should be UTF-8 encoded, shouldn't Net::LDIF 
convert values that are "character-strings" explicitly to UTF8?

--- LDIF.pm.orig        2004-07-29 15:45:25.000000000 +0200
+++ LDIF.pm     2004-07-29 15:44:54.000000000 +0200
@@ -296,7 +296,9 @@
      my $ln = $lower ? lc $attr : $attr;
      if ($v =~ /(^[ :]|[\x00-\x1f\x7f-\xff])/) {
        require MIME::Base64;
-      $ln .= ":: " . MIME::Base64::encode($v,"");
+      use Encode;
+      $ln .= ":: " .MIME::Base64::encode(
+        Encode::is_utf8($v)? encode_utf8($v) : $v,"");
      }
      else {
        $ln .= ": " . $v;

Otherwise a perl-string that contains only code points up to 0xFF (e.g. 
a string in Latin1) will be internally represented as 8 bit characters 
and will be converted to a Base64 converted Latin1 string, not a Base64 
converted UTF-8 string.

The same applies to all method that communicate with the ldap-server.
Shouldn't they convert perl character strings to UTF-8 octet-strings 
(like above) when sending data to the server?

Cheers,
--leo
-- 
-------------------------------------------------------
Alexander (Leo) Bergolth          leo@leo.wu-wien.ac.at
WU-Wien - Zentrum fuer Informatikdienste - Projektbuero

0
leo
7/29/2004 2:39:05 PM
perl.ldap 1268 articles. 0 followers. Follow

1 Replies
559 Views

Similar Articles

[PageSpeed] 4

On 29/7/04 3:39 pm, Alexander Bergolth <leo@strike.wu-wien.ac.at> wrote:

> Hi!
> 
> Since attribute values should be UTF-8 encoded, shouldn't Net::LDIF

Some attributes aren't UTF-8, eg jpegPhoto and userPassword both use OCTET
STRING. Certificates and CRLs (etc) are BER.

> convert values that are "character-strings" explicitly to UTF8?
> 
> --- LDIF.pm.orig        2004-07-29 15:45:25.000000000 +0200
> +++ LDIF.pm     2004-07-29 15:44:54.000000000 +0200
> @@ -296,7 +296,9 @@
>       my $ln = $lower ? lc $attr : $attr;
>       if ($v =~ /(^[ :]|[\x00-\x1f\x7f-\xff])/) {
>         require MIME::Base64;
> -      $ln .= ":: " . MIME::Base64::encode($v,"");
> +      use Encode;
> +      $ln .= ":: " .MIME::Base64::encode(
> +        Encode::is_utf8($v)? encode_utf8($v) : $v,"");
>       }
>       else {
>         $ln .= ": " . $v;
> 
> Otherwise a perl-string that contains only code points up to 0xFF (e.g.
> a string in Latin1) will be internally represented as 8 bit characters
> and will be converted to a Base64 converted Latin1 string, not a Base64
> converted UTF-8 string.
> 
> The same applies to all method that communicate with the ldap-server.
> Shouldn't they convert perl character strings to UTF-8 octet-strings
> (like above) when sending data to the server?

No, particularly if you still trying to support LDAPv2.

Cheers,

Chris


0
chrisridd
7/29/2004 6:19:36 PM
Reply:

Similar Artilces:

make Net::LDAP::LDIF more similar to Net::LDAP
Hi Graham, hi Chris, hi list, I would like to rework Net::LDAP::LDIF a bit so that its API resembles that of Net::LDAP a bit more while still keeping the traditional API. The reason for this is that in application I often need to distinguish between Net::LDAP and Net::LDAP::LDIF because some methods are only implemented on one side. I\'d like to start with a code() method that tries to mimic the Net::LDAP one and I\'d like to extend the Net::LDAP::Entry->update() method so that it takes a Net::LDAP::LDIF object as an argument. The latter one requires a...

[Fwd: make Net::LDAP::LDIF more similar to Net::LDAP]
--------------95D5815B06BDC2BD1A0ABFEB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --------------95D5815B06BDC2BD1A0ABFEB Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mozilla-Status2: 00000000 Message-ID: <40C7B13E.8864E5A0@cs.adelaide.edu.au> Date: Thu, 10 Jun 2004 10:54:22 +1000 From: Sion Camilleri <sion@cs.adelaide.edu.au> Reply-To: sion@cs.adelaide.edu.au X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Graham Barr <gbarr@pobox.com>...

Net::LDAP and Net:LDAP::LDIF read & add problems
I'm trying to read in a simple LDIF file to add an entry to my LDAP server. Here is the basic routine (extraneous details omitted for brevity and security): $ldif = Net::LDAP::LDIF->new($tmp,"r",onerror => 'warn'); $entry = $ldif->ready_entry(); $ldap = Net::LDAP->new($LDAPSERVER); $result=$ldap->bind("$binddn",password=>"$bindpass",version=>"3"); $result=$ldap->add($entry); Now, everything seems to work until I get to the $ldap->add method. From that I get various versions of the following: object...

Fw: Re: make Net::LDAP::LDIF more similar to Net::LDAP
Am 08.06.2004 um 18:29 Uhr haben Sie geschrieben: > On 8 Jun 2004, at 16:56, peter@adpm.de wrote: > > I\'d like to start with a code() method that tries to mimic the >> Net::LDAP one and >I assume you mean better error handling ? My first goal is having a code() method in Net::LDAP::LDIF. > > I\'d like to extend the > > Net::LDAP::Entry->update() method so that it takes a > > Net::LDAP::LDIF object as an argument. The latter one > > requires a bit of work in Net::LDAP::LDIF to make it > > correct. > Not su...

Net::LDAP and Net:LDAP::LDIF read & add problems #2
I'm trying to read in a simple LDIF file to add an entry to my LDAP server. Here is the basic routine (extraneous details omitted for brevity and security): $ldif = Net::LDAP::LDIF->new($tmp,"r",onerror => 'warn'); $entry = $ldif->ready_entry(); $ldap = Net::LDAP->new($LDAPSERVER); $result=$ldap->bind("$binddn",password=>"$bindpass",version=>"3"); $result=$ldap->add($entry); Now, everything seems to work until I get to the $ldap->add method. From that I get various versions of the following: obj...

Fw: Re: make Net::LDAP::LDIF more similar to Net::LDAP #2
Hi, Am 09.06.2004 um 01:44 Uhr haben Sie geschrieben: > Extending Net::LDAP::Entry to update against LDIF and LDAP objects > could allow the changetype modifications to be to produced. > > This would be really useful to produce changetypes for entry objects by > updating against an LDIF object to produce the changetype LDIF required > up to synchronise entry objects. as Graham posted you can to that already now. Simply create your Net::LDAP::Entry object with the changes option set to TRUE. Having created the ::LDIF object that way you autom...

$ldap->search triggers Bug in ASN1 and utf8 Net::LDAP code
Dear perl programmers, I think I found bug in Net::LDAP in the part which is doing something with ASN.1 (Convert::ASN1). I'm writing small program for selecting and exporting part of oracle (with DBD::Oracle) doing nasty things with output, selecting from OpenLDAP server matching and non-matching entries and comparing them attribute by attribute, making ldif diff file from that, or producing new entries if $mesg->entries is 0. I'm not a professional programmer, but I *must* finish this application. :-( Output from oracle is in UTF-8, and it has many names with nati...

Net::LDAP::LDIF should support LDIF comments
Hi, comments are an official part of LDIF, but the Perl module doesn't support them right now. RFC 2849 (LDAP Data Interchange Format) says on page 6: 3) Any line that begins with a pound-sign ("#", ASCII 35) is a comment line, and MUST be ignored when parsing an LDIF file. Why do I need that? I wrote an LDIF import utility that writes all entries that had an error into an LDIF output file for manual (or automatic) review. However it would be great to add the LDAP server's error messages as a comment in from of every entry. Code snipplet: .... ...

Net::LDAP v0.28, bug in Net::LDAP::Constant, :all not supported
Net::LDAP::Constant no longer supports the :all tag in the export list due to the switch from Exporter to a manual export routine. So, while the following: perl -MNet::LDAP::Constant=:all -e 1 worked fine in 0.2701, it now dies with the error: ":all" is not exported by the Net::LDAP::Constant module at -e line 0 Can't continue after import errors at -e line 0 BEGIN failed--compilation aborted, <DATA> line 197. The documentation for Net::LDAP::Constant still documents the ':all' tag. I am not subscribed to the list, so if some...

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

Net::LDAP based LDAP server available?
Hi, has anybody tried to build an LDAP server based on Net::LDAP or Convert::ASN1 yet? Thanks for any hint. Enrik ...

Net::LDAP & LDAP Decoding Error
--mvpLiMfbWzRoNl4x Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello! I have a question about an LDAP query with Net::LDAP. I send queries to an OpenLDAP server (version 2.2.24). The queries are very simple and intended to detect already existing user entries. The code that prepares and sends the query looks like this: $filter =3D "(uid=3D".$username.")"; $filterobj =3D Net::LDAP::Filter->new($filter); $lres =3D $ldap->search( base =3D> $base, s...

HowTo retrieve a userCertificate;binary from ldif file using Net::LDAP::LDIF
------_=_NextPart_001_01C5F613.7E0680A4 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello =20 =20 I am trying to extract a userCertificate;binary object from an ldif file using Net::LDAP::LDIF and even in this trivial example the @entries is not populated, the other objects and attributes are? =20 use Net::LDAP::LDIF; $ldif =3D Net::LDAP::LDIF->new( "test.ldif", "r", onerror =3D> 'undef' = ); @entries =3D $ldif->read( ); =20 The goal is to read the ldif file, extra...

Some feedback on Net::LDAP::LDIF...
Hi folks, Just three comments on Net::LDAP::LDIF... 1) Using: my $load_ldif = Net::LDAP::LDIF->new($LOAD_FILE, "w", lowercase => 0, wrap => 0); .... $entry->add("cellPhone" => "$phone_number"); # cellPhone with upper-case "P" .... $yahoo_load_ldif->write_entry($entry); produces a line in the output file like: cellphone: ... # cellphone with lower-case "p" so either the "lowercase" arg to "new" isn't working correctly, or I'm somehow using it incorrectly? Further, t...

Web resources about - Net::LDAP::LDIF and UTF8 data - perl.ldap

Resources last updated: 1/21/2016 2:54:17 PM