Custom Extension Attribute Jamf Variable: Account Setup Prestage

fiolu01
New Contributor II

Hello, I am looking to create a Jamf Extension Attribute to create a username that matches a users LDAP info $FULLNAME and turn it into `firstnamelastname` or `firstname-lastname` and then use the Jamf Variable $EXTENSIONATTRIBUTE_# on the Account Name within Prestage Enrollments Account Setup.

$FULLNAME/REALNAME don't work as it creates a space between the names and this creates issues when attempting to call username in scripts as it will only see the `Last` name of the user. $USERNAME does not work as this is an email address from our LDAP and the @ symbol is also an illegal character causing the same issue.

Unfortunately I have no idea where to begin other than knowing to use <result> with in the custom attributes, very new to scripting and I am the only Jamf Admin at this small company. Does anyone know how to accomplish this automatic Account Setup?

 

2 REPLIES 2

Tribruin
Valued Contributor II

What are you trying to do with $REALNAME in the scripts that is causing issues? You can put "s around the variable to prevent the name from splitting. Maybe instead of an Extension Attribute, you can use something else. 

The issue that $FULLNAME & $USERNAME are not on the computer by default. One option is to push a Config Profile to every computer with a custom domain (e.g. com.organization.userinfo). Then you could create an EA script to read from that file and use sed to remove the spaces. 

#!/bin/bash

UserName=$(defaults read /Library/Managed Preferences/com.organization.userinfo.plist UserName)
NewUserName=$(echo "$UserName" | sed "s/ //g")
echo "<result>$NewUserName</result>"

NOTE: That code has not been tested. Do not use without testing. 

 

fiolu01
New Contributor II

Some interesting ideas here, I am working with support right now. I'll bring this up with them in our meeting and see what they think. I like the idea of pushing this to machines not sure if this will work with enrollment. I tried something with $EXTENSIONATTRIBUTE_# and built an EA trying to us $FULLNAME then modifying it, but that did not go well. Everything I have looked at or heard recently all leads to LDAP configs, well see where the support leads. Thanks for taking the time.