diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
index bf6a48a511f11f38ee621f512d0f5372a008cafb..4ef6906c2bd996c97fd1c688f8eea67838f5927f 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
@@ -214,9 +214,15 @@ fi
   # 1. Map requests to EOS virtual identities
   eos -r 0 0 vid add gateway eoscta grpc
 
-  # 2. Add authorisation key (must be the same as the one specified in client.sh)
+  # 2. Add authorisation key
+  #
+  # Note: EOS_GRPC_USER and EOS_AUTH_KEY must be the same as those specified in client.sh
+  EOS_GRPC_USER=daemon
+  EOS_GRPC_GROUP=${EOS_GRPC_USER}
   EOS_AUTH_KEY=migration-test-token
-  eos -r 0 0 vid set map -grpc key:${EOS_AUTH_KEY} vuid:2 vgid:2
+  # daemon is already in EOS sudo group (see above)
+  #eos vid set membership ${EOS_GRPC_USER} +sudo
+  eos -r 0 0 vid set map -grpc key:${EOS_AUTH_KEY} vuid:${EOS_GRPC_USER} vgid:${EOS_GRPC_GROUP}
   echo "gRPC authorized uid and gid:"
   eos -r 0 0 vid ls | grep grpc:
 
diff --git a/continuousintegration/orchestration/tests/grpc_dir_inject.sh b/continuousintegration/orchestration/tests/grpc_dir_inject.sh
index fdd0b3d83a8d15891b93a803e5cf58c6dc126fd3..19d4d6777fb62ebc127390326cc5fa43cac173aa 100644
--- a/continuousintegration/orchestration/tests/grpc_dir_inject.sh
+++ b/continuousintegration/orchestration/tests/grpc_dir_inject.sh
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+# Migration tools parameters
+EOS_GRPC_USER=daemon
+EOS_TEST_DIR_INJECT=/usr/bin/eos-test-dir-inject
+CONFIG_FILE=/etc/cta/castor-migration.conf
+TMPFILE=/tmp/eos-test-inject-sh.$$
+
 # Colours
 NC='\033[0m' # No colour
 RED='\033[0;31m'
@@ -24,21 +30,19 @@ echoc()
   echo -e "${COLOUR}$*${NC}"
 }
 
-EOS_TEST_DIR_INJECT=/usr/bin/eos-test-dir-inject
-[ -x ${EOS_TEST_DIR_INJECT} ] || error "Can't find executable ${EOS_TEST_DIR_INJECT}"
+test_dir_inject()
+{
+  COMMAND="${EOS_TEST_DIR_INJECT} $*"
+  sudo -u ${EOS_GRPC_USER} bash -c "${COMMAND}"
+}
 
-CONFIG_FILE=/etc/cta/castor-migration.conf
+[ -x ${EOS_TEST_DIR_INJECT} ] || error "Can't find executable ${EOS_TEST_DIR_INJECT}"
 [ -r ${CONFIG_FILE} ] || error "Can't find configuration file ${CONFIG_FILE}"
-
-TMPFILE=/tmp/eos-test-inject-sh.$$
-
 CASTOR_PREFIX=$(awk '/^castor.prefix[ 	]/ { print $2 }' ${CONFIG_FILE})
 EOS_PREFIX=$(awk '/^eos.prefix[ 	]/ { print $2 }' ${CONFIG_FILE})
 
-echo "Running as user ${UID}:${USER}"
-
 # Ping the gRPC interface
-${EOS_TEST_DIR_INJECT} ping || error "gRPC ping failed"
+test_dir_inject ping || error "gRPC ping failed"
 
 # Create the top-level directory. GNU coreutils "mkdir -p" does not return an error if the directory
 # already exists; "eos mkdir -p" does return an error, which we explicitly ignore.
@@ -46,7 +50,7 @@ eos mkdir -p ${EOS_PREFIX} 2>/dev/null
 
 # Create directory with system-assigned file id -- should succeed
 echoc $LT_BLUE "Creating directory with auto-assigned file id"
-${EOS_TEST_DIR_INJECT} --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
+test_dir_inject --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
 [ $? -eq 0 ] || error "Creating directory with auto-assigned file id failed"
 json-pretty-print.sh ${TMPFILE}
 rm ${TMPFILE}
@@ -56,7 +60,7 @@ eos rmdir ${EOS_PREFIX}/my_test_dir
 
 # Create directory with self-assigned file id -- should succeed
 echoc $LT_BLUE "Creating directory with self-assigned file id"
-${EOS_TEST_DIR_INJECT} --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
+test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
 [ $? -eq 0 ] || error "Creating directory with self-assigned file id failed"
 json-pretty-print.sh ${TMPFILE}
 rm ${TMPFILE}
@@ -64,14 +68,14 @@ eos fileinfo ${EOS_PREFIX}/my_test_dir
 
 # Try again -- should fail
 echoc $LT_GREEN "Creating directory with the same file id (should fail)"
-${EOS_TEST_DIR_INJECT} --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir2 >/dev/null
+test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir2 >/dev/null
 [ $? -ne 0 ] || error "Creating directory with self-assigned file id succeeded when it should have failed"
 
 # Remove and try again -- should succeed after restarting EOS
 echoc $LT_GREEN "Remove the directory and restart EOS to remove the tombstone"
 eos rmdir ${EOS_PREFIX}/my_test_dir
 echoc $LT_BLUE "Recreate the directory with self-assigned file id (should succeed this time)"
-${EOS_TEST_DIR_INJECT} --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >/dev/null
+test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >/dev/null
 [ $? -eq 0 ] || error "Creating directory with self-assigned file id failed with error $?"
 eos fileinfo ${EOS_PREFIX}/my_test_dir