class SimpleLdapUserController in Simple LDAP 7
Same name and namespace in other branches
- 7.2 simple_ldap_user/SimpleLdapUserController.class.php \SimpleLdapUserController
Controller class for LDAP users.
Hierarchy
- class \DrupalDefaultEntityController implements DrupalEntityControllerInterface
- class \UserController
- class \SimpleLdapUserController
- class \UserController
Expanded class hierarchy of SimpleLdapUserController
1 string reference to 'SimpleLdapUserController'
- simple_ldap_user_entity_info_alter in simple_ldap_user/
simple_ldap_user.module - Implements hook_entity_info_alter().
File
- simple_ldap_user/
SimpleLdapUserController.class.php, line 10 - SimpleLdapUserController class.
View source
class SimpleLdapUserController extends UserController {
/**
* Resets the entity cache.
*/
public function resetCache(array $ids = NULL) {
if (isset($ids)) {
foreach ($ids as $id) {
if (isset($this->entityCache[$id]->name)) {
SimpleLdapUser::reset($this->entityCache[$id]->name);
}
}
}
else {
SimpleLdapUser::reset();
}
return parent::resetCache($ids);
}
/**
* Verifies that the user exists in the LDAP directory.
*/
public function load($ids = array(), $conditions = array()) {
$users = parent::load($ids, $conditions);
// Validate users against LDAP directory.
foreach ($users as $uid => $drupal_user) {
// Do not validate user/1, anonymous users, or blocked users.
if ($uid == 1 || $uid == 0 || $drupal_user->status == 0) {
continue;
}
// Try to load the user from LDAP.
$ldap_user = SimpleLdapUser::singleton($drupal_user->name);
if (!$ldap_user->exists) {
// Block the user if it does not exist in LDAP.
$this
->blockUser($drupal_user);
}
// Active Directory uses a bitmask to specify certain flags on an account,
// including whether it is enabled. http://support.microsoft.com/kb/305144
if ($ldap_user->server->type == 'Active Directory') {
if (isset($ldap_user->useraccountcontrol[0]) && (int) $ldap_user->useraccountcontrol[0] & 2) {
$this
->blockUser($drupal_user);
}
}
}
return $users;
}
/**
* Block a user, setting status to 0. This will store the current status as
* stored in the database into a separate value, for use in user hooks.
*/
protected function blockUser(stdClass $account) {
$account->simple_ldap_user_drupal_status = $account->status;
$account->simple_ldap_user_ldap_status = 0;
$account->status = 0;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDefaultEntityController:: |
protected | property | Whether this entity type should use the static cache. | |
DrupalDefaultEntityController:: |
protected | property | Static cache of entities, keyed by entity ID. | |
DrupalDefaultEntityController:: |
protected | property | Array of information about the entity. | |
DrupalDefaultEntityController:: |
protected | property | Entity type for this controller instance. | |
DrupalDefaultEntityController:: |
protected | property | Additional arguments to pass to hook_TYPE_load(). | |
DrupalDefaultEntityController:: |
protected | property | Name of the entity's ID field in the entity database table. | |
DrupalDefaultEntityController:: |
protected | property | Name of entity's revision database table field, if it supports revisions. | |
DrupalDefaultEntityController:: |
protected | property | The table that stores revisions, if the entity supports revisions. | |
DrupalDefaultEntityController:: |
protected | function | Builds the query to load the entity. | 4 |
DrupalDefaultEntityController:: |
protected | function | Gets entities from the static cache. | 1 |
DrupalDefaultEntityController:: |
protected | function | Stores entities in the static entity cache. | |
DrupalDefaultEntityController:: |
protected | function | Ensures integer entity IDs are valid. | |
DrupalDefaultEntityController:: |
protected | function | Callback for array_filter that removes non-integer IDs. | |
DrupalDefaultEntityController:: |
public | function | Constructor: sets basic variables. | |
SimpleLdapUserController:: |
protected | function | Block a user, setting status to 0. This will store the current status as stored in the database into a separate value, for use in user hooks. | |
SimpleLdapUserController:: |
public | function |
Verifies that the user exists in the LDAP directory. Overrides DrupalDefaultEntityController:: |
|
SimpleLdapUserController:: |
public | function |
Resets the entity cache. Overrides DrupalDefaultEntityController:: |
|
UserController:: |
function |
Attaches data to entities upon loading. Overrides DrupalDefaultEntityController:: |