Files
lootjes/includes/ldap.php
2025-11-12 10:17:30 +01:00

24 lines
540 B
PHP

<?php
function ldap_authenticate($username, $password)
{
$config = require __DIR__ . '/../config/config.php';
$ldapconn = ldap_connect($config['ldap']['server']);
if (!$ldapconn) {
return false;
}
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
$bind_dn = "uid={$username},{$config['ldap']['user_dn']}";
if (@ldap_bind($ldapconn, $bind_dn, $password)) {
ldap_unbind($ldapconn);
return true;
}
return false;
}