1e versie
This commit is contained in:
23
includes/ldap.php
Normal file
23
includes/ldap.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user