Okta - Jamf pass user full name from Okta to Jamf

Milos
New Contributor

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

 

1 ACCEPTED SOLUTION

Tribruin
Valued Contributor II

Are you having your users sign in to Okta when logged in? if so you can read the com.jamf.connect.state preference file for their Username and their Full Name:

defaults read com.jamf.connect.state UserShortName

defaults read com.jamf.connect.state DisplayName

More information here: https://docs.jamf.com/jamf-connect/2.6.0/documentation/State_Settings_and_User_Status.html

View solution in original post

4 REPLIES 4

Tribruin
Valued Contributor II

Are you having your users sign in to Okta when logged in? if so you can read the com.jamf.connect.state preference file for their Username and their Full Name:

defaults read com.jamf.connect.state UserShortName

defaults read com.jamf.connect.state DisplayName

More information here: https://docs.jamf.com/jamf-connect/2.6.0/documentation/State_Settings_and_User_Status.html

Milos
New Contributor

By sign in to Okta, do you refer to force Okta dashboard to open in lets say a browser and have user sign in?

Right now this is only enabled on lab machines, basically on the Mac login screen I have Jamf Connect window where I can login with Okta username + Password + 2FA. 

Will test out what you have mentioned and go from there. Thanks a lot!!

Milos
New Contributor

Update, your info helped out a lot, thanks again!

saeid_agheli
New Contributor III

Can tell me how your are resolving the issue I'm confused