From b9abfc2d9826111fae9c2d435dc8428838cd43fc Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Fri, 23 Nov 2012 19:22:20 +0100 Subject: [PATCH] Fixed issue #6938: Web server auth doesn't work - patch by pfpDave --- application/core/UserIdentity.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/application/core/UserIdentity.php b/application/core/UserIdentity.php index d301728ed5c..8425b99ae29 100644 --- a/application/core/UserIdentity.php +++ b/application/core/UserIdentity.php @@ -27,7 +27,7 @@ class UserIdentity extends CUserIdentity */ public function authenticate($sOneTimePassword='') { - if (Yii::app()->getConfig("auth_webserver")==false) + if (Yii::app()->getConfig("auth_webserver")==false || $this->username != "") { $user = User::model()->findByAttributes(array('users_name' => $this->username)); @@ -67,9 +67,14 @@ public function authenticate($sOneTimePassword='') $this->errorCode = self::ERROR_NONE; } } - elseif(Yii::app()->getConfig("auth_webserver") === true && isset($_SERVER['PHP_AUTH_USER'])) // normal login through webserver authentication + elseif(Yii::app()->getConfig("auth_webserver") === true && (isset($_SERVER['PHP_AUTH_USER'])||isset($_SERVER['LOGON_USER']))) // normal login through webserver authentication { - $sUser=$_SERVER['PHP_AUTH_USER']; + if (isset($_SERVER['PHP_AUTH_USER'])) { + $sUser=$_SERVER['PHP_AUTH_USER']; + } else { + $sUser = $_SERVER['LOGON_USER']; + $sUser = substr($sUser, strrpos($sUser, "\\")+1); + } $aUserMappings=Yii::app()->getConfig("auth_webserver_user_map"); if (isset($aUserMappings[$sUser])) $sUser= $aUserMappings[$sUser]; @@ -85,6 +90,10 @@ public function authenticate($sOneTimePassword='') elseif (Yii::app()->getConfig("auth_webserver_autocreate_user")) { $aUserProfile=Yii::app()->getConfig("auth_webserver_autocreate_profile"); + } else { + $this->id = $oUser->uid; + $this->user = $oUser; + $this->errorCode = self::ERROR_NONE; } }