1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* The ldap_help issues provides a filtered watchdog view for ldap issues.
|
6
|
*
|
7
|
*/
|
8
|
|
9
|
/**
|
10
|
* the goal of this function is to illustrate samples from various ldap
|
11
|
* implementations (AD, openldap, etc) alongside default/common
|
12
|
* ldap module configurations. The data for the ldaps and the configuration
|
13
|
* should be the same as is used in the simpletets.
|
14
|
*/
|
15
|
function ldap_help_examples() {
|
16
|
module_load_include('php', 'ldap_test', 'LdapTestFunctions.class');
|
17
|
$test_functions = new LdapTestFunctions();
|
18
|
drupal_add_library('system', 'drupal.collapse');
|
19
|
$sample_ldaps = array(
|
20
|
'activedirectory' => 'activedirectory1',
|
21
|
'openldap' => 'openldap1',
|
22
|
);
|
23
|
|
24
|
|
25
|
$form = array();
|
26
|
foreach ($sample_ldaps as $ldap_type => $sample_ldap_id) {
|
27
|
|
28
|
$sample_ldap_id = $sample_ldaps[$ldap_type];
|
29
|
$test_functions->populateFakeLdapServerData(LDAP_TEST_LDAP_NAME, $sample_ldap_id);
|
30
|
$data = $test_functions->data['ldap_servers'][$sample_ldap_id]['ldap'];
|
31
|
$form[$sample_ldap_id] = array(
|
32
|
'#type' => 'fieldset',
|
33
|
'#title' => $ldap_type,
|
34
|
'#description' => '',
|
35
|
'#attributes' => array('class' => array('collapsible', 'collapsed')),
|
36
|
'#collapsible' => TRUE,
|
37
|
'#collapsed' => TRUE,
|
38
|
);
|
39
|
foreach (array('people', 'groups') as $ou) {
|
40
|
$form[$sample_ldap_id][$ou] = array(
|
41
|
'#type' => 'fieldset',
|
42
|
'#title' => "ou=$ou",
|
43
|
'#description' => '',
|
44
|
'#attributes' => array('class' => array('collapsible', 'collapsed')),
|
45
|
'#collapsible' => TRUE,
|
46
|
'#collapsed' => TRUE,
|
47
|
);
|
48
|
}
|
49
|
|
50
|
foreach ($data as $dn => $item) {
|
51
|
$ou = ldap_servers_get_all_rdn_values_from_dn($dn, 'ou');
|
52
|
$ou = $ou[0];
|
53
|
unset($item['count']);
|
54
|
|
55
|
$li = array();
|
56
|
foreach ($item as $attr => $values) {
|
57
|
unset($values['count']);
|
58
|
if (count($values) == 1) {
|
59
|
$li[] = "$attr: " . $values[0] . '<br/>';
|
60
|
}
|
61
|
else {
|
62
|
$li[] = theme('item_list', array('items' => $values , 'type' => 'ul', 'title' => $attr));
|
63
|
}
|
64
|
}
|
65
|
$form[$sample_ldap_id][$ou][$dn] = array(
|
66
|
'#type' => 'fieldset',
|
67
|
'#attributes' => array('class' => array('collapsible', 'collapsed')),
|
68
|
'#title' => $dn,
|
69
|
'#collapsible' => TRUE,
|
70
|
'#collapsed' => TRUE,
|
71
|
);
|
72
|
$form[$sample_ldap_id][$ou][$dn][] = array(
|
73
|
'#markup' => theme('item_list', array('items' => $li , 'type' => 'ul', 'title' => '')),
|
74
|
);
|
75
|
|
76
|
}
|
77
|
}
|
78
|
|
79
|
return drupal_render($form);
|
80
|
}
|