forked from loceee/OSXCasperScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed superfluous local account position var. changed phone number text manipulation to return only number added department via querying Active Directory fixed echo formatting for AD accounts
- Loading branch information
Will Polley
committed
Jul 6, 2014
1 parent
97209e7
commit 9e3223e
Showing
1 changed file
with
15 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,30 +8,35 @@ | |
# 0.2 - [email protected] - Updated code for user info parsing | ||
# 0.3 - thanks Jaymes, querying attrib direct via dscl is a much better approach! removed extraneous echos | ||
# directed stderr to null so we don't see errors for unpopualted atributes (tidier) | ||
# 0.4 - removed superfluous local account position var. | ||
# changed phone number text manipulation to return only number | ||
# added department via querying Active Directory | ||
# fixed echo formatting for AD accounts | ||
|
||
loggedinuser=$(ls -l /dev/console | awk '{ print $3 }') | ||
accounttype=$(dscl . -read /Users/$loggedinuser OriginalNodeName 2> /dev/null | tail -1 | cut -c 2-) | ||
accountnode=$(dscl . -read /Users/$loggedinuser OriginalNodeName 2> /dev/null | tail -1 | cut -c 2-) | ||
|
||
echo "Reconning and submitting user information for $loggedinuser..." | ||
echo "------------------------------------------------------------------------" | ||
|
||
if [ "$accounttype" == "" ] | ||
if [ "$accountnode" == "" ] | ||
then | ||
userposition="Local Account" | ||
echo "Local Account" | ||
echo "------------------------------------------------------------------------" | ||
jamf recon -endUsername $loggedinuser -position "$userposition" | ||
jamf recon -endUsername $loggedinuser -position "Local Account" | ||
else | ||
userrealname=$(dscl . -read /Users/$loggedinuser original_realname 2> /dev/null | tail -1 | cut -d ' ' -f 2-) | ||
useremail=$(dscl . -read /Users/$loggedinuser EMailAddress 2> /dev/null | cut -d ' ' -f 2-) | ||
userposition=$(dscl . -read /Users/$loggedinuser JobTitle 2> /dev/null | tail -1 | cut -d ' ' -f 2-) # these keys may not be filed | ||
userphone=$(dscl . -read /Users/$loggedinuser PhoneNumber 2> /dev/null | cut -d ' ' -f 2-) | ||
echo "realname: $userrealname" | ||
echo "emailaddress: $useremail" | ||
echo "position: $userposition" | ||
echo "phone: $userphone" | ||
userphone=$(dscl . -read /Users/$loggedinuser PhoneNumber 2> /dev/null | tail -1 | cut -c 2-) | ||
userdepartment=$(dscl "$accountnode" -read /Users/$loggedinuser dsAttrTypeNative:department 2> /dev/null | tail -1 | cut -c 2-) | ||
echo "realname: $userrealname" | ||
echo "emailaddress: $useremail" | ||
echo "position: $userposition" | ||
echo "phone: $userphone" | ||
echo "department: $userdepartment" | ||
echo "------------------------------------------------------------------------" | ||
jamf recon -endUsername "$loggedinuser" -realname "$userrealname" -email "$useremail" -position "$userposition" -phone "$userphone" | ||
fi | ||
|
||
exit | ||
exit 0 |