-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlemonldap.class.php
94 lines (76 loc) · 2.82 KB
/
lemonldap.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* LemonLDAP authentication backend
* Inspired from CAS authentication by Andreas Gohr <[email protected]>,
* Christopher Smith <[email protected]>
* and Cedric Puig <[email protected]>
* LemonLDAP only provides authentication mechanism
* User data mechanism must be provided in an other module (lemonldapsuserdatabackend.class.php)
* At this time only plain text mechanism is provided
*
*
* The LemonLDAP server returns a username, and then auth_lemonldap uses
* the userDataBackend to match this username with his
* informations.
*
* Thanks to Thomas Chemineau [email protected]
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Erwan Le Gall [email protected]
* @date 16/07/08
*/
define('DOKU_AUTH', dirname(__FILE__));
require_once(DOKU_AUTH.'/lemonldapuserdatabackend.class.php');
require_once(DOKU_AUTH.'/basic.class.php');
class auth_lemonldap extends auth_basic {
var $lemon = null;
var $userDataBackend = null;
public function auth_lemonldap() {
global $conf;
$this->userDataBackend = new lemonldapUserDataBackend();
foreach($this->userDataBackend->cando as $key => $value)
$this->cando[$key] = $value;
$this->cando['external'] = true;
$this->cando['logoff'] = true;
}
public function logOff(){
setcookie(DokuWiki, 'FALSE', time() - 600000, '/');
// Head the Lemon Logout page
$location = array();
if ( preg_match("#https?://[^/]*#", $_SERVER["HTTP_REFERER"], $location)) {
header('Location: '.$location[0].'/logout');
} else {
nice_die("Disconnection failed");
}
}
public function trustExternal($user,$pass,$sticky=false){
global $USERINFO;
$username = $_SERVER{HTTP_REMOTE_USER};
$USERINFO = $this->userDataBackend->getUserData($username);
$success = $USERINFO !== false;
if ($success) {
$_SERVER['REMOTE_USER'] = $username;
$_SESSION[DOKU_COOKIE]['auth']['user'] = $username;
$_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
}
return $success;
}
public function getUserData($user) {
return $this->userDataBackend->getUserData($user);
}
public function getUserCount($filter=array()) {
return $this->userDataBackend->getUserCount($filter);
}
public function retrieveUsers($start=0, $limit=-1, $filter=array()) {
return $this->userDataBackend->retrieveUsers($start, $limit, $filter);
}
public function createUser($user, $pass, $name, $mail, $grps=null) {
return $this->userDataBackend->createUser($user,$pass,$name,$mail,$grps);
}
public function modifyUser($user, $changes) {
return $this->userDataBackend->modifyUser($user, $changes);
}
public function deleteUsers($users) {
return $this->userDataBackend->deleteUsers($users);
}
}