Skip to main content
Question

script to detect if logged in user is mobile cached account


Forum|alt.badge.img+21

Hi guys

i was wondering if someone can help me.

Im trying to run a script if the currently logged in user is a cached mobile account?

Has anyone got any ideas?

Thanks

4 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7882 replies
  • June 9, 2015

Two ways. Check the UID, which should be above 1000 (typically much higher than that), although its been mentioned on other threads that the UID can be spoofed pretty easily, so its not an absolute way. The better way, as was mentioned was to check for the OriginalAuthenticationAuthority key as part of the account's info from dscl. That key does not exist in local accounts, but will with cached AD mobile ones.

So...

#!/bin/sh

loggedInUser=$(ls -l /dev/console | awk '{print $3}')

if [[ $(dscl . read /Users/${loggedInUser} OriginalAuthenticationAuthority 2>/dev/null) ]]; then
    echo "$loggedInUser is an AD mobile account"
else
    echo "$loggedInUser is a local account"
fi

Should get you what you're looking for.


Forum|alt.badge.img+21
  • Author
  • Honored Contributor
  • 970 replies
  • June 9, 2015

thanks very much for your help


Forum|alt.badge.img+3
  • New Contributor
  • 3 replies
  • July 6, 2015

This works a treat, thanks


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • July 7, 2015

@mm2270

Just wanted to add one thing. Anyone with sudo rights and dscl can modify any attribute. So, you can spoof almost anything in there. You might want to look at actually checking if the computer is bound to AD (or LDAP), then take that users UID and see if it is in AD and not look at the local dscl entry.

I remember an old thread where the IT admin was claiming users were changing their UIDs to over 1000 on local accounts. I did some testing and I was able to use the -append switch in dscl and was able to basically spoof any attribute I wanted to in the local user record.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings