Accessing keychain info of another user for EA

ScottEKendall
New Contributor III

Help!

I have been trying to endlessly to get this to work...what am I doing wrong? I know for a fact that the logged in user has the workplace join key in their keychain but for some reason, when trying to run this for an EA it doesn't report correctly.  I know the jamf runs with elevated privileges, but should it be able to run this without prompt for user credentials (like root), or is this not going to be possible?

 

#!/bin/zsh

currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
uid=$(id -u "$currentUser")

haswpjkey="No"
wpjkey=$(launchctl asuser "$uid" sudo -iu "$currentUser" security dump-keychain | grep "Workplace Join Key" | xargs)
[[ "${wpjkey}" == *"Microsoft Workplace Join Key"* ]] && haswpjkey="Yes"
echo "<result>$haswpjkey</result>"

 

1 ACCEPTED SOLUTION
1 REPLY 1