You are here

function ldap_user_ldap_exclude in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_user/ldap_user.module \ldap_user_ldap_exclude()

Parameters

object $account: as drupal user object.

array $edit: is a drupal user edit array.

enum int $direction: indicating which directions to test for association.

Return value

boolean TRUE if user should be excluded from ldap provision/synching

4 calls to ldap_user_ldap_exclude()
ldap_user_user_insert in ldap_user/ldap_user.module
Implements hook_user_insert().
ldap_user_user_login in ldap_user/ldap_user.module
Implements hook_user_login().
ldap_user_user_presave in ldap_user/ldap_user.module
Implements hook_user_presave()
ldap_user_user_update in ldap_user/ldap_user.module
Implements hook_user_update()
1 string reference to 'ldap_user_ldap_exclude'
ldap_user_user_entity_fields in ldap_user/ldap_user.install
See http://api.drupal.org/api/drupal/modules%21field%21field.module/group/fi....

File

ldap_user/ldap_user.module, line 668
Module for the LDAP User Entity.

Code

function ldap_user_ldap_exclude($account = NULL, $edit = NULL, $direction = LDAP_USER_PROV_DIRECTION_ALL) {

  // Always exclude user 1.
  if (is_object($account) && isset($account->uid) && $account->uid == 1) {
    return TRUE;
  }

  // Exclude users who have the field ldap_user_ldap_exclude set to 1.
  if (is_object($account) && isset($account->ldap_user_ldap_exclude[LANGUAGE_NONE][0]['value']) && $account->ldap_user_ldap_exclude[LANGUAGE_NONE][0]['value'] == 1) {
    return TRUE;
  }

  // Exclude new users who have the value set to 1 in their $edit array.
  if (is_array($edit) && isset($edit['ldap_user_ldap_exclude'][LANGUAGE_NONE][0]['value']) && $edit['ldap_user_ldap_exclude'][LANGUAGE_NONE][0]['value'] == 1) {
    return TRUE;
  }

  // Everyone else is fine.
  return FALSE;
}