diff --git a/include/functions.inc b/include/functions.inc
index 39fc85b6697e6c37b6bb4e8b7b0bb5f1a3719d39..dab51ac86293bab88091b538684027e73d23b5a0 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
echo "<body>".$_SESSION['errors']."</body></html>";
exit();
}
+
+ /* Check if mail address is also a valid auth name */
+ $auth_mail = FALSE;
+ if(isset($config->current['AUTH_MAIL']) && preg_match("/^true$/i",$config->current['AUTH_MAIL'])){
+ $auth_mail = TRUE;
+ }
+
$ldap->cd($config->current['BASE']);
- $ldap->search("(&(uid=$username)(objectClass=gosaAccount))", array("uid"));
+ if(!$auth_mail){
+ $ldap->search("(&(uid=$username)(objectClass=gosaAccount))", array("uid"));
+ }else{
+ $ldap->search("(&(|(uid=".$username.")(mail=".$username."))(objectClass=gosaAccount))", array("uid","mail"));
+ }
/* get results, only a count of 1 is valid */
switch ($ldap->count()){
/* LDAP schema is not case sensitive. Perform additional check. */
$attrs= $ldap->fetch();
- if ($attrs['uid'][0] != $username){
- return(NULL);
+ if($auth_mail){
+ if ($attrs['uid'][0] != $username && strcasecmp($attrs['mail'][0], $username) != 0){
+ return(NULL);
+ }
+ }else{
+ if ($attrs['uid'][0] != $username){
+ return(NULL);
+ }
}
/* 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();
global $ui, $config;
/* Check for strict tagging */
+ $ttag= "";
if ($checkTag && isset($config->current['STRICT_UNITS']) &&
preg_match('/^(yes|true)$/i', $config->current['STRICT_UNITS']) &&
$ui->gosaUnitTag != ""){
return preg_match ("/^[\/0-9 ()+*-]+$/", $nr);
}
+function is_dns_name($str)
+{
+ return(preg_match("/^[a-z0-9\.\-]*$/i",$str));
+}
function is_url($url)
{