[Date Prev][Date Next] [Chronological] [Thread] [Top]

AW: How do retrieve binary value with PHP?



Hi,

here the workaround I use to read binary certificates into php variables:


function certfiles ($dn) {
  $ldapcall = "ldapsearch -x -LLL -h " . Z_SERVER . " -D \"" . Z_BIND_DN 
    . "\" -w \"" . Z_PW . "\" -s base -b \"" . $dn . "\" -t
usercertificate";

  $res = `$ldapcall`;
  $res_ar = explode("\n", $res);

  $dn_garbage = array_shift ($res_ar);   // do not use 1st line (dn)

  return $res_ar;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// userCertificates übernehmen:
$certs = certfiles("uid=userxyz,o=myorg,c=de");   // get certificates

$u = 0;   // counter

for ($i = 0; $i < sizeof($certs); $i++) {
  $xp = explode("//", $certs[$i], 2);

  $xinfo["userCertificate;binary"][$u] = `cat "$xp[1]"`;
  unlink($xp[1]);   // delete tmp file
  $u++;
}


I think the reason for this problem is that binary certificates contain
linefeed characters which the ldap package of php consideres as end of
output string, such cutting the userCertificate at the first occurance of
lf. (or so...)

Regards,
Gerhard


-----Ursprüngliche Nachricht-----
Von: Lui Yeok Peng [mailto:ypenglui@hotmail.com]
Gesendet: Freitag, 18. Januar 2002 13:31
An: openldap-software@OpenLDAP.org
Betreff: How do retrieve binary value with PHP?


hi,
      have anybody using php to retrieve binary value from OpenLDAP before? 
i have try to get it back using php API to get the 'certificate;binary' 
value but the returning result is not what i'm intended.
      Is it not possible to store a binary value into php variable? If not, 
how to do to get these binary value with PHP?
      thanks !

with regards,
lui

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com