note 52916 deleted from function.ldap-sort by danbrown

From: Date: Wed, 31 Mar 2010 16:20:47 +0000
Subject: note 52916 deleted from function.ldap-sort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-167572@lists.php.net to get a copy of this message
Note Submitter: huntz at huntz dot org ---- 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); ?>

« previous php.notes (#167572) next »