Search APIs based on Email Address & case sensitivity

Quick post based off a query I got (via GitHub) on using the v3 Search API to search on email address.

The community IdentityNow PowerShell module has quite a legacy and provides both legacy and v3 API support.
Searching for accounts by email address however has a caveat no matter which API you are using.
The following methods are all valid BUT the key caveat is that the backend APIs are case sensitive for email address. That is, case sensitive for the value.
All the following work IF you know any capitalisation in the value of the email address you are searching on.

Using Search-IdentityNowUsers

Search-IdentityNowUsers -query "email:[email protected])" 

Creating a PSObject and using Invoke-IdentityNowRequest

Name                           Value
----                           -----
query                          {[query, email:"[email protected]"]}
indices                        {identities}
includeNested                  False
sort                           {displayName}

$searchBodyJSON = $searchObj | ConvertTo-Json 
Invoke-IdentityNowRequest -uri "https://YOURTenant.api.identitynow.com/v3/search" -method Post -headers Headersv3_JSON -body $searchBodyJSON 

Using Search-IdentityNowIdentities (v3 Elastic Search)

{"query":{"query":"email:\"[email protected]\""},"indices":["identities"],"includeNested":false,"sort":["displayName"]}
Search-IdentityNowIdentities -filter $searchBodyJSON

Workaround
Searching then on email address value and not specifying to match to the email attribute will likely return numerous results.

$searchBody
Name                           Value
----                           -----
query                          {[query, [email protected]]}
indices                        {identities}
includeNested                  False
sort 

$searchBodyJSON = $searchBody | ConvertTo-Json 
$searchBodyJSON 

{
  "query": {
    "query": "[email protected]"
  },
  "indices": [
    "identities"
  ],
  "includeNested": false,
  "sort": [
    "displayName"
  ]
}

$results = Search-IdentityNowIdentities -filter $searchBodyJSON

But you can capture all the results and get the object that does have the value (case-insensitive) using the following.

$results | Where-Object {$_.email -like '[email protected]'}

Hope that helps anyone else in a similar scenario.

Cheers,
DR

3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.