1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
part of pfSense (https://www.pfsense.org/)
|
5
|
|
6
|
Copyright (C) 2007 Scott Ullrich <sullrich@gmail.com>
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
/*
|
31
|
pfSense_MODULE: auth
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-system-usermanager-settings-testldap
|
36
|
##|*NAME=System: User Manager: Settings: Test LDAP page
|
37
|
##|*DESCR=Allow access to the 'System: User Manager: Settings: Test LDAP' page.
|
38
|
##|*MATCH=system_usermanager_settings_test.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
require("guiconfig.inc");
|
42
|
require_once("auth.inc");
|
43
|
|
44
|
$authserver = $_GET['authserver'];
|
45
|
$authcfg = auth_get_authserver($authserver);
|
46
|
|
47
|
?>
|
48
|
|
49
|
<html>
|
50
|
<HEAD>
|
51
|
<STYLE type="text/css">
|
52
|
TABLE {
|
53
|
border-width: 1px 1px 1px 1px;
|
54
|
border-spacing: 0px;
|
55
|
border-style: solid solid solid solid;
|
56
|
border-color: gray gray gray gray;
|
57
|
border-collapse: separate;
|
58
|
background-color: collapse;
|
59
|
}
|
60
|
TD {
|
61
|
border-width: 1px 1px 1px 1px;
|
62
|
border-spacing: 0px;
|
63
|
border-style: solid solid solid solid;
|
64
|
border-color: gray gray gray gray;
|
65
|
border-collapse: collapse;
|
66
|
background-color: white;
|
67
|
}
|
68
|
</STYLE>
|
69
|
</HEAD>
|
70
|
<body>
|
71
|
<form method="post" name="iform" id="iform">
|
72
|
|
73
|
<?php
|
74
|
|
75
|
if (!$authcfg) {
|
76
|
printf(gettext("Could not find settings for %s%s"), htmlspecialchars($authserver), "<p/>");
|
77
|
} else {
|
78
|
echo sprintf(gettext("Testing %s LDAP settings... One moment please..."), $g['product_name']) . "<p/>";
|
79
|
|
80
|
echo "<table width='100%'>";
|
81
|
|
82
|
echo "<tr><td>" . gettext("Attempting connection to") . " " . $ldapserver . "</td><td>";
|
83
|
if(ldap_test_connection($authcfg)) {
|
84
|
echo "<td><font color=green>OK</td></tr>";
|
85
|
|
86
|
echo "<tr><td>" . gettext("Attempting bind to") . " " . $ldapserver . "</td><td>";
|
87
|
if(ldap_test_bind($authcfg)) {
|
88
|
echo "<td><font color=green>OK</td></tr>";
|
89
|
|
90
|
echo "<tr><td>" . gettext("Attempting to fetch Organizational Units from") . " " . $ldapserver . "</td><td>";
|
91
|
$ous = ldap_get_user_ous(true, $authcfg);
|
92
|
if(count($ous)>1) {
|
93
|
echo "<td><font color=green>OK</td></tr>";
|
94
|
echo "</table>";
|
95
|
if(is_array($ous)) {
|
96
|
echo gettext("Organization units found") . ":<p/>";
|
97
|
echo "<table width='100%'>";
|
98
|
foreach($ous as $ou) {
|
99
|
echo "<tr><td>" . $ou . "</td></tr>";
|
100
|
}
|
101
|
}
|
102
|
} else
|
103
|
echo "<td><font color=red>" . gettext("failed") . "</td></tr>";
|
104
|
|
105
|
echo "</table><p/>";
|
106
|
|
107
|
} else {
|
108
|
echo "<td><font color=red>" . gettext("failed") . "</td></tr>";
|
109
|
echo "</table><p/>";
|
110
|
}
|
111
|
} else {
|
112
|
echo "<td><font color=red>" . gettext("failed") . "</td></tr>";
|
113
|
echo "</table><p/>";
|
114
|
}
|
115
|
}
|
116
|
|
117
|
?>
|
118
|
<p/>
|
119
|
<input type="Button" value="<?=gettext("Close"); ?>" onClick='Javascript:window.close();'>
|
120
|
|
121
|
</form>
|
122
|
</body>
|
123
|
</html>
|