php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12740 LDAP modify functions do not handle special characters
Submitted: 2001-08-14 09:41 UTC Modified: 2001-11-12 07:30 UTC
From: christian at metamerge dot com Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.0.5 OS: Linux RH 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: christian at metamerge dot com
New email:
PHP Version: OS:

 

 [2001-08-14 09:41 UTC] christian at metamerge dot com
Hi,

I am working with PHP 4.0.5 and OpenLDAP 2.0.11.

I encounter problems when modifying some entries with attributes containing special chars (such as ?, ?...). The error returned by the LDAP server is "invalid syntax".

I have read some documentation about this. OpenLDAP can accept special chars, provided values are base64-encoded, when we use the tools that come with the application (ldapadd, ldapmodify, etc.).

But how to do this from PHP functions? I tried to base64_encode the values,
it naturally didn't do the trick (those values were considered as normal, and thus were not decoded - this polutes my directory.) Same goes for urlencoding.

Please help!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-14 09:50 UTC] sniper@php.net
Please include a short example script in this report.

 [2001-10-02 18:39 UTC] sniper@php.net
I can't reprocude this with my test scripts. If this still
happens with PHP 4.0.6, reopen. Check also your locale settings.

 [2001-10-09 14:03 UTC] christian at metamerge dot com
// Here is a function to translate all values of a multi-dimensional array to UTF8

function encoder ($array)
{
  while ( list ($key, $val) = each ($array) ) 
  {
    if (!is_array($val))
      $array[$key] = utf8_encode($val);
    else $array[$key] = encoder ($val);
  }	
  return $array;
}

//Here is a call where 
// - $conn_id is a valid connection ID
// - $dn is the dn of the object to add
// - $array is the array containing the values of the attributes indexed by name

$array = encoder($arr); 
ldap_add($conn_id, $dn, $array);

// this call fails 
// - if $array contains a special char (e.g ?, ?...) , thus returning SYNTAX ERROR
// - if $dn contains a special char (e.g ?, ?...) , thus returning No Such Object
 [2001-10-09 14:05 UTC] christian at metamerge dot com
What would the locale setting change? According to the docs, PHP have a UTF8 internal reprsentation of data...
 [2001-10-23 04:07 UTC] sniper@php.net
Okay, does the ldap server support ldap v3?
If so, you should propably try to add this:

ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)

--Jani

 [2001-11-12 07:30 UTC] venaas@php.net
The problem turned out to be that the syntax for the
attribute was IA5, thus not allowing non-ASCII. We
should see if we can report more precise error messages
that includes which attribute was the problem.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 06:01:27 2025 UTC