You are here

public function Server::derivePuidFromLdapResponse in Lightweight Directory Access Protocol (LDAP) 8.4

Fetches the persistent UID from the LDAP entry.

Parameters

\Symfony\Component\Ldap\Entry $ldapEntry: The LDAP entry.

Return value

string|false The user's PUID or permanent user id (within ldap), converted from binary, if applicable.

Overrides ServerInterface::derivePuidFromLdapResponse

File

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

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function derivePuidFromLdapResponse(Entry $ldapEntry) : string {
  $puid = '';
  if ($this
    ->getUniquePersistentAttribute() && $ldapEntry
    ->hasAttribute($this
    ->getUniquePersistentAttribute(), FALSE)) {
    $puid = $ldapEntry
      ->getAttribute($this
      ->getUniquePersistentAttribute(), FALSE)[0];
    if ($this
      ->isUniquePersistentAttributeBinary()) {
      $puid = bin2hex($puid);
    }
  }
  return $puid;
}