diff --git a/lib/base.php b/lib/base.php
index f0a0b94a41f7d3239e3020cd7492cacf3f47a30e..56061ba53b3176654776354420048748f605d527 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -756,14 +756,17 @@ class OC {
 	protected static function handleLogin() {
 		OC_App::loadApps(array('prelogin'));
 		$error = array();
-		if (OC::tryApacheAuth()) {
 
+		// auth possible via apache module?
+		if (OC::tryApacheAuth()) {
+			$error[] = 'apacheauthfailed';
 		}
 		// remember was checked after last login
 		elseif (OC::tryRememberLogin()) {
 			$error[] = 'invalidcookie';
-			// Someone wants to log in :
-		} elseif (OC::tryFormLogin()) {
+		}
+		// Someone wants to log in :
+		elseif (OC::tryFormLogin()) {
 			$error[] = 'invalidpassword';
 		}
 
@@ -782,7 +785,17 @@ class OC {
 	}
 
 	protected static function tryApacheAuth() {
-		return OC_User::handleApacheAuth(false);
+		$return = OC_User::handleApacheAuth();
+
+		// if return is true we are logged in -> redirect to the default page
+		if ($return === true) {
+			$_REQUEST['redirect_url'] = \OC_Request::requestUri();
+			OC_Util::redirectToDefaultPage();
+			exit;
+		}
+
+		// in case $return is null apache based auth is not enabled
+		return is_null($return) ? false : true;
 	}
 
 	protected static function tryRememberLogin() {
diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php
index 9b5663998ffc360ce46ed9a1c7c65ea64ba73657..d2fd74c44f9f2a00f53610ad316d2ecc28379a6f 100644
--- a/lib/private/connector/sabre/auth.php
+++ b/lib/private/connector/sabre/auth.php
@@ -72,7 +72,8 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
 	  * @return bool
 	  */
 	public function authenticate(Sabre_DAV_Server $server, $realm) {
-		if (OC_User::handleApacheAuth(true)) {
+
+		if (OC_User::handleApacheAuth()) {
 		    return true;
 		}
 
diff --git a/lib/private/user.php b/lib/private/user.php
index a4ad3278142008074869be6fd5828984c1411f19..90060cb33d8e6ec636007a548cf858371e7fdf83 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -237,12 +237,10 @@ class OC_User {
 
 	/**
 	 * @brief Verify with Apache whether user is authenticated.
-	 * @note Currently supports only Shibboleth.
 	 *
-	 * @param $isWebdav Is this request done using webdav.
-	 * @return true: authenticated - false: not authenticated
+	 * @return boolean|null true: authenticated - false: not authenticated
 	 */
-	public static function handleApacheAuth($isWebdav = false) {
+	public static function handleApacheAuth() {
 		foreach (self::$_usedBackends as $backend) {
 			if ($backend instanceof OCP\ApacheBackend) {
 				if ($backend->isSessionActive()) {
@@ -252,21 +250,12 @@ class OC_User {
 					self::setupBackends();
 					self::unsetMagicInCookie();
 
-					if (self::loginWithApache($backend)) {
-						if (! $isWebdav) {
-							$_REQUEST['redirect_url'] = \OC_Request::requestUri();
-							OC_Util::redirectToDefaultPage();
-							return true;
-						}
-						else {
-							return true;
-						}
-					}
+					return self::loginWithApache($backend);
 				}
 			}
 		}
 
-		return false;
+		return null;
 	}