|
#!/bin/zsh |
|
# set -x |
|
|
|
:<<ABOUT_THIS_SCRIPT |
|
----------------------------------------------------------------------- |
|
|
|
Written by:William Smith |
|
Technical Enablement Manager |
|
Jamf |
|
[email protected] |
|
https://gist.github.com/talkingmoose/0550abf9ebb9e1267ea82a55556601d8 |
|
|
|
Originally posted: June 16, 2024 |
|
|
|
Purpose: Configure Jamf Pro LAPS settings. |
|
|
|
Instructions: |
|
|
|
1. In Jamf Pro click Settings > System > API roles and clients. |
|
|
|
2. Under API Roles create a new API role such as "LAPS Management". |
|
|
|
Set Privileges to include: |
|
Update Local Admin Password Settings |
|
|
|
Under API Clients create a new API client such as "LAPS Manager". |
|
|
|
Set API roles to: |
|
LAPS Management |
|
|
|
Enable the API client and copy the Client ID and Client Secret. |
|
|
|
3. UUpdate the Jamf Pro URL, Client ID, and Client Secret variables below. |
|
|
|
4. In Jamf Pro edit Settings > Global > User-Initiated Enrollment > |
|
Computers. |
|
|
|
Select "Create managed local administrator account" and provide |
|
a Username for the LAPS account. |
|
|
|
Optionally, hide the managed local administrator account and/or |
|
allow SSH access. |
|
|
|
5. Adjust the LAPS settings JSON variable below. |
|
|
|
autoDeployedEnabled (default: false): |
|
|
|
Set to "true" only if using a PreStage LAPS account. |
|
Otherwise, the jamf binary LAPS account |
|
|
|
passwordRotationTime (default: 3600): |
|
|
|
Number of seconds before Jamf Pro will will wait before |
|
rotating the password after viewing it. |
|
|
|
autoRotateEnabled (default: false): |
|
|
|
Set to "true" to rotate LAPS account passwords regardless |
|
of whether they've been viewed. |
|
|
|
autoRotateExpirationTime (default: 7776000): |
|
|
|
Number of seconds before Jamf Pro will will automatically rotate |
|
LAPS account passwords regardless of whether they've been viewed. |
|
autoRotateEnabled must be set to "true". |
|
|
|
Except where otherwise noted, this work is licensed under |
|
http://creativecommons.org/licenses/by/4.0/ |
|
|
|
"A feature undiscovered is a feature missing." |
|
|
|
----------------------------------------------------------------------- |
|
ABOUT_THIS_SCRIPT |
|
|
|
|
|
jamfProURL="https://talkingmoose.jamfcloud.com" |
|
clientID="b36a0245-f238-4c54-ac8a-6e4170f7ad6a" |
|
clientSecret="ve5ffjUAIGjs4X-OjsT_KeyqVAv7HR_Em4hXWYHT12mp791DY7RGqHFEdyhtjZsB" |
|
|
|
lapsSettingsJSON='{ |
|
"autoDeployEnabled": false, |
|
"passwordRotationTime": 900, |
|
"autoRotateEnabled": false, |
|
"autoRotateExpirationTime": 31536000 |
|
}' |
|
|
|
function checkResponseCode() { |
|
httpErrorCodes="000 No HTTP code received |
|
200 Request successful |
|
201 Request to create or update object successful |
|
400 Bad request |
|
401 Authentication failed |
|
403 Invalid permissions |
|
404 Object/resource not found |
|
409 Conflict |
|
500 Internal server error" |
|
|
|
responseCode=${1: -3} |
|
code=$( /usr/bin/grep "$responseCode" <<< "$httpErrorCodes" ) |
|
|
|
echo "$code" |
|
} |
|
|
|
echo "Requesting oauth token." |
|
|
|
# request oauth token |
|
oAuthTokenResponse=$( /usr/bin/curl \ |
|
--data-urlencode "grant_type=client_credentials" \ |
|
--data-urlencode "client_id=$clientID" \ |
|
--data-urlencode "client_secret=$clientSecret" \ |
|
--header "Content-Type: application/x-www-form-urlencoded" \ |
|
--request POST \ |
|
--silent \ |
|
--url "$jamfProURL/api/oauth/token" \ |
|
--write-out "%{http_code}" ) |
|
|
|
checkResponseCode "$oAuthTokenResponse" |
|
|
|
# extract token data from response |
|
oAuthToken=${oAuthTokenResponse%???} |
|
|
|
# parse token from response |
|
token=$( /usr/bin/plutil -extract access_token raw - <<< "$oAuthToken" ) |
|
|
|
echo "Configuring settings." |
|
|
|
# set LAPS settings |
|
lapsSettings=$( /usr/bin/curl \ |
|
--data "$lapsSettingsJSON" \ |
|
--header "Content-Type: application/json" \ |
|
--header "Authorization: Bearer $token" \ |
|
--request PUT \ |
|
--silent \ |
|
--url "$jamfProURL/api/v2/local-admin-password/settings" \ |
|
--write-out "%{http_code}" ) |
|
|
|
checkResponseCode "$lapsSettings" |
|
|
|
# extract data from request |
|
echo "${lapsSettings%???}" |
|
|
|
echo "Destroying oauth token." |
|
|
|
# expire auth token |
|
expireToken=$( /usr/bin/curl \ |
|
--header "Authorization: Bearer $token" \ |
|
--request POST \ |
|
--silent \ |
|
--url "$jamfProURL/api/v1/auth/invalidate-token" \ |
|
--write-out "%{http_code}" ) |
|
|
|
checkResponseCode "$oAuthTokenResponse" |
|
|
|
exit 0 |
Thanks for the response, but I do understand that...Im now trying to make a script that looks up the managementID's of devices in a smart group and then proceeds to loop through them and reset the laps password, but was hoping someone already did this. (smart group of just Apple Silicon that have this laps password). I had turned laps off last week and we are having issues with volume ownership because of this. Now I need to reset the passwords all back to a new one to get around this issue.