Projet

Général

Profil

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

root / drupal7 / sites / all / modules / ldap / ldap_authentication / ldap_authentication.api.php @ 91af538d

1
<?php
2

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

    
8
/**
9
 * Allow a custom module to check user's ldap details and refuse authentication.
10
 *
11
 * See also: http://drupal.org/node/1634930.
12
 *
13
 * @param array $ldap_user
14
 *   See README.developers.txt for structure.
15
 * @param string $name
16
 *   The drupal account name or proposed drupal account name if none exists yet.
17
 * @param bool $hook_result
18
 *   TRUE for allow, FALSE for deny.
19
 *   If set to TRUE or FALSE, another module has already set this and function
20
 *   should be careful about overriding this.
21
 */
22
function hook_ldap_authentication_allowuser_results_alter(array $ldap_user, $name, &$hook_result) {
23
  // Other module has denied user, should not override.
24
  if ($hook_result === FALSE) {
25
    return;
26
  }
27
  // Other module has allowed, maybe override.
28
  elseif ($hook_result === TRUE) {
29
    if (mymodule_dissapproves($ldap_user, $name)) {
30
      $hook_result = FALSE;
31
    }
32
  }
33
}
34

    
35
/**
36
 * Allow a custom module to alter $ldap_user.
37
 *
38
 * @param array $ldap_user
39
 *   See README.developers.txt for structure.
40
 * @param array $params
41
 *   Array of parameters. Includes account key with the Drupal account as value.
42
 */
43
function hook_ldap_entry_alter(array &$ldap_user, array $params) {
44
  $ldap_user['mail'] = 'newmail@example.com';
45
}