Created
March 7, 2018 02:08
-
-
Save patgmac/29cb5213f0d1ec8741a0e0707f1b502b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### | |
# | |
# Name: ec_checkLDAPmatch_EA.sh | |
# Description: Checks if local user name matches what is authenticated in EC | |
# Author: Patrick Gallagher | |
# Created: 2018-02-16 | |
# | |
### | |
if [[ -d "/Applications/Enterprise Connect.app" ]]; then | |
logged_in_user=$( python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");' ) | |
/usr/bin/security find-generic-password -l "Enterprise Connect" "/Users/$logged_in_user/Library/Keychains/login.keychain" > /dev/null 2>&1 | |
if [[ $? -eq 0 ]]; then | |
ec_user=$(/usr/bin/security find-generic-password -l "Enterprise Connect" | grep "acct" | awk -F "=" '{print $2}' | tr -d "\"") | |
echo "<result>$ec_user</result>" | |
else | |
echo "<result>EC Not Signed In</result>" | |
fi | |
else | |
echo "<result>EC Not Installed</result>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment