You are here

private function SimpleLdapUser::fetch_puid in Simple LDAP 7.2

Special function to fetch the PUID of a record.

1 call to SimpleLdapUser::fetch_puid()
SimpleLdapUser::save in simple_ldap_user/SimpleLdapUser.class.php
Save user to LDAP.

File

simple_ldap_user/SimpleLdapUser.class.php, line 437
Class defining a simple LDAP user.

Class

SimpleLdapUser
@file Class defining a simple LDAP user.

Code

private function fetch_puid() {

  // Configuration
  $base_dn = simple_ldap_user_variable_get('simple_ldap_user_basedn');
  $scope = simple_ldap_user_variable_get('simple_ldap_user_scope');
  $puid_attr = strtolower(simple_ldap_user_variable_get('simple_ldap_user_unique_attribute'));

  // Should we bother?
  if (!$puid_attr || !$this->exists) {
    return array();
  }
  try {
    $result = $this->server
      ->search($this->dn, 'objectclass=*', 'sub', array(
      $puid_attr,
    ), 0, 1);
  } catch (SimpleLdapException $e) {
    if ($e
      ->getCode() == -1) {
      $result = array(
        'count' => 0,
      );
    }
    else {
      throw $e;
    }
  }
  return $result['count'] == 1 ? $result[0] : array();
}