Projet

Général

Profil

Paste
Télécharger (1,25 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_authentication / ldap_authentication.api.php @ 59ae487e

1
<?php
2

    
3
/**
4
 * @file
5
 * summary of hooks and other developer related functions
6
 */
7

    
8
/**
9
 * Allow a custom module to examine the user's ldap details
10
 * and refuse authentication.  See also: http://drupal.org/node/1634930
11
 *
12
 *  @param array $ldap_user
13
 *    See README.developers.txt for structure
14
 *  @param string $name
15
 *    The drupal account name or proposed drupal account name if none exists yet
16
 *  @param boolean $hook_result
17
 *    TRUE for allow, FALSE for deny.
18
 *    If set to TRUE or FALSE, another module has already set this and function should
19
 *    be careful about overriding this.
20
 *
21
 *  @return boolean &$hook_result passed by reference
22
 */
23
function hook_ldap_authentication_allowuser_results_alter($ldap_user, $name, &$hook_result) {
24

    
25
  if ($hook_result === FALSE) { // other module has denied user, should not override
26
    return;
27
  }
28
  elseif ($hook_result === TRUE) { // other module has allowed, maybe override
29
    if (mymodule_dissapproves($ldap_user, $name)) {
30
      $hook_result = FALSE;
31
    }
32
  }
33

    
34
}
35

    
36
/**
37
 * Allow a custom module to alter $ldap_user before validating user login.
38
 *
39
 *  @param array $ldap_user
40
 *    See README.developers.txt for structure
41
 */
42
function hook_ldap_entry_alter(&$ldap_user) {
43
  $ldap_user['mail'] = 'newmail@example.com';
44
}