#41953 [NEW]: ldap_add incorrectly handles the comma, even with two backslashes (\\,)

From: Date: Tue, 10 Jul 2007 19:27:30 +0000
Subject: #41953 [NEW]: ldap_add incorrectly handles the comma, even with two backslashes (\\,)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-114856@lists.php.net to get a copy of this message
From: ahoyt at kpcommunications dot com Operating system: Mac OS X, Windows 2003 Server PHP version: 5.2.3 PHP Bug Type: LDAP related Bug description: ldap_add incorrectly handles the comma, even with two backslashes (\\,) Description: ------------ ldap_add fails when creating a new user in Active Directory with the following circumstances: 1. The DN contains a comma such as: "CN=Last, First,CN=Users,DC=example,DC=com" 2. This bug is reproducible on Mac OS X and Windows 2003 Server (Have not tried other OS's). 3. unknown whether the problem is with php_ldap module or with zend engine. Sourcecode for AD user creation from http://adldap.sourceforge.net. Class modified to make entry as straightforward as possible. See example.php user_create() and change the dn in adLDAP.php to a preset string. Reproduce code: --------------- //ldap connect -> $_conn (returns a valid link resource) ldap_set_option($_conn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($_conn, LDAP_OPT_REFERRALS, 0); //ldaps bind (ldap binds with ssl) $dn = "CN=Last\\, First,CN=Users,DC=example,DC=com"; //escape twice for a single backslash in ldap echo $dn; echo "<br>"; $attributes["samaccountname"][0] = "flast"; $attributes["anyattribute"][0] = "anything"; ldap_add($_conn,$dn,$attributes); //Error Expected result: ---------------- ldap_add returns true, new user created at CN=Last\, First,CN=Users,DC=example,DC=com Note: This happens with Active Directory on Windows 2003 Server, as well as many open directory implementations. The comma character is not defined in RFC 2255, PHP or SSL does not deal with it correctly. php class located at: http://adldap.sourceforge.net Actual result: -------------- Program returns the following: ---------------------------------------------------------------------- CN=Last\, First,CN=Users,DC=example,DC=com Warning: ldap_add() [function.ldap-add]: Add: Invalid DN syntax in / PHP/classes/class.adLDAP.php on line 689 ---------------------------------------------------------------------- Notes: The dn syntax is completely valid, no reason why this should not work. line 689 is not the actual location of ldap_add in the original adldap class: (http://adldap.sourceforge.net), but it is near that line. In the class, it is preceeded by an @. I removed the @ to see the error messages. Notes: the phpLDAPadmin project has a similar problem but when exporting to LDIF format, the DN comes out like this: CN=Last\2C First,CN=Users,DC=example,DC=com under and Open Directory Server. Other notes: This bug also seems to appear in the PEAR package for LDAP. I have tried DN entries with commas ",", backslash commas, "\,", etc. and none of it works. -- Edit bug report at http://bugs.php.net/?id=41953&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41953&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41953&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41953&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41953&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41953&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41953&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41953&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41953&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41953&r=support Expected behavior: http://bugs.php.net/fix.php?id=41953&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41953&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41953&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41953&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41953&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41953&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41953&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41953&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41953&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41953&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41953&r=mysqlcfg

« previous php.bugs (#114856) next »