You are here

public function Server::checkDnExists in Lightweight Directory Access Protocol (LDAP) 8.3

Does dn exist for this server?

Parameters

string $dn: DN to search for.

Return value

bool DN exists.

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

File

ldap_servers/src/Entity/Server.php, line 383

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function checkDnExists($dn) {
  $params = [
    'base_dn' => $dn,
    'attributes' => [
      'objectclass',
    ],
    'attrsonly' => FALSE,
    'filter' => '(objectclass=*)',
    'sizelimit' => 0,
    'timelimit' => 0,
    'deref' => NULL,
  ];
  $result = $this
    ->ldapQuery(Server::SCOPE_BASE, $params);
  if ($result !== FALSE) {
    $entries = @ldap_get_entries($this->connection, $result);
    if ($entries !== FALSE && $entries['count'] > 0) {
      return TRUE;
    }
  }
  return FALSE;
}