You are here

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

Same name and namespace in other branches
  1. 8.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 477
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, []);
  $deleted = FALSE;
  foreach ([
    '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;
  }
}