alex098304
❔ Using Microsoft Graph to verify users exist based on IEnumerable<Guid>
I am trying to work with Microsoft Graph to verify that each guid in some list is associated with a user in the graph. I have noticed that there is some sort of property
graphClient.Users.GetByIds
that I intuitively think I can use to at least return a list of Users somehow, but I have no idea how it’s supposed to work, and I can’t seem to find documentation on it online that is useful. Mostly I am just very confused about how this API is supposed to work at all, and to me it’s just very unintuitive.
Right now the best implementation I can come up with is to call graphClient.Users[guid.ToString()].GetAsync() with a config specifying that I don’t want any data returned. I do this for every Guid in my list, and I check if an exception is thrown. This seems kind of dumb to me, but it’s the only thing I can find that actually works.
To be clear, I am writing an async Task<bool> method that accepts an IEnumerable<Guid>. It should return false if any supplied Guid is not associated with a user Id in the graph, and true if every Guid is associated with a user.
I feel like there has to be a more intelligent solution than what I am currently using. Any help would be appreciated.15 replies