/**
  * Remove an LDAP user from the LDAP group.
  */
 public function deleteUser($user)
 {
     // Make sure the user is a SimpleLdapUser object.
     if (is_string($user)) {
         $user = SimpleLdapUser::singleton($user);
     }
     // Get the module configuration.
     $user_attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name');
     $attribute_member = simple_ldap_role_variable_get('simple_ldap_role_attribute_member');
     $attribute_member_format = simple_ldap_role_variable_get('simple_ldap_role_attribute_member_format');
     // Determine the member attribute format.
     if ($attribute_member_format == 'dn') {
         $member = $user->dn;
     } else {
         $member = $user->{$user_attribute_name}[0];
     }
     // Remove the user from this group.
     if (is_array($this->attributes[$attribute_member])) {
         $key = array_search($member, $this->attributes[$attribute_member]);
         if ($key !== FALSE) {
             unset($this->attributes[$attribute_member][$key]);
             if (isset($this->attributes[$attribute_member]['count'])) {
                 unset($this->attributes[$attribute_member]['count']);
             }
             $this->attributes[$attribute_member] = array_values($this->attributes[$attribute_member]);
             $this->attributes[$attribute_member]['count'] = count($this->attributes[$attribute_member]);
             $this->dirty = TRUE;
         }
     }
 }
 /**
  * Special function to fetch the PUID of a record.
  */
 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();
 }