You are here

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

Does dn exist for this server and what is its data?

@todo Entry/null would be better for type hints.

Parameters

string $dn: DN to search for.

array $attributes: In same form as ldap_read $attributes parameter.

Return value

bool|Entry Return ldap entry or false.

2 calls to LdapBaseManager::checkDnExistsIncludeData()
LdapGroupManager::groupAllMembers in ldap_servers/src/LdapGroupManager.php
Get all members of a group.
LdapGroupManager::groupMembers in ldap_servers/src/LdapGroupManager.php
Get direct members of a group.

File

ldap_servers/src/LdapBaseManager.php, line 149

Class

LdapBaseManager
LDAP Base Manager.

Namespace

Drupal\ldap_servers

Code

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