ryxeo-glpi-git / front / setup.auth.php @ b67d8923
Historique | Voir | Annoter | Télécharger (5,36 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | |||
3 | |||
4 | /*
|
||
5 | * @version $Id: setup.auth.php 7763 2009-01-06 18:44:50Z moyo $
|
||
6 | -------------------------------------------------------------------------
|
||
7 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
8 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
9 | |||
10 | http://indepnet.net/ http://glpi-project.org
|
||
11 | -------------------------------------------------------------------------
|
||
12 | |||
13 | LICENSE
|
||
14 | |||
15 | This file is part of GLPI.
|
||
16 | |||
17 | GLPI is free software; you can redistribute it and/or modify
|
||
18 | it under the terms of the GNU General Public License as published by
|
||
19 | the Free Software Foundation; either version 2 of the License, or
|
||
20 | (at your option) any later version.
|
||
21 | |||
22 | GLPI is distributed in the hope that it will be useful,
|
||
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
25 | GNU General Public License for more details.
|
||
26 | |||
27 | You should have received a copy of the GNU General Public License
|
||
28 | along with GLPI; if not, write to the Free Software
|
||
29 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
30 | --------------------------------------------------------------------------
|
||
31 | */
|
||
32 | |||
33 | // ----------------------------------------------------------------------
|
||
34 | // Original Author of file:
|
||
35 | // Purpose of file:
|
||
36 | // ----------------------------------------------------------------------
|
||
37 | |||
38 | $NEEDED_ITEMS = array ( |
||
39 | "setup",
|
||
40 | "auth",
|
||
41 | "ldap",
|
||
42 | "user"
|
||
43 | ); |
||
44 | |||
45 | define('GLPI_ROOT', '..'); |
||
46 | include (GLPI_ROOT . "/inc/includes.php"); |
||
47 | |||
48 | checkRight("config", "w"); |
||
49 | $config = new Config(); |
||
50 | $config_mail = new AuthMail(); |
||
51 | $config_ldap = new AuthLDAP(); |
||
52 | |||
53 | //Update CAS configuration
|
||
54 | if (isset ($_POST["update"])) { |
||
55 | $config->update($_POST); |
||
56 | glpi_header($CFG_GLPI["root_doc"] . "/front/setup.auth.php"); |
||
57 | } |
||
58 | //IMAP/POP Server add/update/delete
|
||
59 | elseif (isset ($_POST["update_mail"])) { |
||
60 | $config_mail->update($_POST); |
||
61 | glpi_header($_SERVER['HTTP_REFERER']); |
||
62 | } |
||
63 | elseif (isset ($_POST["add_mail"])) { |
||
64 | //If no name has been given to this configuration, then go back to the page without adding
|
||
65 | if ($_POST["name"] != ""){ |
||
66 | if ($newID=$config_mail->add($_POST)){ |
||
67 | glpi_header($CFG_GLPI["root_doc"] . "/front/setup.auth.php?next=extauth_mail&ID=".$newID); |
||
68 | } |
||
69 | } |
||
70 | glpi_header($_SERVER['HTTP_REFERER']); |
||
71 | } |
||
72 | elseif (isset ($_POST["delete_mail"])) { |
||
73 | $config_mail->delete($_POST); |
||
74 | glpi_header($CFG_GLPI["root_doc"] . "/front/setup.auth.php?onglet=2"); |
||
75 | } |
||
76 | |||
77 | //LDAP Server add/update/delete
|
||
78 | elseif (isset ($_POST["update_ldap"])) { |
||
79 | $config_ldap->update($_POST); |
||
80 | glpi_header($_SERVER['HTTP_REFERER']); |
||
81 | } |
||
82 | elseif (isset ($_POST["add_ldap"])) { |
||
83 | //If no name has been given to this configuration, then go back to the page without adding
|
||
84 | if ($_POST["name"] != ""){ |
||
85 | if ($newID=$config_ldap->add($_POST)){ |
||
86 | if (testLDAPConnection($newID)){ |
||
87 | addMessageAfterRedirect($LANG["login"][22]); |
||
88 | } else{
|
||
89 | addMessageAfterRedirect($LANG["login"][23]); |
||
90 | } |
||
91 | glpi_header($CFG_GLPI["root_doc"] . "/front/setup.auth.php?next=extauth_ldap&ID=".$newID); |
||
92 | } |
||
93 | } |
||
94 | glpi_header($_SERVER['HTTP_REFERER']); |
||
95 | } |
||
96 | elseif (isset ($_POST["delete_ldap"])) { |
||
97 | $config_ldap->delete($_POST); |
||
98 | glpi_header($CFG_GLPI["root_doc"] . "/front/setup.auth.php?onglet=1"); |
||
99 | } |
||
100 | elseif (isset ($_POST["test_ldap"])) { |
||
101 | $ldap = new AuthLDAP; |
||
102 | $ldap->getFromDB($_POST["ID"]); |
||
103 | |||
104 | if (testLDAPConnection($_POST["ID"])){ |
||
105 | $_SESSION["LDAP_TEST_MESSAGE"]=$LANG["login"][22]." (".$LANG["ldap"][21]." : ".$ldap->fields["name"].")";; |
||
106 | } else{
|
||
107 | $_SESSION["LDAP_TEST_MESSAGE"]=$LANG["login"][23]." (".$LANG["ldap"][21]." : ".$ldap->fields["name"].")";; |
||
108 | } |
||
109 | glpi_header($_SERVER['HTTP_REFERER']); |
||
110 | } |
||
111 | elseif (isset ($_POST["test_ldap_replicate"])) { |
||
112 | foreach($_POST["test_ldap_replicate"] as $replicate_id => $value) |
||
113 | { |
||
114 | $replicate = new AuthLdapReplicate; |
||
115 | $replicate->getFromDB($replicate_id); |
||
116 | |||
117 | if (testLDAPConnection($_POST["ID"],$replicate_id)){ |
||
118 | $_SESSION["LDAP_TEST_MESSAGE"]=$LANG["login"][22]." (".$LANG["ldap"][19]." : ".$replicate->fields["name"].")"; |
||
119 | } else{
|
||
120 | $_SESSION["LDAP_TEST_MESSAGE"]=$LANG["login"][23]." (".$LANG["ldap"][19]." : ".$replicate->fields["name"].")"; |
||
121 | } |
||
122 | } |
||
123 | glpi_header($_SERVER['HTTP_REFERER']); |
||
124 | }elseif (isset ($_POST["test_mail"])) { |
||
125 | |||
126 | if (test_auth_mail($_POST["imap_string"],$_POST["imap_login"],$_POST["imap_password"])){ |
||
127 | addMessageAfterRedirect($LANG["login"][22]); |
||
128 | } else {
|
||
129 | addMessageAfterRedirect($LANG["login"][23]); |
||
130 | } |
||
131 | glpi_header($_SERVER['HTTP_REFERER']); |
||
132 | } |
||
133 | elseif (isset($_POST["delete_replicate"])) |
||
134 | { |
||
135 | $replicate = new AuthLdapReplicate; |
||
136 | foreach ($_POST["item"] as $index=>$val) |
||
137 | $replicate->delete(array("ID"=>$index)); |
||
138 | glpi_header($_SERVER['HTTP_REFERER']); |
||
139 | } |
||
140 | elseif (isset($_POST["add_replicate"])) |
||
141 | { |
||
142 | $replicate = new AuthLdapReplicate; |
||
143 | unset($_POST["next"]); |
||
144 | unset($_POST["ID"]); |
||
145 | $replicate->add($_POST); |
||
146 | glpi_header($_SERVER['HTTP_REFERER']); |
||
147 | } |
||
148 | |||
149 | if (!isset ($_SESSION['glpi_authconfig'])){ |
||
150 | $_SESSION['glpi_authconfig'] = 1; |
||
151 | } |
||
152 | if (isset ($_GET['onglet'])){ |
||
153 | $_SESSION['glpi_authconfig'] = $_GET['onglet']; |
||
154 | } |
||
155 | |||
156 | if (!isset($_GET["next"])){ |
||
157 | $_GET["next"] = ''; |
||
158 | } |
||
159 | if (!isset($_GET["ID"])){ |
||
160 | $_GET["ID"]=""; |
||
161 | } |
||
162 | commonHeader($LANG["title"][14], $_SERVER['PHP_SELF'],"config","extauth",$_SESSION['glpi_authconfig']); |
||
163 | switch ($_GET["next"]) { |
||
164 | case "extauth_mail" : |
||
165 | $config_mail->showForm($_SERVER['PHP_SELF'], $_GET["ID"]); |
||
166 | break;
|
||
167 | case "extauth_ldap" : |
||
168 | $config_ldap->showForm($_SERVER['PHP_SELF'], $_GET["ID"]); |
||
169 | break;
|
||
170 | default :
|
||
171 | showFormExtAuthList($_SERVER['PHP_SELF']); |
||
172 | break;
|
||
173 | } |
||
174 | |||
175 | commonFooter(); |
||
176 | ?> |