-
Notifications
You must be signed in to change notification settings - Fork 2
/
passwd_change.php
32 lines (25 loc) · 1007 Bytes
/
passwd_change.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
<?php require_once("app.php");
$auth = new Authenticator();
$auth->requireAuthenticatedUser();
$uid = $_SESSION["uid"];
$password = $_REQUEST["old"];
//check login
try {
$user_ldap = new Ldap("uid=" . $uid . "," . LdapInfo::base_dn, $password);
} catch (ErrorException $e) {
//wrong login
die(header("Location: ./passwd_done.php?status=loginFailed"));
}
if ( $_REQUEST["new"] !== $_REQUEST["new_confirm"] ) {
die("Your new password fields didn't match and I'm too lazy to make a proper error message.");
}
if ( $_REQUEST["new"] == "" ) {
die("Not only did you not enter a password, you didn't enter a password and then you didn't enter it again. Well done.");
}
//HACK to make LDAP password changeable - users can't change their own passwords atm
//using global admin ldap
$ldap->changePassword($uid,$_REQUEST["new"]);
die(header("Location: ./passwd_done.php?status=success"));
//if we made it here something crazy is going on
die(header("Location: ./passwd_done.php?status=unknownError"));
?>