Extension Attribute - check to make sure a user (any user) is logged in

donmontalvo
Esteemed Contributor III

We have a policy that we want to kick in when a user (any user) is logged on. What's the best way to leverage Extension Attributes to check if a user is logged in?

Thanks,
Don

--
https://donmontalvo.com
3 REPLIES 3

tlarkin
Honored Contributor

I would do a script, grab the current user by checking ownership of the /dev/console. If a computer is at the login Window root will own the console if a user is logged in they will own the console.

so,

#!/bin/bash

# current user check currentUser=ls -l /dev/console | awk '{ print $3 }'

if [[ $currentUser != root ]]

then jamf policy -trigger mypolicy

else echo "system is at the loginwindow"

fi

exit 0

talkingmoose
Moderator
Moderator

You could probably use the 'last' command line tool. I believe 'last
On 11/2/10 2:44 PM, "Don Montalvo" <donmontalvo at gmail.com> wrote:
console' would show if anyone's currently logged in or not.

Wouldn't it be easier to trigger the policy at login, though? What are you
trying to accomplish?

--

William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492

Mbentley777
Contributor

So what's the best way to combine the login script with the extension attribute? Would it be to call the script at login, and then trigger a policy, at the end of which recon would be run?