Allow the filterUser to be specified with or without brackets around it.

This commit is contained in:
Andrew Ruthven 2007-10-17 11:58:30 +13:00 committed by Andrew Ruthven
parent 3084924a80
commit 6c872407f7

View File

@ -153,7 +153,17 @@ function LDAP_check($username, $password ){
if ( $ldapDriver->valid ) {
$mapping = $c->authenticate_hook['config']['mapping_field'];
$attributs=array_values($mapping);
$filter="(& $ldapDriver->filterUsers (".$mapping["username"]."=$username))";
// If the config contains a filter that starts with a ( then believe
// them and don't modify it, otherwise wrap the filter.
$filter_munge = "";
if ( preg_match( '/^\(/', $ldapDriver->filterUsers ) ) {
$filter_munge = $ldapDriver->filterUsers;
} else {
$filter_munge = "($ldapDriver->filterUsers)";
}
$filter="(&$filter_munge(".$mapping["username"]."=$username))";
dbg_error_log( "LDAP", "checking user %s for password %s against LDAP",$username,$password );
$valid = $ldapDriver->requestUser($filter,$attributs,$password);