From 9b4a334c7e6d0ddb9588c9452ea5b5583affbb7f Mon Sep 17 00:00:00 2001 From: PierreGode Date: Fri, 24 Aug 2018 09:26:48 +0200 Subject: [PATCH] Update ADconnection.sh --- ADconnection.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ADconnection.sh b/ADconnection.sh index ba591de..33cc117 100644 --- a/ADconnection.sh +++ b/ADconnection.sh @@ -1316,6 +1316,17 @@ fi ########################################### Leave Realm ################################ leave(){ +whoelse=$( who -ut | grep -v old | awk '{print $1}' ) +homeshome=$( sudo realm list | grep domain-name | awk '{print $2}' ) +homes=$( ls /home/$homeshome | head -1 ) +if [ "$homes" = "$whoelse" ] +then +echo "" +echo "you are logged in as an AD user.. canceling request" +echo "only administrator has +echo "" +exit +else LEFT=$(sudo realm discover | grep configured | awk '{print $2}') DOMAIN=$(realm discover | grep -i realm.name | awk '{print $2}') SSSD=$( sudo cat /etc/sssd/sssd.conf | grep domain | awk '{print $3}' | head -1 )