lithnet / googleapps-managementagent

Google Workspace Management Agent for MIM 2016
MIT License
12 stars 4 forks source link

Issues with setting password at account creation #80

Closed JakobQv closed 2 months ago

JakobQv commented 5 months ago

Recently we have started getting errors related to the initial flow of password when creating an account, sometimes it works but most of the times it fails with below error, the account is created in Google but the password is not set. Any idea what might be wrong?

2024-04-08 11:42:08: Error setting password for user@contoso.com


An exception has occurred in SetPassword Type: Google.GoogleApiException Message: Google.Apis.Requests.RequestError Resource Not Found: userKey [404] Errors [ Message[Resource Not Found: userKey] Location[ - ] Reason[notFound] Domain[global] ] Source: Google.Apis TargetSite: Void MoveNext() StackTrace: at Google.Apis.Requests.ClientServiceRequest1.<ParseResponse>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Requests.ClientServiceRequest1.d27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Requests.ClientServiceRequest`1.d26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetry[T](ClientServiceRequest1 request, Func2 shouldRetry, Int32 retryAttempts, Int32 consumeTokens) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetry[T](ClientServiceRequest1 request, RetryEvents policy, Int32 retryAttempts, Int32 consumeTokens) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff[T](ClientServiceRequest1 request, Int32 retryAttempts, Int32 consumeTokens) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff[T](ClientServiceRequest1 request, Int32 retryAttempts) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetryOnBackoff[T](ClientServiceRequest`1 request) at Lithnet.GoogleApps.UserRequestFactory.SetPassword(String id, SecureString newPassword) at Lithnet.GoogleApps.MA.ManagementAgent.SetPassword(CSEntry csentry, SecureString newPassword, PasswordOptions options) in D:\dev\git\lithnet\googleapps-managementagent\src\Lithnet.GoogleApps.MA\ManagementAgent.cs:line 583


ryannewington commented 5 months ago

@JakobQv

It's just a terrible API. We've created the user, and then made a follow-up API call to set the password, and whatever endpoint we are hitting on the second call doesn't think that users exists. It hasnt replicated through their system for whatever reason.

We've seen this before, and it tends to be transient - eg something goes wrong on the google back end and its inconsistent for a while and then goes back to normal.

I'll check in with some other users and see if they are seeing this at the moment as well.

JakobQv commented 5 months ago

@ryannewington Thanks for the quick response, in this particular environment the issue appeared in late January and has persisted since so I'm not very hopeful that it will resolve itself.

ryannewington commented 5 months ago

@JakobQv

I've modified the agent to perform a backoff/retry when setting a user password and encountering a 404. Try this test build and see if its any better

https://github.com/lithnet/googleapps-managementagent/releases/tag/v2.2.1

JakobQv commented 5 months ago

@ryannewington I will implement it ASAP and let you know how it goes, thanks!

JakobQv commented 5 months ago

@ryannewington Got a different error now.

2024-04-10 08:42:32: Error setting password for user@contoso.com


An exception has occurred in SetPassword Type: Google.GoogleApiException

Message: Google.Apis.Requests.RequestError Required parameter: [resource.name.field] [400] Errors [ Message[Required parameter: [resource.name.field]] Location[ - ] Reason[required] Domain[global] ]

Source: Google.Apis TargetSite: Void MoveNext() StackTrace: at Google.Apis.Requests.ClientServiceRequest1.<ParseResponse>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Requests.ClientServiceRequest1.d31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Requests.ClientServiceRequest`1.d30.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Lithnet.GoogleApps.ApiExtensions.ExecuteWithRetry[T](ClientServiceRequest1 request, Func2 shouldRetry, Int32 retryAttempts, Int32 consumeTokens) at Lithnet.GoogleApps.UserRequestFactory.SetPassword(String id, SecureString newPassword) at Lithnet.GoogleApps.MA.ManagementAgent.SetPassword(CSEntry csentry, SecureString newPassword, PasswordOptions options)


ryannewington commented 5 months ago

that... shouldn't have anything to do with the change that I made. very confused

ryannewington commented 5 months ago

Are you getting that on any and all password changes, or is it working for some but not all?

JakobQv commented 5 months ago

Three accounts have been created so far, the first two failed with the same error and the third was successful

ryannewington commented 5 months ago

What version were you on prior to this? If you rollback to that version, does the error message stay the same, or revert back to the old one?

JakobQv commented 4 months ago

Sorry about the delayed response. Version 2.1.7857, rolling back to that version produces the old error "Errors [ Message[Resource Not Found: userKey] Location[ - ] Reason[notFound] Domain[global] ]"

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.