1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Maps ldap data to drupal roles.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_ldap_authorization_consumer().
|
10
|
*/
|
11
|
function ldap_authorization_drupal_role_ldap_authorization_consumer() {
|
12
|
|
13
|
$types['drupal_role'] = [
|
14
|
'consumer_name' => t('drupal role'),
|
15
|
'consumer_name_plural' => t('drupal roles'),
|
16
|
'consumer_short_name' => t('role'),
|
17
|
'consumer_short_name_plural' => t('roles'),
|
18
|
'consumer_description' => t('A Drupal Role.'),
|
19
|
'consumer_class_name' => 'LdapAuthorizationConsumerDrupalRole',
|
20
|
'consumer_class_file' => 'LdapAuthorizationConsumerRole.class.php',
|
21
|
'consumer_module' => 'ldap_authorization_drupal_role',
|
22
|
'consumer_mapping_directions' => '<p>Mappings should be of form:<br/>
|
23
|
<code>[ldap group representation]|[role name]</code>
|
24
|
<br/>such as:<br/>
|
25
|
<code>cn=students,ou=groups,dc=hogwarts,dc=edu|students<br/>
|
26
|
cn=faculty,ou=groups,dc=hogwarts,dc=edu|administrator
|
27
|
</code><br/>
|
28
|
or if "Convert full dn" is selected below, they should look like:
|
29
|
<br/>
|
30
|
<code>students|students<br/>
|
31
|
faculty|administrator
|
32
|
</code><br/>',
|
33
|
];
|
34
|
|
35
|
return $types;
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* Implements hook_ldap_user_attrs_list_alter().
|
40
|
*/
|
41
|
function ldap_authorization_drupal_role_ldap_user_attrs_list_alter(&$available_user_attrs, &$params) {
|
42
|
|
43
|
$available_user_attrs['[property.role]'] = [
|
44
|
'name' => 'Property: Drupal Roles',
|
45
|
'source' => 'depends on configuration',
|
46
|
'configurable_to_drupal' => 0,
|
47
|
'configurable_to_ldap' => 0,
|
48
|
'notes' => t('configure at:') . 'admin/config/people/ldap/authorization',
|
49
|
'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
|
50
|
'enabled' => TRUE,
|
51
|
'config_module' => 'ldap_authorization_drupal_role',
|
52
|
'prov_events' => [LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER, LDAP_USER_EVENT_CREATE_DRUPAL_USER],
|
53
|
'prov_module' => 'ldap_authorization_drupal_role',
|
54
|
];
|
55
|
|
56
|
}
|