Add option to add passwords unencrypted/unhashed
Apparently required for UnboundId
diff --git a/config.php.example b/config.php.example
index ebb0e67..32c9488 100755
--- a/config.php.example
+++ b/config.php.example
@@ -11,6 +11,7 @@
$USER = "admin";
$PASSWORD = "myldappassword";
$BASE_DN = 'cn={},ou=organization,dc=example,dc=com';
+$ENCRYPT_PASSWORDS = false;
// Redis password
$REDIS_PASS = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
diff --git a/ldap.php b/ldap.php
index 1633eb9..e24fe8c 100755
--- a/ldap.php
+++ b/ldap.php
@@ -27,8 +27,14 @@
$this->first_name = $first_name;
$this->last_name = $last_name;
$this->email = $email;
- $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
+ if ($ENCRYPT_PASSWORDS) {
+ $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
+ # $this->user_hash = "{SHA}" . base64_encode(sha1($password, true));
+ } else {
+ $this->user_hash = "{CLEAR}" . $password;
+ }
$this->password = $this->user_hash;
+
}
}
@@ -145,8 +151,12 @@
}
$dn = $data[0]["dn"];
- $newEntry = ['userPassword' => "{crypt}" . crypt($new_password, '$6$' . generateSalt(10) . '$')];
-
+ if ($ENCRYPT_PASSWORDS) {
+ $newEntry = ['userPassword' => "{crypt}" . crypt($new_password, '$6$' . generateSalt(10) . '$')];
+ # $newEntry = ['userPassword' => "{SHA}" . base64_encode(sha1($new_password, true))];
+ } else {
+ $newEntry = ['userPassword' => "{CLEAR}" . $new_password];
+ }
if (ldap_mod_replace($connect, $dn, $newEntry))
return true;
else