diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
index a13cc30aa2e1d4f301a8ac50cf269762dcb20539..d42fb085c42f50ca036de3d2b60c3b0cad9a0a0c 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
@@ -58,7 +58,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
     private final PluginTaskProviders pluginTaskParameters;
 
     private String cifexAdminUserOrNull;
-    
+
     private String cifexAdminPasswordOrNull;
 
     private File storeRoot;
@@ -66,7 +66,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
     private File commandQueueDirOrNull;
 
     private IDataSetCommandExecutor commandExecuter;
-    
+
     public DataStoreService(SessionTokenManager sessionTokenManager,
             MailClientParameters mailClientParameters, PluginTaskProviders pluginTaskParameters)
     {
@@ -194,9 +194,10 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
         ICIFEXComponent cifex = serviceFactory.createCIFEXComponent();
         String userID = context.getUserID();
         String password = context.getPassword();
-        if (cifex.login(userID, password) == null)
+        if (UploadingCommand.canLoginToCIFEX(cifex, context.isUserAuthenticated(), userID,
+                password, cifexAdminUserOrNull, cifexAdminPasswordOrNull) == false)
         {
-            throw new InvalidSessionException("User couldn't be authenticated at CIFEX.");
+            throw new InvalidSessionException("User failed to be authenticated by CIFEX.");
         }
         commandExecuter.scheduleUploadingDataSetsToCIFEX(serviceFactory, mailClientParameters,
                 dataSets, context, cifexAdminUserOrNull, cifexAdminPasswordOrNull);
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
index 745af2257fb3121a12639ef2548016dcd56dfbd7..ff2efa703cde49dcc6c4632dccef9f9f4e317320 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
@@ -326,20 +326,55 @@ class UploadingCommand implements IDataSetCommand
     }
 
     private String getCIFEXSession(ICIFEXComponent cifex)
+    {
+        return getCIFEXSession(cifex, userAuthenticated, userID, password, cifexAdminUserOrNull,
+                cifexAdminPasswordOrNull);
+    }
+
+    private static String getCIFEXSession(ICIFEXComponent cifex, boolean userAuthenticated,
+            String userID, String password, String cifexAdminUserOrNull,
+            String cifexAdminPasswordOrNull)
     {
         if (userAuthenticated && StringUtils.isBlank(password)
                 && StringUtils.isNotBlank(cifexAdminUserOrNull)
                 && StringUtils.isNotBlank(cifexAdminPasswordOrNull))
         {
             final String token = cifex.login(cifexAdminUserOrNull, cifexAdminPasswordOrNull);
+            if (operationLog.isDebugEnabled())
+            {
+                operationLog.debug(String.format(
+                        "Calling setSessionUser() on CIFEX session to userID=%s", userID));
+            }
             cifex.setSessionUser(token, userID);
             return token;
         } else
         {
+            if (operationLog.isDebugEnabled())
+            {
+                operationLog.debug(String.format("Directly logging into CIFEX as userID=%s "
+                        + "(user authenticated=%s, password provided=%s", userID,
+                        userAuthenticated, StringUtils.isNotBlank(password)));
+            }
             return cifex.login(userID, password);
         }
     }
 
+    static boolean canLoginToCIFEX(ICIFEXComponent cifex, boolean userAuthenticated, String userID,
+            String password, String cifexAdminUserOrNull, String cifexAdminPasswordOrNull)
+    {
+        final String tokenOrNull =
+                getCIFEXSession(cifex, userAuthenticated, userID, password, cifexAdminUserOrNull,
+                        cifexAdminPasswordOrNull);
+        if (tokenOrNull != null)
+        {
+            cifex.logout(tokenOrNull);
+            return true;
+        } else
+        {
+            return false;
+        }
+    }
+
     private String createFileName()
     {
         if (StringUtils.isBlank(fileName))