diff --git a/lib/private/user.php b/lib/private/user.php
index f15fdf1dbbcc21c2548d2def91c3dc7ba81eb062..5bd36006750f98867c849d0ad1329598b6e37a61 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -54,6 +54,9 @@ class OC_User {
 
 	private static $_setupedBackends = array();
 
+	// bool, stores if a user want to access a resource anonymously, e.g if he opens a public link
+	private static $incognitoMode = false;
+
 	/**
 	 * @brief registers backend
 	 * @param string $backend name of the backend
@@ -319,6 +322,15 @@ class OC_User {
 		return false;
 	}
 
+	/**
+	 * @brief set incognito mode, e.g. if a user wants to open a public link
+	 * @param bool $status
+	 */
+	public static function setIncognitoMode($status) {
+		self::$incognitoMode = $status;
+
+	}
+
 	/**
 	 * Supplies an attribute to the logout hyperlink. The default behaviour
 	 * is to return an href with '?logout=true' appended. However, it can
@@ -354,7 +366,7 @@ class OC_User {
 	 */
 	public static function getUser() {
 		$uid = OC::$session ? OC::$session->get('user_id') : null;
-		if (!is_null($uid)) {
+		if (!is_null($uid) && self::$incognitoMode === false) {
 			return $uid;
 		} else {
 			return false;