You are here

public function LdapBaseManager::checkDnExists in Lightweight Directory Access Protocol (LDAP) 8.4

Does dn exist for this server?

Parameters

string $dn: DN to search for.

Return value

bool DN exists.

1 call to LdapBaseManager::checkDnExists()
LdapGroupManager::groupAddGroup in ldap_servers/src/LdapGroupManager.php
Add a group entry.

File

ldap_servers/src/LdapBaseManager.php, line 182

Class

LdapBaseManager
LDAP Base Manager.

Namespace

Drupal\ldap_servers

Code

public function checkDnExists(string $dn) : bool {
  if (!$this
    ->checkAvailability()) {
    return FALSE;
  }
  $options = [
    'filter' => [
      'objectclass',
    ],
    'scope' => 'base',
  ];
  try {
    $result = $this->ldap
      ->query($dn, '(objectclass=*)', $options)
      ->execute();
  } catch (LdapException $e) {
    return FALSE;
  }
  return $result
    ->count() > 0;
}