Windows Azure AD Graph Common Queries
This topic lists common queries that can be used with Windows Azure AD Graph. Replace ”contoso.com” with your domain to successfully run the queries with your subscription.
Top-Level Resources
| Top-Level Resources | Query Results | URI (for contoso.com) |
|---|---|---|
Top-level resources | Returns URI list of the top-level resources for directory services (also listed below) | https://graph.windows.net/contoso.com?api-version=2013-04-05 |
Company information | Returns company information | https://graph.windows.net/contoso.com/tenantDetails?api-version=2013-04-05 |
Contacts | Returns contact information | https://graph.windows.net/contoso.com/contacts?api-version=2013-04-05 |
Users | Returns user information | https://graph.windows.net/contoso.com/users?api-version=2013-04-05 |
Groups | Returns group data | https://graph.windows.net/contoso.com/groups?api-version=2013-04-05 |
Roles | Returns all roles that have users or groups assigned to them | https://graph.windows.net/contoso.com/roles?api-version=2013-04-05 |
SubscribedSkus | Returns the tenant's subscriptions | https://graph.windows.net/contoso.com/subscribedSkus?api-version=2013-04-05 |
Directory metadata | Returns a Service Metadata Document that describes the data model (that is, structure and organization of directory resources) | https://graph.windows.net/contoso.com/$metadata?api-version=2013-04-05 |
Query Operations
| Query Operation | URI (for contoso.com) |
|---|---|
List all Users and Groups | https://graph.windows.net/contoso.com/users?api-version=2013-04-05 https://graph.windows.net/contoso.com/groups?api-version=2013-04-05 |
Retrieve individual User by specifying the objectId or userPrincipalName | https://graph.windows.net/contoso.com/users/d1f67a6c-02c9-4fe5-81fb-58160ce24fe5?api-version=2013-04-05 https://graph.windows.net/contoso.com/users/admin@contoso.com?api-version=2013-04-05 |
Request and Filter for a user with displayName equal to “Jon Doe” | https://graph.windows.net/contoso.com/Users?$filter=displayName eq 'Jon Doe'&api-version=2013-04-05 |
Request and Filter for specific users with firstName equal to “Jon” | https://graph.windows.net/contoso.com/users?$filter=givenName eq 'Jon'&api-version=2013-04-05 |
Filter for givenName and surname values. | https://graph.windows.net/contoso.com/users?$filter=givenName eq 'Jon' and surname eq 'Doe'&api-version=2013-04-05 |
Retrieve individual group by specifying the objectId | https://graph.windows.net/contoso.com/groups/06790a81-0382-434c-b40e-216fa41bda21?api-version=2013-04-05 |
Retrieve a user’s manager | https://graph.windows.net/contoso.com/users/John.Smith@contoso.com/manager?api-version=2013-04-05 |
Retrieve a user’s direct reports list | https://graph.windows.net/contoso.com/users/3c4a09b0-a7b6-444e-9702-96983635a66e/directReports?api-version=2013-04-05 |
Retrieve a list of links to a user’s direct reports | https://graph.windows.net/contoso.com/users/3c4a09b0-a7b6-444e-9702-96983635a66e/$links/directReports?api-version=2013-04-05 |
Retrieve membership list of a group | https://graph.windows.net/contoso.com/groups/3f575eef-bb04-44a5-a9af-eee9f547e3f9/members?api-version=2013-04-05 |
Retrieve a list of links to the members of a group. | https://graph.windows.net/contoso.com/groups/3f575eef-bb04-44a5-a9af-eee9f547e3f9/$links/members?api-version=2013-04-05 |
Retrieve a user’s group membership (not transitive) | https://graph.windows.net/contoso.com/users/ee6308f6-646a-4845-a4e1-57ac96ccc0c8/memberOf?api-version=2013-04-05 |
Retrieve a list of the groups that the user is a member of (not transitive) | https://graph.windows.net/contoso.com/users/ee6308f6-646a-4845-a4e1-57ac96ccc0c8/$links/memberOf?api-version=2013-04-05 |
Request and filter for groups with displayName => ‘az’ and <= ‘dz’ | https://graph.windows.net/contoso.com/groups?$filter=displayName ge 'az' and displayName le 'dz'&api-version=2013-04-05 |
Note |
|---|
| White space in the query string should be URL-encoded before sending a request. For example, the following query string, https://graph.windows.net/contoso.com/Users?$filter=displayName eq 'Jon Doe'&api-version=2013-04-05, should be URL encoded as: https://graph.windows.net/contoso.com/Users?$filter=displayName%20eq%20'Jon%20Doe'&api-version=2013-04-05. |
Query Options
Windows Azure AD supports the following query options: $filter and $top. (The following query options are not currently supported: $count, $expand, $format, $inlinecount, $orderby, and $skip.)
$filter
The following general restrictions apply to queries that contain a filter.
-
Filtering is not supported for queries on Role or SubscribedSku directory objects.
-
Not all properties of supported directory objects can be used in a filter expression. For information about filterable properties of supported types, see User, Group, and Contact.
-
Paging is not supported for filtered queries. Only the first N results are returned, where N is either the default page size of 100 or a client-specified page size between 1 and 999.
The following restrictions apply to filter expressions.
-
Logical operators: and is supported; or is not supported.
-
Comparison operators: eq (equal to), ge (greater than or equal to), and le (less than or equal to) are supported.
-
Arithmetic operators: not supported.
-
Functions: not supported.
- null values are not supported as an operand in filter expressions. For example, you cannot specify a null value to filter for unset properties.
$top
$top is not supported for queries on Role or SubscribedSku directory objects.
Paging Support
-
The default page size is 100. The maximum page size is 999.
-
Queries against roles do not support paging. This includes reading role objects themselves as well as role members.
-
Resource listing, such as a blanket /users query (https://graph.windows.net/contoso.com/users?api-version=2013-04-05), does support paging. However, across all types, when a filter is applied, paging is not supported and only the first page of results is returned.
-
Paging is not supported for link searches; for example, searches for group members (https://graph.windows.net/contoso.com/groups/3f575eef-bb04-44a5-a9af-eee9f547e3f9/$links/members?api-version=2013-04-05).
Sort Order
-
Windows Azure AD Graph does not support the $orderby query option. For this reason, you cannot specify how the results of a query are ordered.
-
The result set of a query for all users (https://graph.windows.net/contoso.com/users?api-version=2013-04-05) is ordered by the UserPrincipalName property.
-
The result set of a query for all other top-level resources, such as groups (https://graph.windows.net/contoso.com/groups?api-version=2013-04-05), contacts (https://graph.windows.net/contoso.com/contacts?api-version=2013-04-05), and so on, is ordered by the objectId property.
-
The order of the results of queries other than for top-level resources is indeterminate.
See Also
Note