'Filtering User Based on Multiple Organizational Unit GSuite Search API
I want to fetch a list of users that present in multiple Organizational Units. For single organization unit below code is working fine
query = "orgUnitPath:/OU-1"
admin_service_obj = self.connector_obj.build_service_obj("admin", "directory_v1",
self.delegated_credentials())
activities = admin_service_obj.users()
request = activities.list(domain=self.domain, maxResults=50, query=query)
results = request.execute()
but for multiple organization units none of them is working.
query = "orgUnitPath:/OU-1 OR orgUnitPath:/OU-2"
query = "orgUnitPath:'/OU-1 OR /OU-2'"
Solution 1:[1]
I think the problem is that you can not use OR for multiple parameters of the query. According to the documentation:
Multiple clauses are separated by whitespace and are implicitly joined by an AND operator.
I have tested it with other queries like listing users with different email addresses or names and it does not work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fernando Lara |
