diff --git a/controllers/matrix_chat.php b/controllers/matrix_chat.php
index 112ff01599fcc7ab3a9ff264783f02a96fc5579a..dbbb664f3079427f40dce953ab2d59f772a3c1fd 100644
--- a/controllers/matrix_chat.php
+++ b/controllers/matrix_chat.php
@@ -42,6 +42,13 @@ class MatrixChatController extends AuthenticatedController
 
         // Check if current user has a Matrix account.
         $this->account = MatrixAccount::find(User::findCurrent()->id);
+
+        // If no account is found, try to search in Matrix user directory.
+        $found = MatrixClient::get()->searchUsers(
+            MatrixAccount::requireSystemAccount(), '@studip_test1:', 1);
+
+        PageLayout::postInfo('<pre>' . print_r($found, 1) . '</pre>');
+
         $this->no_account_wanted = UserConfig::get(User::findCurrent()->id)->MATRIX_NO_ACCOUNT_WANTED;
 
         if ($this->account) {
diff --git a/migrations/20210519_init_matrix_chat.php b/migrations/20210519_init_matrix_chat.php
index 4ad10fdfc1829f70b89fed463a252f20c5681541..47381a3cf1e4ab252df955c6628a1b9d95e56d8a 100644
--- a/migrations/20210519_init_matrix_chat.php
+++ b/migrations/20210519_init_matrix_chat.php
@@ -76,6 +76,14 @@ class InitMatrixChat extends Migration
                 'range' => 'global',
                 'section' => 'matrix',
                 'description' => 'URL des Chatservers (z.B. Element)'
+            ],
+            'AUTO_CREATE_ACCOUNTS' => [
+                'value' => false,
+                'type' => 'bool',
+                'range' => 'global',
+                'section' => 'matrix',
+                'description' => 'Soll automatisch versucht werden, Matrixaccounts anzulegen? Andernfalls wird ' .
+                    'ein Link zum Chatserver angezeigt.'
             ]
         ];
 
diff --git a/models/MatrixClient.php b/models/MatrixClient.php
index ceddde46b07f68ef489257a4b4e9d831e976eccb..881d8653253d27d56d242cd094ae06da151a3f0e 100644
--- a/models/MatrixClient.php
+++ b/models/MatrixClient.php
@@ -29,7 +29,10 @@ class MatrixClient
     public static function get()
     {
         if (is_null(MatrixClient::$client)) {
-            MatrixClient::$client = new Patrix\MatrixClient(Config::get()->MATRIX_SERVER_HOSTNAME);
+            MatrixClient::$client = new Patrix\MatrixClient(
+                Config::get()->MATRIX_SERVER_HOSTNAME,
+                'https://' . Config::get()->MATRIX_SERVER_HOSTNAME
+            );
         }
 
         return MatrixClient::$client;