note 75321 added to function.ldap-search

From: Date: Wed, 23 May 2007 18:39:50 +0000
Subject: note 75321 added to function.ldap-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-126854@lists.php.net to get a copy of this message
When I discovered I couldn't get searches to work with complex strings (in my case searching on displayName which can have parens and slashes in it). I made this quick function to quote ldap strings in accordance with the RFC. Except I encode spaces as well since searching wouldn't work with spaces. Note, technically speaking a search filter can be encoded into the \xx format for all characters but then filters wouldn't be human readable. I'm somewhat surprised there wasn't a built in ldap_quote() type of function already. <?php // see: RFC2254 function ldap_quote($str) { return str_replace( array( '\\', ' ', '*', '(', ')' ), array( '\\5c', '\\20', '\\2a', '\\28', '\\29' ), $str ); } ?> ---- Server IP: 69.39.81.135 Probable Submitter: 128.231.88.6 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-search.php Edit -- https://master.php.net/note/edit/75321 Del: integrated -- https://master.php.net/note/delete/75321/integrated Del: useless -- https://master.php.net/note/delete/75321/useless Del: bad code -- https://master.php.net/note/delete/75321/bad+code Del: spam -- https://master.php.net/note/delete/75321/spam Del: non-english -- https://master.php.net/note/delete/75321/non-english Del: in docs -- https://master.php.net/note/delete/75321/in+docs Del: other reasons-- https://master.php.net/note/delete/75321 Reject -- https://master.php.net/note/reject/75321 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126854) next »