From a44de80672dee0f1b04f85ffdc196d02b3f5efb6 Mon Sep 17 00:00:00 2001 From: Paul Bowden Date: Thu, 25 Mar 2021 08:25:21 -0700 Subject: [PATCH] Revision 2 --- ADALCache_Age.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ADALCache_Age.sh b/ADALCache_Age.sh index 0a6707e..a099839 100644 --- a/ADALCache_Age.sh +++ b/ADALCache_Age.sh @@ -26,17 +26,14 @@ SetHomeFolder() { LoggedInUser=$(GetLoggedInUser) SetHomeFolder "$LoggedInUser" -# Find out if the login.keychain is in the path - if not, add it -KeychainHasLogin=$(/usr/bin/sudo -u $LoggedInUser /usr/bin/security list-keychains | grep 'login.keychain') -if [ "$KeychainHasLogin" = "" ]; then - /usr/bin/sudo -u $LoggedInUser /usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db" -fi +# Search the keychain of the logged in user +/usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db" # Get today's date in the 8-digit format of YYYYMMDD DateToday=$(date "+%Y%m%d") # Get the creation date of the keychain entry -KeychainCreationDate=$(/usr/bin/sudo -u $LoggedInUser /usr/bin/security find-generic-password -l 'com.microsoft.adalcache' | grep 'cdat' | cut -d '"' -f4) +KeychainCreationDate=$(/usr/bin/security find-generic-password -l 'com.microsoft.adalcache' | grep 'cdat' | cut -d '"' -f4) # Trim the keychain date into the 8-digit format of YYMMDD TrimmedCreationDate=${KeychainCreationDate:0:8}