Skip to main content
Question

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

  • November 2, 2010
  • 3 replies
  • 11 views

donmontalvo
Forum|alt.badge.img+36

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

3 replies

Forum|alt.badge.img+31
  • Honored Contributor
  • November 2, 2010

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
Forum|alt.badge.img+36
  • Community Manager
  • November 3, 2010

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


Forum|alt.badge.img+6
  • Contributor
  • July 20, 2012

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?