Posted on 09-09-2018 06:14 AM
What's up everyone!
Hoping someone can shed some light...
We have drilled through every post on JN to set up LDAP to populate the user information in the User and Location tab for each of our workstations. We're on 10.6.2. No matter how we try it, now matter how we configure LDAP, we can't get it to work on Check-in, Update or Recon. Yet, we're able to click on Edit > Search within User and Location manually, and it works!
so we created a policy at check-in with this script posted by @benjamin.michael here:
#!/bin/sh
# Grab the username of the user that last logged in (current user).
currentUser=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`
# Submit an inventory report and include the current user (above) to be written to the
# username field in User and Location Information.
jamf recon -endUsername $currentUser
exit 0
and POW! It works! Thanks Ben!
One problem though... On some, we're not getting the current logged on users info. We're getting other user logins who may have logged in at one point but then moved on. Anyone know where its grabbing this info from? Anything we need to remove, or clear from the workstation? Any help would be appreciated. Thanks as always!
Posted on 09-09-2018 08:13 AM
Posted on 09-09-2018 06:02 PM
Thanks @bpavlov but the string on the link didn't work. Unless we're doing something wrong. It returned with the local Admin account on the machine. Not the AD user. And the machines i tested this on, were machines where the users were logged in.
This string came back with Root:
loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
and this string came back with the local admin account, not the current AD user:
loggedInUser=$(/usr/bin/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 + " ");')
Thoughts?