Hello everyone,
I hope you are doing well. I have Okta integrated with Jamf through Jamf Connect, I am wondering is it somehow possible to pass user's Full Name or at least Username in Okta to Jamf / Mac.
What I am trying to do is to change computer name to be the same as the name of the Okta user.
So far my closest success to this was to create script that takes username or alias(alias has precedence) of the currently logged in user and sets it as computer name. Code is below:
#!/bin/bash
admin1="admin1"
admin2="admin2"
# get username of the currently logged in user
username=$(/usr/bin/logname)
# get currently logged in user's alias if alias is not available, username will be used instead
alias=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name && ! /loginwindow/ { print $3 }' )
# If logged in user is not one of local admins that are for IT personel
if [ $username != $admin1 ] && [ $username != $admin2 ]; then
if [ $username == $alias ]; then
/usr/local/bin/jamf setcomputername -name $username
/usr/local/bin/jamf recon
else
/usr/local/bin/jamf setcomputername -name $alias
/usr/local/bin/jamf recon
fi
fi
Right now I do not have app integration in Okta created specifically for Jamf Connect integration.
Edit1:
In case someone needs this in the future, here's an example code:
# awk splits Okta username from Okta domain
okta_user=$(defaults read com.jamf.connect.state DisplayName | awk -F'@' '{print $1}')
/usr/local/bin/jamf setcomputername -name $okta_user
/usr/local/bin/jamf recon