Directory Manager API - searching for a user

Looking at the “Get a User” API Endpoint (https://demomachine:4443/GroupIDDataService/api/IdentityStores/{identityStoreId}/Users/{userIdentity}) it appears we need to know the objectGUID of the user in advance. How can we search for a user through an API call based on their name or email address in order to retrieve the objectGUID (userID entity)?

Hi Hunter,

Welcome to the community :slightly_smiling_face:

Good question. I’m digging into this right now.

It looks like this may require doing a more general search via the API first to retrieve the user details, and then using that info (like the objectGUID) for the specific call. I’m going to validate this and put together some details.

I’ll share an update soon!

Thank you!

Hi Hunter,

As promised, here are the details! You’re right that the GET /Users/{userIdentity} endpoint requires the objectGUID upfront. The solution is a two-step flow — search first, then fetch.

Step 1 — Search by name or email

POST https://yourserver/GroupIDDataService/api/IdentityStores/{identityStoreId}/Searches
Authorization: Bearer {token}
Content-Type: application/json

Search by email:

json

{
    "identityStoreId": 2,
    "searchType": 0,
    "sortBy": "displayName",
    "sortOrder": 0,
    "pageNo": 1,
    "pageSize": 10,
    "calculateTotal": true,
    "criteria": {
        "operator": "Is Exactly",
        "attribute": "mail",
        "value": "john.doe@company.com"
    },
    "attributesToLoad": ["displayName", "mail", "objectGUID", "sAMAccountName"]
}

Search by display name (partial match):

json

{
    "criteria": {
        "operator": "Contains",
        "attribute": "displayName",
        "value": "John"
    },
    "attributesToLoad": ["displayName", "mail", "objectGUID", "sAMAccountName"]
}

From the response, extract objectIdFromIdentityStore — that’s your objectGUID.

Step 2 — Get full user details

GET https://yourserver/GroupIDDataService/api/IdentityStores/{identityStoreId}/Users/{objectGUID}
Authorization: Bearer {token}

A couple of gotchas worth flagging:

  • sortOrder must be an integer (0 = Ascending, 1 = Descending) — passing "Ascending" as a string will return a 400 error

  • When getting your Bearer token, the client_id must be the Secret GUID from SVC.Client where ClientType = 'APIClient' — not the client name. This one isn’t obvious from the documentation

Hope that helps! Let me know if you run into any issues.

Thank you Ali, this is very helpful.

If this works for you, please mark Ali’s reply as the solution! It’s this button under his reply: