note 90158 added to function.ldap-search

From: Date: Wed, 08 Apr 2009 13:01:14 +0000
Subject: note 90158 added to function.ldap-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-152958@lists.php.net to get a copy of this message
A better ldap_escape, if you don't need nested filters such as those in the Pear package. Escapes for both filters and distinguished names. function ldap_escape($str, $for_dn = false) { // see: // RFC2254 // http://msdn.microsoft.com/en-us/library/ms675768(VS.85).aspx // http://www-03.ibm.com/systems/i/software/ldap/underdn.html if ($for_dn) $metaChars = array(',','=', '+', '<','>',';', '\\', '"', '#'); else $metaChars = array('*', '(', ')', '\\', chr(0)); $quotedMetaChars = array(); foreach ($metaChars as $key => $value) $quotedMetaChars[$key] = '\\'.str_pad(dechex(ord($value)), 2, '0'); $str=str_replace($metaChars,$quotedMetaChars,$str); //replace them return ($str); } ---- Server IP: 64.71.164.2 Probable Submitter: 65.87.162.35 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-search.php Edit -- https://master.php.net/note/edit/90158 Del: integrated -- https://master.php.net/note/delete/90158/integrated Del: useless -- https://master.php.net/note/delete/90158/useless Del: bad code -- https://master.php.net/note/delete/90158/bad+code Del: spam -- https://master.php.net/note/delete/90158/spam Del: non-english -- https://master.php.net/note/delete/90158/non-english Del: in docs -- https://master.php.net/note/delete/90158/in+docs Del: other reasons-- https://master.php.net/note/delete/90158 Reject -- https://master.php.net/note/reject/90158 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152958) next »