note 96826 added to function.ldap-get-entries
| From: | AdrianCalderon at osu1 dot php dot net | Date: | Wed, 17 Mar 2010 19:41:26 +0000 |
| Subject: | note 96826 added to function.ldap-get-entries | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167141@lists.php.net to get a copy of this message | ||
@ 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;
}
----
Server IP: 69.147.83.197
Probable Submitter: 216.55.52.130
----
Manual Page -- http://www.php.net/manual/en/function.ldap-get-entries.php
Edit -- https://master.php.net/note/edit/96826
Del: integrated -- https://master.php.net/note/delete/96826/integrated
Del: useless -- https://master.php.net/note/delete/96826/useless
Del: bad code -- https://master.php.net/note/delete/96826/bad+code
Del: spam -- https://master.php.net/note/delete/96826/spam
Del: non-english -- https://master.php.net/note/delete/96826/non-english
Del: in docs -- https://master.php.net/note/delete/96826/in+docs
Del: other reasons-- https://master.php.net/note/delete/96826
Reject -- https://master.php.net/note/reject/96826
Search -- https://master.php.net/manage/user-notes.php