Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/test.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
|
|
4 | 3 |
/** |
5 | 4 |
* @file |
6 |
* test script functions for testing ldap functionality outside of Drupal
|
|
7 |
* see README.txt for instructions |
|
5 |
* Test script functions for testing ldap functionality outside of Drupal
|
|
6 |
* see README.txt for instructions.
|
|
8 | 7 |
*/ |
9 | 8 |
|
10 |
require_once('functions.inc');
|
|
9 |
require_once 'functions.inc';
|
|
11 | 10 |
|
12 | 11 |
$config = ldap_help_config(); |
13 | 12 |
|
... | ... | |
26 | 25 |
foreach ($config['servers'] as $sid => $server) { |
27 | 26 |
|
28 | 27 |
/** |
29 |
* Test LDAP Connect |
|
28 |
* Test LDAP Connect.
|
|
30 | 29 |
*/ |
31 | 30 |
$results = ldap_help_connect($server['server_address'], $server['server_port'], $server['server_tls'], TRUE); |
32 | 31 |
$test_name = "\"" . $sid . "\""; |
... | ... | |
40 | 39 |
ldap_help_display('anonymous bind', $anon_bind_text); |
41 | 40 |
|
42 | 41 |
ldap_help_display('connect result', $results[1]); |
43 |
ldap_help_display('connect context', join("", array("server: ", $server['server_address'], ", port: ", $server['server_port'], ", tls= $tls")));
|
|
42 |
ldap_help_display('connect context', join("", ["server: ", $server['server_address'], ", port: ", $server['server_port'], ", tls= $tls"]));
|
|
44 | 43 |
$con = FALSE; |
45 | 44 |
if ($results[0] == LDAP_SUCCESS) { |
46 | 45 |
$con = $results[2]; |
... | ... | |
54 | 53 |
} |
55 | 54 |
|
56 | 55 |
/** |
57 |
* Test LDAP Bind |
|
56 |
* Test LDAP Bind.
|
|
58 | 57 |
*/ |
59 | 58 |
|
60 | 59 |
ldap_help_display(NULL, "------------------------------------------\n$test_name bind\n------------------------------------------"); |
61 | 60 |
|
62 | 61 |
if ($anon_bind) { |
63 | 62 |
if (@!ldap_bind($con)) { |
64 |
$results = array(ldap_errno($con), "LDAP anonymous bind error." . ldap_help_show_error($con));
|
|
63 |
$results = [ldap_errno($con), "LDAP anonymous bind error." . ldap_help_show_error($con)];
|
|
65 | 64 |
} |
66 | 65 |
} |
67 | 66 |
else { |
68 | 67 |
$bind_result = @ldap_bind($con, $server['server_bind_dn'], $server['server_bind_pw']); |
69 | 68 |
if (!$bind_result) { |
70 |
$results = array(ldap_errno($con), "LDAP bind failure for user " . $server['server_bind_dn'] . "." . ldap_help_show_error($con));
|
|
69 |
$results = [ldap_errno($con), "LDAP bind failure for user " . $server['server_bind_dn'] . "." . ldap_help_show_error($con)];
|
|
71 | 70 |
} |
72 | 71 |
else { |
73 |
$results = array(LDAP_SUCCESS, "LDAP bind success.");
|
|
72 |
$results = [LDAP_SUCCESS, "LDAP bind success."];
|
|
74 | 73 |
} |
75 | 74 |
} |
76 | 75 |
|
... | ... | |
81 | 80 |
} |
82 | 81 |
|
83 | 82 |
/** |
84 |
* Test LDAP Queries |
|
83 |
* Test LDAP Queries.
|
|
85 | 84 |
*/ |
86 | 85 |
foreach ($server['test_queries'] as $query_id => $query) { |
87 | 86 |
ldap_help_display(NULL, "------------------------------------------\n$test_name query \"$query_id\" \n------------------------------------------"); |
... | ... | |
97 | 96 |
if (!$query_result) { |
98 | 97 |
ldap_help_display(ldap_errno($con), "LDAP search failure for user $filter." . ldap_help_show_error($con)); |
99 | 98 |
} |
100 |
else {// display results |
|
99 |
// Display results. |
|
100 |
else { |
|
101 | 101 |
$entries = ldap_get_entries($con, $query_result); |
102 |
// print_r($entries); |
|
103 | 102 |
ldap_help_display('search result'); |
104 | 103 |
if (is_array($entries)) { |
105 | 104 |
$entry_count = $entries['count']; |
... | ... | |
127 | 126 |
} |
128 | 127 |
} |
129 | 128 |
|
130 |
/**
|
|
131 |
* Test LDAP Provisioning |
|
129 |
/** |
|
130 |
* Test LDAP Provisioning.
|
|
132 | 131 |
*/ |
133 | 132 |
foreach ($server['test_provisions'] as $provision_id => $provision) { |
134 | 133 |
ldap_help_display(NULL, "------------------------------------------\n$test_name provision \"$provision_id\"\n------------------------------------------"); |
... | ... | |
151 | 150 |
} |
152 | 151 |
} |
153 | 152 |
else { |
154 |
// no entry exists
|
|
153 |
// No entry exists.
|
|
155 | 154 |
} |
156 | 155 |
} |
157 | 156 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules