note 96826 deleted from function.ldap-get-entries by danbrown

From: Date: Fri, 19 Mar 2010 15:32:42 +0000
Subject: note 96826 deleted from function.ldap-get-entries by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-167215@lists.php.net to get a copy of this message
Note Submitter: Adrian Calderon ---- @ markus dot schabel at tgm dot ac dot at If you are going to use Markus' function to directly push the returned entry into ldap_add or ldap_modify (i.e. doing a diff with another system and updating changed attributes during sychronization), you need to add another for loop to handle the entry structure properly. Please see revised function below: /** * Take an LDAP and make an associative array from it. * * This function takes an LDAP entry in the ldap_get_entries() style and * converts it to an associative array like ldap_add() needs. * * @param array $entry is the entry that should be converted. * * @return array is the converted entry. */ function cleanUpEntry($entry) { $retEntry = array(); for ( $i = 0; $i < $entry['count']; $i++ ) { for ($h = 0; $h < $entry[$i]['count']; $h++) { $attribute = $entry[$i][$h]; if ( $entry[$i][$attribute]['count'] == '1' ) { $retEntry[$attribute] = $entry[$i][$attribute][0]; } else { for ( $j = 0; $j < $entry[$attribute]['count']; $j++ ) { $retEntry[$attribute][$j] = $entry[$i][$attribute][$j]; } } } } return $retEntry; }

« previous php.notes (#167215) next »