As I needed LDAP-Logon for our Hesk-Admins I figured out how to implement this easily and so I wanted to share this to everybody else.
Maybe Klemen can use it to adopt it to the next version (with a checkbox in the admin-settings to enable or disable LDAP)…
What the code does:
The given username and password is verified with LDAP and if it fits you’re logged on. Otherwise the credentials are checked against the local Hesk-Database.
To implement copy the following lines to hesk\admin\index.php (below line 178):
Code: Select all
/////////////////////////////////////////////////
// *** Parameter for LDAP-Check ***
$ldap_server = "ldap://192.168.0.1";
$auth_dc = "@yourdomain.com";
$auth_user_full = $user.$auth_dc;
$errorcode = "";
if ($connect=@ldap_connect($ldap_server)) {
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
if ($bind=@ldap_bind($connect, $auth_user_full, $pass)) {
//echo "Right password!";
}
else {
//echo "Wrong password!";
$errorcode = "wrong_ldap_pass__try_local_DB_pass";
}
}
else {
echo "No connection to LDAP-Server possible.";
}
////////////////////////////////////////////////
if ($errorcode == "wrong_ldap_pass__try_local_DB_pass"){
I hope this helps somebody else to save some time!