0

I've seen code snippets and answers for setting a user to an Org Unit (OU) during user creation, but nothing regarding moving a user from one OU to another after it's been created.

NOTE: Prior to this I retrieved the user I wanted to modify, which is what the user variable refers to.

user.OrgUnitPath = "/NLWC";
var updateResult = await _service.Users.Update(user, user.Id).ExecuteAsync();

updateResult returns a User object. When I view the OrgUnitPath in the returned user I view the desired OU path (and also, when I query that same user in the future I get the same result).

enter image description here

But when I view the user in the Gsuite admin console, the OU hasn't changed.

In fact, I manually moved the user to the OU, and queried the user object again. After manually moving it, the OrgUnitPath is still the same.

Additionally, I queried the Org Units to verify I have the right path, and it shows the following: enter image description here

I can't understand why it's not moving the user to the right OU, what am I missing?

Dymas
  • 122
  • 9
  • 1
    Can you please provide a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) with the minimum necessary setup and code to be able to reproduce the situation? Also, did you try making a request from the "Try this API" in the docs? https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/update - is it possible that you have the request ready in memory but are not actually sending it? – iansedano Mar 01 '21 at 11:47
  • @iansedano I'm not really sure how to add more of an MCVE since the preceding code involves authenticating with the Gsuite API (which requires specific credentials) and also involves querying the list of users for an environment specific identifier (that other Gsuite orgs might not have). Really the code boils down to 1) Find the user 2) Set the OrgUnitPath property of the user 3) Send an Update request to the Directory Service – Dymas Mar 02 '21 at 23:14
  • As for your second point, I've been able to perform other operations with the directory service so that's not an issue. Also, like I mentioned in the question, if I query the User object (after executing the original code), it shows the OrgUnitPath as the changed one. It just doesn't reflect the change in the Admin console. – Dymas Mar 02 '21 at 23:15
  • 1
    From what you are saying I understand that it is likely nothing to do with the dot net library. Thing is I just did a test with the "try this API" sidebar in the docs, where I made an update request to change the OU path of a user, and this was reflected immediately in both `admin.google.com` and subsequent user get requests. Do the changes eventually propagate to the admin console or is it as if they are querying different sources? Is it just with OU paths or does it not change any aspect of a user? What about other resources? – iansedano Mar 03 '21 at 09:37
  • Strangely enough, it seems be working now. When I first tested it, none of the OU path changes were being reflected in the admin console. Now, they're reflected immediately. I'm not sure what the difference is, since the code for both situations is identical. At least it works though. If you'd like to leave an answer, I'll mark it as accepted so you get credit for trying to help, thanks! – Dymas Mar 03 '21 at 23:18
  • There is not much by way of answer I can post. It was not working and now it is. There is no solution as such. I appreciate the offer though. I wonder what it was... – iansedano Mar 04 '21 at 08:28
  • Be sure NOT to include the domain name. Root = "/" – Mario Favere Jan 19 '22 at 13:43

0 Answers0