Below is the Current code, i want to add CAML Query here to filter Field "AppCode", "User" and "Group".
Here need to check "Group" using OR condition because we have list of group here
GraphServiceClient _graphServiceClient = getGraphClient(configValues);
var aclList = new HashSet<string>();
Microsoft.Graph.Models.GroupCollectionResponse? response = await _graphServiceClient.Users[userId].MemberOf.GraphGroup.GetAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Select = ["id", "displayName"];
requestConfiguration.QueryParameters.Top = 100;
});
var pageIteratorG = PageIterator<
Microsoft.Graph.Models.Group,
Microsoft.Graph.Models.GroupCollectionResponse?
>.CreatePageIterator(_graphServiceClient, response, async (group) =>
{
groupsQuery.Add(group.DisplayName);
return true;
});
await pageIteratorG.IterateAsync();
ListItemCollectionResponse? _listItems = await _graphServiceClient.Sites[configValues.SiteId].Lists[configValues.clientsListID].Items.GetAsync(requestConfiguration =>
{
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
requestConfiguration.Headers.Add("Prefer", "HonorNonIndexedQueriesWarningMayFailRandomly");
requestConfiguration.QueryParameters.Select = new[] { "id" };
requestConfiguration.QueryParameters.Expand = new[] { "fields($select=AppCode,User,Group,ACL)" };
requestConfiguration.QueryParameters.Filter = $"fields/AppCode eq '{departmentName}' and (fields/User eq '{currentUser}' or fields/User eq null)";
});
var pageIterator = PageIterator<ListItem, ListItemCollectionResponse>.CreatePageIterator(_graphServiceClient, _listItems, item =>
{
bool check = (bool)item.Fields?.AdditionalData.ContainsKey("Group");
if (check)
{
var groupName = item.Fields?.AdditionalData["Group"];
if (groupName != null)
{
if (groupsQuery.IndexOf(groupName.ToString()) > -1)
{
bool checkACL = (bool)item.Fields?.AdditionalData.ContainsKey("ACL");
if (checkACL)
{
var acl = item.Fields?.AdditionalData["ACL"];
Console.WriteLine("ACL : " + acl);
aclList.Add(acl.ToString());
isValidateWithAdmin = true;
}
}
}
}
return true;
});
await pageIterator.IterateAsync();