thycotic-ps / secretserver

Secret Server scripts that can be utilized to extend the abilities of Secret Server in your environment.
https://delinea.com/products/secret-server/
MIT License
24 stars 20 forks source link

Heartbeat Fails and getting throw Authentication Failed. Unknown error occurred. Does the user exist? when $responce is null #32

Open battlebudy opened 5 months ago

battlebudy commented 5 months ago

Heartbeat Fails and getting "Authentication Failed. Unknown error occurred. Does the user exist? "when $responce is null

After a lot of testing and running this outside of Secret Server I found when running $response = Invoke-WebRequest -Uri $authUrl -Method POST -headers $headers -Body $body
the $response would be null causing $errormessage to also be null thus triggering the final else statement

else {
            write-log -ErrorLevel 0 -Message "Authentication Failed. Unknown error occurred. Does the user exist?"
            write-log -ErrorLevel 2 -Message $errormessage.error_description
            throw "Authentication Failed. Unknown error occurred. Does the user exist?"

when running just Invoke-WebRequest -Uri $authUrl -Method POST -headers $headers -Body $body alone and outside of a Variable I was presented with the following error

Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.

Adding -UseBasicParsing to the request fixed the issue $response = Invoke-WebRequest -Uri $authUrl -Method POST -headers $headers -Body $body -UseBasicParsing

PatrickV-code commented 5 months ago

Seems like I did change this code in offline copy already. This is related to changes Microsoft did in if I recall Server 2022 in a recent patch. However, we actually moved this functionality natively in product if you are on Secret Server Cloud.