Got the solution
I found another way, which is not a fully protected one, but suits a little to my requirement.
function check_passwd($password){
$SearchFor=$this->username;
$SearchField="samaccountname";
$check=$this->username;
$LDAPHost = "ldap://ldap.com";
$dn = "DC=ldap,DC=coml";
$LDAPUserDomain = "@ldap.com";
$LDAPUser = "administrator";
$LDAPUserPassword = "password";
$LDAPFieldsToFind = array("cn", "givenname", "samaccountname","userAccountControl");
$cnx = ldap_connect($LDAPHost) or die("Could not connect to LDAP");
ldap_set_option($cnx, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($cnx, LDAP_OPT_REFERRALS, 0);
ldap_bind($cnx,$LDAPUser.$LDAPUserDomain,$LDAPUserPassword) or die("Could not bind to LDAP");
error_reporting (E_ALL ^ E_NOTICE);
$filter="($SearchField=$SearchFor)";
//echo $filter;
$sr=ldap_search($cnx, $dn, $filter, $LDAPFieldsToFind);
$info = ldap_get_entries($cnx, $sr);
for ($x=0; $x
$sam=$info;
$e=$info;
}
if(($check==$sam)&&($e!=514)){
return (TRUE);
}
else{
if($e!=512){
echo "you are disabled in AD";
}
return (FALSE);
//return (strlen($this->passwd) && strcmp($this->passwd, MD5($password))==0)?(TRUE):(FALSE);
}
}
This code actually works, and the authentication i used, is the user should exist in the ADS and he should be enabled.