Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / ldap.sync.php @ b67d8923

Historique | Voir | Annoter | Télécharger (3,74 ko)

1
<?php
2

    
3

    
4
/*
5
 * @version $Id: ldap.sync.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
        "ldap",
40
        "user",
41
        "profile","entity","group","rulesengine","rule.right"
42
);
43

    
44
define('GLPI_ROOT', '..');
45
include (GLPI_ROOT . "/inc/includes.php");
46

    
47
checkSeveralRightsAnd(array("user"=>"w", "user_auth_method"=>"w"));
48

    
49
commonHeader($LANG["setup"][3],$_SERVER['PHP_SELF'],"admin","user","ldap");
50

    
51
if (isset ($_GET['next'])) {
52
        ldapChooseDirectory($_SERVER['PHP_SELF']);
53
} else {
54
        if (isset ($_SESSION["ldap_sync"])) {
55
                if ($count = count($_SESSION["ldap_sync"])) {
56
                        $percent = min(100, round(100 * ($_SESSION["ldap_sync_count"] - $count) / $_SESSION["ldap_sync_count"], 0));
57

    
58
                        displayProgressBar(400, $percent);
59

    
60
                        $key = array_pop($_SESSION["ldap_sync"]);
61
                        ldapImportUser($key, 1);
62
                        glpi_header($_SERVER['PHP_SELF']);
63

    
64
                } else {
65
                        unset ($_SESSION["ldap_sync"]);
66
                        displayProgressBar(400, 100);
67

    
68
                        echo "<div align='center'><strong>" . $LANG["ocsng"][8] . "<br>";
69
                        echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . $LANG["buttons"][13] . "</a>";
70
                        echo "</strong></div>";
71
                }
72
        }
73

    
74
if (isset($_POST["change_ldap_filter"]))
75
{
76
        $_SESSION["ldap_filter"] = $_POST["ldap_filter"];
77
        glpi_header($_SERVER['PHP_SELF']);
78
}
79
elseif (!isset ($_POST["sync_ok"])) {
80
                if (!isset ($_GET['check']))
81
                        $_GET['check'] = 'all';
82
                if (!isset ($_GET['start']))
83
                        $_GET['start'] = 0;
84

    
85
                if (isset ($_SESSION["ldap_sync"]))
86
                        unset ($_SESSION["ldap_sync"]);
87
                        
88
                //Store in session the ldap server's id, in case of it is not already done        
89
                if (!isset ($_SESSION["ldap_server"]))
90
                        $_SESSION["ldap_server"] = $_POST["ldap_server"];
91

    
92
                //If a connection to the server can not be established, display a page with a back link
93
                if (!testLDAPConnection($_SESSION["ldap_server"])) {
94
                        unset ($_SESSION["ldap_server"]);
95
                        echo "<div align='center'><strong>" . $LANG["ldap"][6] . "<br>";
96
                        echo "<a href='" . $_SERVER['PHP_SELF'] . "?next=listservers'>" . $LANG["buttons"][13] . "</a>";
97
                        echo "</strong></div>";
98
                } else
99
                {
100
                        //Display users to synchronise
101
                        if (!isset($_SESSION["ldap_filter"]))
102
                                $_SESSION["ldap_filter"]='';
103
                                
104
                        showLdapUsers($_SERVER['PHP_SELF'], $_GET['check'], $_GET['start'], 1,$_SESSION["ldap_filter"]);
105
                }
106
        } else {
107

    
108
                if (count($_POST['tosync']) > 0) {
109
                        $_SESSION["ldap_sync_count"] = 0;
110
                        foreach ($_POST['tosync'] as $key => $val) {
111
                                if ($val == "on") {
112
                                        $_SESSION["ldap_sync"][] = $key;
113
                                        $_SESSION["ldap_sync_count"]++;
114
                                }
115
                        }
116
                }
117

    
118
                glpi_header($_SERVER['PHP_SELF']);
119
        }
120
}
121

    
122
commonFooter();
123
?>
Redmine Appliance - Powered by TurnKey Linux