diff --git a/include/functions.inc b/include/functions.inc
index 8da921a7bba6c23c87ce6c7de905e140ce6a8969..d628de47a0033dcd92f7e7f1376d9a0c7bf9f2f7 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
exit();
}
$ldap->cd($config->current['BASE']);
exit();
}
$ldap->cd($config->current['BASE']);
- $ldap->search("(&(uid=$username)(objectClass=gosaAccount))", array("uid"));
+ $allowed_attributes = array("uid","mail");
+ $verify_attr = array();
+ if(isset($config->current['LOGIN_ATTRIBUTE'])){
+ $tmp = split(",",$config->current['LOGIN_ATTRIBUTE']);
+ foreach($tmp as $attr){
+ if(in_array($attr,$allowed_attributes)){
+ $verify_attr[] = $attr;
+ }
+ }
+ }
+ if(count($verify_attr) == 0){
+ $verify_attr = array("uid");
+ }
+ $tmp= $verify_attr;
+ $tmp[] = "uid";
+ $filter = "";
+ foreach($verify_attr as $attr) {
+ $filter.= "(".$attr."=".$username.")";
+ }
+ $filter = "(&(|".$filter.")(objectClass=gosaAccount))";
+ $ldap->search($filter,$tmp);
/* get results, only a count of 1 is valid */
switch ($ldap->count()){
/* get results, only a count of 1 is valid */
switch ($ldap->count()){
/* LDAP schema is not case sensitive. Perform additional check. */
$attrs= $ldap->fetch();
/* LDAP schema is not case sensitive. Perform additional check. */
$attrs= $ldap->fetch();
- if ($attrs['uid'][0] != $username){
- return(NULL);
+ $success = FALSE;
+ foreach($verify_attr as $attr){
+ if ($attrs[$attr][0] == $username){
+ $success = TRUE;
+ }
+ }
+ if(!$success){
+ return(FALSE);
}
/* got user dn, fill acl's */
$ui= new userinfo($config, $ldap->getDN());
}
/* got user dn, fill acl's */
$ui= new userinfo($config, $ldap->getDN());
- $ui->username= $username;
+ $ui->username= $attrs['uid'][0];
/* password check, bind as user with supplied password */
$ldap->disconnect();
/* password check, bind as user with supplied password */
$ldap->disconnect();
return preg_match ("/^[\/0-9 ()+*-]+$/", $nr);
}
return preg_match ("/^[\/0-9 ()+*-]+$/", $nr);
}
+function is_dns_name($str)
+{
+ return(preg_match("/^[a-z0-9\.\-]*$/i",$str));
+}
function is_url($url)
{
function is_url($url)
{
$remove= false;
/* Save variables from LOCK_VARS_TO_USE in session - for further editing */
$remove= false;
/* Save variables from LOCK_VARS_TO_USE in session - for further editing */
- if( is_global(LOCK_VARS_TO_USE) && count(get_global('LOCK_VARS_TO_USE'))){
+ if( is_global('LOCK_VARS_TO_USE') && count(get_global('LOCK_VARS_TO_USE'))){
$LOCK_VARS_USED = array();
$LOCK_VARS_TO_USE = get_global('LOCK_VARS_TO_USE');
$LOCK_VARS_USED = array();
$LOCK_VARS_TO_USE = get_global('LOCK_VARS_TO_USE');
$deactivated = FALSE;
}
$deactivated = FALSE;
}
- // Detect the encryption Method
+ /* Is ensure that clear passwords will stay clear */
+ if($hash == "" && isset($attrs['userPassword'][0]) && !preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0])){
+ $hash = "clear";
+ }
+
+ // Detect the encryption Method
if ( (isset($attrs['userPassword'][0]) && preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0], $matches)) || $hash != ""){
/* Check for supported algorithm */
if ( (isset($attrs['userPassword'][0]) && preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0], $matches)) || $hash != ""){
/* Check for supported algorithm */