From: Chris R. <chr...@me...> - 2001-01-26 08:38:00
|
Ken DeLay <ken...@sy...> wrote: > Correction, $fileName var below was corrected but still doesn't work. > > I realize now that the jpeg photo should be ASN encoded first, is that > correct? > > Ken The RFCs require that values of jpegPhoto attributes be the raw bytes of the JPEG file. The only reason to ASN encode (actually BER encode) the value would be if you were manipulating the value using the ;binary attribute type description of LDAPv3. So kind of this: jpegPhoto;binary = <load of BER-encoded octets> But that would be unusual and almost certainly the Netscape server wouldn't be able to deal with it anyway. You *should* just be able to read the JPEG in and add it as a value to a jpegPhoto attribute. Your code to read the image in is overcomplex IMHO, but should work. So should this: if (-e $fileName) { local $/ = undef; open JPEG, $fileName or die; $jpegimage = <JPEG>; close JPEG; $res = $ldap->modify('cn=My entry,o=My company,c=XX', add => { 'jpegPhoto' => [ $jpegimage ] }) or die; $code = $res->code; die "Modify error ($code)" if $code; } You appear to be using the Mozilla LDAP library for perl called perldap (which uses native libraries and is not pure perl), which apparently isn't being maintained any more. This mailing list is for the native perl LDAP library, called perl-ldap. So there might be a problem with the way the Mozilla LDAP code handles values which aren't text and which aren't BER. This kind of stuff is no problem in perl-ldap :-) > At 03:08 PM 01/25/2001 -0700, Ken DeLay wrote: >> Excuse a newbie question, but I am trying to do something simple and add >> an entry to a Netscape Directory via perl-ldap with a jpeg photo. >> >> The problem I am having is that the jpeg photo doesn't seem to get added >> correctly. >> >> I am using the same basic sample code from the Mozilla FAQ: >> >> $filename="test.jpg"; >> if (-e $fileName) { >> open(JPEG, $fileName) || die; >> while (sysread JPEG, $buf, 1024) { >> $jpegimage .= $buf; >> >> } >> } else { >> open(JPEG, $NOPHOTOJPG) || die; >> $jpegimage=<JPEG>; >> while (sysread JPEG, $buf, 1024) { >> $jpegimage .= $buf; >> } >> } >> $entry->{jpegphoto} = $jpegimage; >> >> Anyone had problems using this code to add binary data such as a jpeg >> photo to the Netscape 4.1 directory server? >> >> >> Thanks, >> >> Ken >> >> >> ========================= >> Ken DeLay >> Senior Consultant >> Syntegra (USA) >> Phone: (303)-205-1621 >> email: ken...@sy... >> ========================= >> > > Cheers, Chris |