Skip to main content
Question

API call to update user location info

  • September 11, 2018
  • 5 replies
  • 4 views

KyleEricson
Forum|alt.badge.img+16

I have a script that will do the following: Create a local account based on admin pop-up box and rename the mac to this username-last4ofserial#. The account that is created is in LDAP format and is the user that I would assign in JAMF console in the user location field.

I have LDAP fully set up in JAMF pro how can I make an API call to grab the username from the user account or the computer name and update the user location fields in JAMF pro console?

5 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • September 11, 2018

I don't think you need to do this via the API. A simple recon command should do it.

/usr/local/bin/jamf recon -endUsername $username

If you have more info than just the username, such as full name and some other details, those can be entered as well with their own flags. Run jamf help recon in Terminal for more details.


KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • September 11, 2018

Ok so normally I enter the username in JAMF pro and hit search and it pulls the LDAP info like realname, email, position and etc. How do the other fields work?


KyleEricson
Forum|alt.badge.img+16
  • Author
  • Valued Contributor
  • 444 replies
  • September 11, 2018

Nevermind this updates everything cool thanks.


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • September 11, 2018

@kericson Take a look at the help page for the recon command. Almost all of those can be populated with the recon command, if you know what those are. If the username is coming from LDAP, like from AD, it should be simple enough to pull these values into variables by querying AD on the username, then using those variables to populate the values in the User and Location fields.


Forum|alt.badge.img+7
  • Contributor
  • 37 replies
  • December 22, 2023
#!/bin/bash # Get the currently logged in user short name CURRUSER=$( stat -f "%Su" /dev/console ) # Run the result through dscl locally REALNAME=$( /usr/bin/dscl . -read /Users/${CURRUSER} dsAttrTypeStandard:RealName | sed 's/RealName://g' | tr '\\n' ' ' | sed 's/^ *//;s/ *$//' ) EMAIL=$( /usr/bin/dscl . -read /Users/${CURRUSER} dsAttrTypeStandard:NetworkUser | sed 's/NetworkUser://g' | tr '\\n' ' ' | sed 's/^ *//;s/ *$//' ) # Echo the result if [ "(${CURRUSER})" == "_windowserver" ]; then echo "No one logged in" exit 1 else echo "Sending email: ${EMAIL} to JSS" echo "Sending endUsername: ${EMAIL} to JSS" echo "Sending realname: ${REALNAME} to JSS" sudo jamf recon -email "${EMAIL}" -endUsername "${EMAIL}" -realname "${REALNAME}" fi exit 0

Using the info above, I threw this together. We use JamfConnect with Azure to create the accounts; so, /usr/bin/dscl . -read /Users/$USERNAME pulls the info for us.


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