You are here

public function LdapServerTest::delete in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_test/LdapServerTest.class.php \LdapServerTest::delete()

Perform an LDAP delete.

Parameters

string $dn:

Return value

boolean result per ldap_delete

Overrides LdapServer::delete

File

ldap_test/LdapServerTest.class.php, line 476
Simpletest ldapServer class for testing without an actual ldap server

Class

LdapServerTest

Code

public function delete($dn) {
  $test_data = variable_get('ldap_test_server__' . $this->sid, array());

  // debug("test ldap server, delete=$dn, test data="); debug(array_keys($test_data['users']));
  $deleted = FALSE;
  foreach (array(
    'entries',
    'users',
    'groups',
    'ldap',
  ) as $test_data_sub_array) {
    if (isset($test_data[$test_data_sub_array][$dn])) {
      unset($test_data[$test_data_sub_array][$dn]);
      $deleted = TRUE;
    }
  }
  if ($deleted) {
    variable_set('ldap_test_server__' . $this->sid, $test_data);
    $this
      ->refreshFakeData();
    return TRUE;
  }
  else {
    return FALSE;
  }
}