To retrieve recently modified or added users from Azure Active Directory using the Graph API, you have a couple of options:
Option 1: Delta Queries
Delta queries allow you to track changes in your directory. You can use the user-delta
endpoint to get a list of users that have been modified or added since the last query.
Here’s an example of how to use delta queries to fetch users in C#:
csharpCopy code
var
Make sure to handle the nextLink
or deltaLink
in the response to retrieve subsequent pages of results.
Option 2: Owned Objects
If you’re interested in groups that a specific user owns, you can use the ownedObjects
endpoint. This will give you a list of directory objects (including groups) owned by the user.
The request would look like this:
httpCopy code
GET https://graph.microsoft.com/v1.0/users/{user-id}/ownedObjects
You can then filter the results to get the group names and types.
Detailed Steps for Delta Queries
Initialize Delta Query:
- Make a request to the
users/delta
endpoint to get the initial set of users and a@odata.deltaLink
to track changes.
Process Initial Response:
- The initial response will include the current state of users and a **`@odata.deltaLink`**.
**Track Changes Using Delta Link:**
- Use the **`@odata.deltaLink`** to periodically check for updates since the last query.
Example for Delta Queries in Python
Here’s how you can implement delta queries using Python and the requests
library:
pythonCopy code
import
Handling Pagination
When making delta queries, handle pagination using @odata.nextLink
for multiple pages of results:
csharpCopy code
while
By using delta queries and owned objects endpoints, you can efficiently track and retrieve modified or added users and their related groups in Azure Active Directory.
I