diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index 7929394893b2..7d48bdd23ed4 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -382,8 +382,14 @@ public function getDisplayName($uid) {
 			}
 
 			$user = $this->access->userManager->get($uid);
-			$displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
-			$this->access->connection->writeToCache($cacheKey, $displayName);
+			if ($user instanceof User) {
+				$displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
+				$this->access->connection->writeToCache($cacheKey, $displayName);
+			}
+			if ($user instanceof OfflineUser) {
+				/** @var OfflineUser $user*/
+				$displayName = $user->getDisplayName();
+			}
 			return $displayName;
 		}