Skip to main content
Solved

Extension Attribute not accessing machine's mobile account directory

  • February 3, 2022
  • 3 replies
  • 31 views

Forum|alt.badge.img+6

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

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?

 

 

Best answer by cnixon14

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.

 

 

3 replies

Forum|alt.badge.img+14
  • Honored Contributor
  • February 3, 2022

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" )

 


Forum|alt.badge.img+6
  • Author
  • Contributor
  • Answer
  • February 3, 2022

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.

 

 


Forum|alt.badge.img+6
  • Author
  • Contributor
  • February 3, 2022

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" )

 


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!