note 52916 added to function.ldap-sort

From: Date: Tue, 17 May 2005 16:13:00 +0000
Subject: note 52916 added to function.ldap-sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-89554@lists.php.net to get a copy of this message
About the note of ccblanket at yahoo dot com... Nice tip, but on line 2 of your example we need to use $ldapSortAttributes and not $ldapSortAttribues :-) So, the whole correct function is: <?php $ldapFilterAttributes = array ('givenname', 'sn', 'mail'); $ldapSortAttributes = array('sn', 'givenname'); $ldapFilter = "(&(sn='')(givenname=''))"; $ldapBaseDN = 'ou=users, dc=example, dc=com'; $search = @ldap_search($ldapConnect, $ldapBaseDN, $ldapFilter, $ldapFilterAttributes) ; if (!($search)) { die("Unable to search LDAP server"); } foreach ($ldapSortAttributes as $eachSortAttribute) { if (in_array($eachSortAttribute, $ldapFilterAttributes)) { ldap_sort($this->connect, $search, $eachSortAttribute); } } $results = ldap_get_entries($this->connect, $search); print_r($results); ?> ---- Manual Page -- http://www.php.net/manual/en/function.ldap-sort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52916 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52916&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52916&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52916&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52916&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52916&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52916&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89554) next »