<?php
function authenticate($user, $password) {
include("ldap.php");
$ldap_user_group = "Voodoo";
$ldap = ldap_connect($LDAPHost) or die("Could not connect to LDAP");
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
if($bind = @ldap_bind($ldap, $user . $LDAPUserDomain, $password)) {
$filter = "(sAMAccountName=" . $user . ")";
$attr = array("memberof");
$result = ldap_search($ldap, $dn, $filter, $attr);
$entries = ldap_get_entries($ldap, $result);
ldap_unbind($ldap);
foreach($entries[0]['memberof'] as $grps) {
if (strpos($grps, $ldap_user_group)) $access = 1;
}
if ($access != 0) {
$_SESSION['user'] = $user;
$_SESSION['access'] = $access;
return true;
} else {
return false;
}
} else {
return false;
}
}
?>