chrisgzim / Jamf-API-Recovery-Lock-by-Group

MIT License
6 stars 1 forks source link

Question about Group ID #8

Open Cr4sh0ver1de opened 1 month ago

Cr4sh0ver1de commented 1 month ago

Hi Chris. Not really an issue, probably user error. I just have a question about the group ID.

I've got a smart group that I would like to set recovery lock on, however, every time i use either the Group ID or UUID, I get the following message

1

For the ID i am using (in the instance below) 153 2

I even tried the UUID from the results of the group 3

Nothing seems to be working.

The serials and management IDs exist in the system. If i try and do them using the serial rather than group, it works OK. 4

Any ideas?

Cr4sh0ver1de commented 1 month ago

This is the log from Jamf for the fails

Script result: 2024-07-03 15:51:09 - PRE-FLIGHT CHECK: swiftDialog version 2.5.0.4768 found; proceeding... 2024-07-03 15:56:27 - API Credentials work, invalidating token 2024-07-03 15:56:27 - Token already invalid 2024-07-03 15:56:27 - Workflow Selected: Static / Smart Group. Password Option: Set your own. 2024-07-03 15:56:40 - Found old csv, deleting now 2024-07-03 15:56:40 - Found old python script, deleting now 2024-07-03 15:56:41 - number of computers returned: 452 -:1: parser error : StartTag: invalid element name <!doctype html>HTTP Status 404 – Not Found</title ^ -:1: parser error : Extra content at the end of the document <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title ^ 0 serials found in smart group 2024-07-03 16:00:10 - No Matching Serial Numbers Found. Attempted to search 0 serial numbers.</p> </blockquote> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisgzim"><img src="https://avatars.githubusercontent.com/u/101137859?v=4" />chrisgzim</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Well, huh, that is a new one. The number you should be using the first one you tried: 153. But getting that 404 is really interesting. When I tested this with a non-existent group in my environment I was able to get a parser error, but not the 404.</p> <p>I also have a much smaller environment so my results might be just luck. One quick troubleshooting step is we can just programmatically set the group to 153 regardless and see if the error persists -- this way we can see if it is an issue with how the variable is being set or how the variable is being used. </p> <p>As a temporary workaround, can you replace line 288 with this? (You will still get prompted to put in a smart group, this will just set to whatever you put there as 153) </p> <p><code>smartgroupselection=153</code></p> <p>If this doesn't work, we can go to line 402 and replace <em>$smartgroupselection</em> to 153.</p> <p>I am going to work on putting in some better logging when selecting a smart group and create a branch with that work. Apologies that this isn't working appropriately. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Cr4sh0ver1de"><img src="https://avatars.githubusercontent.com/u/61380535?v=4" />Cr4sh0ver1de</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Hey Chris. Thanks for the comment. Sorry for the delay in my reply. </p> <p>Can you confirm that 288 is the correct line? This is what i am seeing for that line in the latest version</p> <p><img src="https://github.com/chrisgzim/Jamf-API-Recovery-Lock-by-Group/assets/61380535/129db0b3-1302-4e83-a0bd-69527b7d4bf9" alt="image" /></p> <p>Also seeing this for 402</p> <p><img src="https://github.com/chrisgzim/Jamf-API-Recovery-Lock-by-Group/assets/61380535/bd540021-a347-487d-a6e3-160e84c6f5d9" alt="image" /></p> <p>Maybe thinking this should be line 393?</p> <p><img src="https://github.com/chrisgzim/Jamf-API-Recovery-Lock-by-Group/assets/61380535/21597e8d-e7f2-471b-a35b-35ca93fce732" alt="image" /></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisgzim"><img src="https://avatars.githubusercontent.com/u/101137859?v=4" />chrisgzim</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Looking at the screenshots. . . yes, you're right (I am working on commenting and my lines were off on the script I am using.)! Let's replace the smartgroupselection variable to be just your group number of 153. If things work as expected, then I know it has something to do with the reading of the file to get the smart / static group. </p> <p>If it doesn't work, then we will want to just replace the variable in our curl command $smartgroupselection to just be 153 -- no variables at all. If that works, then it has to do with how the variable is being passed in the script. </p> <p>Finally, it might be worth just testing this group in the Jamf Pro API (instance.jamfcloud.com/api) > Classic API > computergroups > and test out the GET function as it might be an odd db issue in the Jamf Pro server. </p> <p>If all of that doesn't work. . . we might just create a new smart group and test out there. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Cr4sh0ver1de"><img src="https://avatars.githubusercontent.com/u/61380535?v=4" />Cr4sh0ver1de</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Hey @chrisgzim sorry for the delay in my reply. I've been away. </p> <p>So I updated the script to use the group ID as mentioned, but still got the same result</p> <p><img src="https://github.com/user-attachments/assets/a63e7143-ea50-4d6b-93e8-97a867dac7d5" alt="image" /></p> <p>I then popped to the classic API and made sure that that was able to see the groupID of 153, which it could... however, i did notice that like the message mentions, there are no Management IDs in the output.</p> <p><img src="https://github.com/user-attachments/assets/725ceaf9-26d1-4d98-ba70-472f1335b5a6" alt="image" /></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisgzim"><img src="https://avatars.githubusercontent.com/u/101137859?v=4" />chrisgzim</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Hey @Cr4sh0ver1de no worries. The error that we're getting should be adjusted because you're getting the management ids from an earlier API call. (Which we can see with the "Number of Computers Returned: 452" What is actually happening is that we can't find any serial numbers being returned in the smart group -- for whatever reason the smart group call is failing and throwing off the rest of the workflow. (I am going to create some better logic for this so there error is more clear.) </p> <p>Glad to see that it is working in the GUI of the Classic API! But now I gotta see what in my logic would be causing a 404 when doing what should be a similar API call. . . </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisgzim"><img src="https://avatars.githubusercontent.com/u/101137859?v=4" />chrisgzim</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Okay, I just committed<a href="https://github.com/chrisgzim/Jamf-API-Recovery-Lock-by-Group/blob/development/swiftdialog_jproapilock.sh"> something to development</a> to get us some better logging on what is potentially going on. If we're still stuck, I would want to meet up. If you have Customer Success Manager at Jamf, please feel free to connect with them and we can coordinate a time to meet. (I would put my contact info on here, but would prefer to go through official channels if that is okay with you.) </p> <p>Just let them know that Chris Zimmerman asked to connect! </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Cr4sh0ver1de"><img src="https://avatars.githubusercontent.com/u/61380535?v=4" />Cr4sh0ver1de</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Hey @chrisgzim </p> <p>Ok, so using the code from Development, I get the following: </p> <blockquote> <p>Script result: 2024-07-18 16:46:50 - PRE-FLIGHT CHECK: swiftDialog version 2.5.0.4768 found; proceeding... 2024-07-18 16:47:29 - API Credentials work, invalidating token 2024-07-18 16:47:29 - Token already invalid 2024-07-18 16:47:29 - Workflow Selected: Static / Smart Group. Password Option: Set your own. 2024-07-18 16:47:41 - Computer Group Selected is 153 2024-07-18 16:47:41 - Found old csv, deleting now 2024-07-18 16:47:41 - Found old python script, deleting now 2024-07-18 16:47:42 - number of computers returned: 446 -:1: parser error : StartTag: invalid element name <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title ^ -:1: parser error : Extra content at the end of the document <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title ^ 2024-07-18 16:47:43 - ERROR: Nothing returned from computer group 153</p> </blockquote> <p>I thought I would also try it with a Static Group (the above is a smart group) with the same results</p> <blockquote> <p>Script result: 2024-07-18 16:51:50 - PRE-FLIGHT CHECK: swiftDialog version 2.5.0.4768 found; proceeding... 2024-07-18 16:58:10 - API Credentials work, invalidating token 2024-07-18 16:58:10 - Token already invalid 2024-07-18 16:58:10 - Workflow Selected: Static / Smart Group. Password Option: Set your own. 2024-07-18 16:58:23 - Computer Group Selected is 159 2024-07-18 16:58:23 - Found old csv, deleting now 2024-07-18 16:58:23 - Found old python script, deleting now 2024-07-18 16:58:24 - number of computers returned: 446 -:1: parser error : StartTag: invalid element name <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title ^ -:1: parser error : Extra content at the end of the document <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title ^ 2024-07-18 16:58:25 - ERROR: Nothing returned from computer group 159</p> </blockquote> <p>Official channels is also good with me. Thanks for all your help. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/chrisgzim"><img src="https://avatars.githubusercontent.com/u/101137859?v=4" />chrisgzim</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>Okay, I'll look forward to connecting. I would be curious why the credentials seem to work at Bearer Token and the JPAPI call, but not on the Classic API call. But will definitely want to take a call on this. </p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>