You are here

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

Fetches the persistent UID from the LDAP entry.

Parameters

array $ldapEntry: The LDAP entry.

Return value

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

File

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

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function userPuidFromLdapEntry(array $ldapEntry) {
  if ($this
    ->get('unique_persistent_attr') && isset($ldapEntry[mb_strtolower($this
    ->get('unique_persistent_attr'))])) {
    $puid = $ldapEntry[mb_strtolower($this
      ->get('unique_persistent_attr'))];

    // If its still an array...
    if (is_array($puid)) {
      $puid = $puid[0];
    }
    return $this
      ->get('unique_persistent_attr_binary') ? ConversionHelper::binaryConversionToString($puid) : $puid;
  }
  else {
    return FALSE;
  }
}