Created
August 4, 2014 15:27
-
-
Save fuzzylogiq/3b05899e2b85793102a1 to your computer and use it in GitHub Desktop.
Casper extension for full User Name
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 | |
# Script to return full AD user name of last logged in user | |
DOMAIN="enterdomainhere" | |
LASTLOGIN=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName` | |
LASTUSERID=`id -u $LASTLOGIN` | |
if [ $LASTUSERID -gt "1000" ] | |
then | |
ADLOGIN=`dscl /Active\ Directory/$DOMAIN/All\ Domains -read /Users/$LASTLOGIN | awk /RealName/'{getline; print $1, $2}'` | |
else | |
ADLOGIN=$LASTLOGIN | |
fi | |
echo "<result>$ADLOGIN</result>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment