Skip to content

Instantly share code, notes, and snippets.

@fuzzylogiq
Created August 4, 2014 15:27
Show Gist options
  • Save fuzzylogiq/3b05899e2b85793102a1 to your computer and use it in GitHub Desktop.
Save fuzzylogiq/3b05899e2b85793102a1 to your computer and use it in GitHub Desktop.
Casper extension for full User Name
#!/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