Extension Attribute not accessing machine's mobile account directory

cnixon14
New Contributor III

I am trying to check if a user is signed into Box on their machine but the script doesn't seem to be accessing the correct directory. Here is what I have

cnixon14_0-1643915877175.png

I believe the script isn't detecting the users account correctly like the $USER variable would if it was run locally. so my question is: Is there a way to have the script detect the current logged in user so it can access the users account directory?

 

 

1 ACCEPTED SOLUTION

cnixon14
New Contributor III

Figured this out by pulling the lastUserName property from the com.apple.loginwindow. So here is my current script for anyone in the future having this same problem.

 

cnixon14_0-1643917963136.png

 

View solution in original post

3 REPLIES 3

jtrant
Valued Contributor

Jamf runs as root, so you would need to set a variable in your script to capture the logged in user.

Something like this should work:

 

USER=$( /usr/bin/stat -f %Su "/dev/console" )

 

cnixon14
New Contributor III

Thank you for the response! The $USER variable is automatically populated with the current user when the script is run locally on a machine. When I first wrote it I didn't think about the fact that JAMF wouldn't be able to detect the current user with the script being run remotely!

cnixon14
New Contributor III

Figured this out by pulling the lastUserName property from the com.apple.loginwindow. So here is my current script for anyone in the future having this same problem.

 

cnixon14_0-1643917963136.png