Getting a user's real name

Not applicable

Aside from manually putting a user's name in manually, anyone have any tips on pulling the info from Accounts in System Prefs or maybe dscl and piping it into a JSS record for the machine?

5 REPLIES 5

tlarkin
Honored Contributor

Just one more final thought here too...

If you have several users that share the same computer and you want to log each user in the JSS you could hard code a variable that pulls from a loop in /Users (assuming their home folders are there) and output it through dscl to get the real name, then output all the names into one variable that recon could use. Now idea how that would show up in the jss but for example I was thinking along these lines

Real Name 1, Real Name 2, Real Name 3 and so on

tlarkin
Honored Contributor

as a long in hook

#!/bin/bash

# get current user, also can use $3 if ran by casper as a log in hook

CurrentUser=`ls -l /dev/console | awk '{ print $3}'

# now get their real name

RealName=dscl . read /Users/$CurrentUser | grep RealName | awk '{ print $2 }' $>/dev/null

echo "$RealName"

Now, here is the tricky part, as there is very little documentation for it. There is a jssutil command line which can probably update records of the JSS, but there is no manual. This wold also require that the jssutil binary be installed on the client. The other way would be to have it update, perhaps modify recon? So instead of echo, at the end of the script you could have this instead?

jamf recon -realname $RealName

?????

I also bet you could replace the -endUsername with the real name if you wanted to as well, and it would always display the users full name instead of their short name. Test this out and let me know as now I am curious myself

Not applicable

I actually asked JAMF about this when I took my CCA course because we would
like to start using the JAMF inventory for our asset management tool, but we
use barcodes on the machines that would all need to be entered manually, as
well as the user name and real name.

I was pretty much told that writing something would be possible, but not
supported, and that I'd have to manually edit the SQL database that houses
the JSS records...

Needless to say I haven't given that a try yet. I might test out the script
that Thomas just posted and see if we can play with that for user names and
real names, but that might pose problems for walkup machines with multiple
users and it doesn't help with our barcode situation.

tlarkin
Honored Contributor

You can write interactive apple scripts that will ask an user to input something, like a bar code (asset tag I assume) and then update that info on the jss via the recon command. That is a bit tricky for my current skill level in invoking apple script from the command line but I am getting the hang of it.

You could set it up via self service, and just so you know, usage logs for each computer log all users, not just one. Go into the JSS, go to logs and in the management log search box type in anyone's login name, and it will pull every machine result they have logged into. I have tons of students that like to play the laptop swap game and that is how I track down who has logged into what, and I set those loges to NEVER be deleted.

Not applicable

Thomas is right. We utilize several flags for recon to update the username
(and other information) in the JSS.

As usual, there are several ways to accomplish this, but in our environment,
we have AD users logging into the machines. We have a script that looks at
the username of the last user that logged in (located in the
/Library/Preferences/com.apple.loginwindow.plist).

We use dscl (like Thomas) to look up other information that we want about
that user. We then use recon to upload that information to the JSS. Here is
the syntax we use to upload to the JSS.

jamf recon -realname "$realname" -endUsername "$username" -department
"$department" -email "$email"

All of the variables should be self explanatory. So instead of running the
standard recon (Update Inventory in the Advanced tab in a policy), we have a
policy that will run a script that contains the above command. So the
"standard" recon will still run, but with the added benefit of other
information being updated/populated as well.

Travis