You are here

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

Returns the user's email from the LDAP entry.

Parameters

array $ldapEntry: The LDAP entry.

Return value

string|bool The user's mail value or FALSE if none present.

1 call to Server::userEmailFromLdapEntry()
Server::matchUsernameToExistingLdapEntry in ldap_servers/src/Entity/Server.php
Queries LDAP server for the user.

File

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

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function userEmailFromLdapEntry(array $ldapEntry) {

  // Not using template.
  if ($ldapEntry && $this
    ->get('mail_attr') && isset($ldapEntry[$this
    ->get('mail_attr')][0])) {
    $mail = isset($ldapEntry[$this
      ->get('mail_attr')][0]) ? $ldapEntry[$this
      ->get('mail_attr')][0] : FALSE;
    return $mail;
  }
  elseif ($ldapEntry && $this
    ->get('mail_template')) {
    return $this->tokenProcessor
      ->tokenReplace($ldapEntry, $this
      ->get('mail_template'), 'ldap_entry');
  }
  else {
    return FALSE;
  }
}