function LdapServerTest::modifyLdapEntry in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_test/LdapServerTest.class.php \LdapServerTest::modifyLdapEntry()
modify attributes of ldap entry
Parameters
string $dn DN of entry:
array $attributes should follow the structure of ldap_add functions: entry array: http://us.php.net/manual/en/function.ldap-add.php $attributes["attribute1"] = "value"; $attributes["attribute2"][0] = "value1"; $attributes["attribute2"][1] = "value2";
@return TRUE on success FALSE on error
Overrides LdapServer::modifyLdapEntry
File
- ldap_test/
LdapServerTest.class.php, line 422 - Simpletest ldapServer class for testing without an actual ldap server
Class
Code
function modifyLdapEntry($dn, $attributes = NULL, $old_attributes = FALSE) {
if (!$attributes) {
$attributes = array();
}
$test_data = variable_get('ldap_test_server__' . $this->sid, array());
if (!isset($test_data['entries'][$dn])) {
return FALSE;
}
$ldap_entry = $test_data['entries'][$dn];
foreach ($attributes as $key => $cur_val) {
if ($cur_val == '') {
unset($ldap_entry[$key]);
}
elseif (is_array($cur_val)) {
foreach ($cur_val as $mv_key => $mv_cur_val) {
if ($mv_cur_val == '') {
unset($ldap_entry[$key][$mv_key]);
}
else {
if (is_array($mv_cur_val)) {
$ldap_entry[$key][$mv_key] = $mv_cur_val;
}
else {
$ldap_entry[$key][$mv_key][] = $mv_cur_val;
}
}
}
unset($ldap_entry[$key]['count']);
$ldap_entry[$key]['count'] = count($ldap_entry[$key]);
}
else {
$ldap_entry[$key][0] = $cur_val;
$ldap_entry[$key]['count'] = count($ldap_entry[$key]);
}
}
$test_data['entries'][$dn] = $ldap_entry;
$test_data['ldap'][$dn] = $ldap_entry;
// debug("modifyLdapEntry:server test data before save $dn"); debug($test_data['entries'][$dn]);
variable_set('ldap_test_server__' . $this->sid, $test_data);
$this
->refreshFakeData();
return TRUE;
}