Thanks @Dan Kershaw for responding and giving a try to my question. As it was an immediate requirement, all i could think of is to change the approach to achieve this. However I am not satisfied fully as I cant think why Filter would not offer an "OR" operation and just work an "AND" operation. Anyways, the below is a working scenario after code based change to get Users and then filter to match the condition. It is working fine now.
Posted so that if it could help others in similar approach!!!!! :)
public async Task<bool> CheckUserByEmailId(string email, CancellationToken ct)
{
List<User> userResult1 = new List<User>();
List<User> userResult2 = new List<User>();
var graphClient = await GetGraphServiceClientAsync();
var user1 = await graphClient.Users
.Request()
.Filter($"otherMails/any(id:id eq '{email}')")
.Select(e => new
{
e.DisplayName,
e.Id,
e.Identities,
e.PasswordPolicies,
e.PasswordProfile,
e.UserPrincipalName,
e.OtherMails,
e.LastPasswordChangeDateTime,
e.Mail
}
)
.GetAsync();
var user2= await graphClient.Users
.Request()
.Filter($"identities/any(c:c/issuerAssignedId eq '{email}' and c/issuer eq '{this._adOptions.Issuer}')")
.Select(e => new
{
e.DisplayName,
e.Id,
e.Identities,
e.PasswordPolicies,
e.PasswordProfile,
e.UserPrincipalName,
e.OtherMails,
e.LastPasswordChangeDateTime,
e.Mail } ).GetAsync();
/*Above approach to first get two possible scenarios for user's to be of either federated(facebook
or google issuer) or domain issuer*/
/*Code based Filter to get Users based on Email condition*/
if(user1.Count==0)
{
userResult1.AddRange(user2);
}
else
userResult1.AddRange(user1);
// Get Issuer
var genIssuer = new List<List<string>>();
genIssuer = userResult1.Select(u => u.Identities
.Select(u => u.Issuer).ToList()).ToList();
List<string> genIssuerList = new List<string>();
genIssuerList = genIssuer[0].ToArray().ToList();
string issuer = genIssuerList[0].ToString();
//Get All emails
var genIdentEmail = new List<List<string>>();
genIdentEmail = userResult1.Select(u => u.Identities
.Select(u => u.IssuerAssignedId).ToList()).ToList();
List<string> genIdentEmailList = new List<string>();
genIdentEmailList = genIdentEmail[0].ToArray().ToList();
string identEmail = genIdentEmailList[0].ToString();
List<string> otherMails = new List<string>();
var other = userResult1.Select(e => e.OtherMails).ToList();
otherMails = other[0].ToArray().ToList();
string otherMail;
if (otherMails.Count==0)
otherMail = "na";
else otherMail = otherMails[0].ToString();
if (email==otherMail || email==identEmail)
{
return true;
}
else
{
return false;
}
}