我正在使用Microsoft.Azure.ActiveDirectory.GraphClient 2.1.1.0版來獲取我的用戶所屬的組。 方法調用是這樣的:獲取Azure Graph API庫中的成員組掛起
ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(
new Uri(GraphUrl),
async() => await GetAppTokenAsync());
IEnumerable<string> groups = GetGroupsAsync(activeDirectoryClient, "currentUserObjectId").Result;
private static async Task<IEnumerable<string>> GetGroupsAsync(ActiveDirectoryClient activeDirectoryClient, string currentUserObjectId)
{
return await activeDirectoryClient.Users.GetByObjectId(currentUserObjectId).GetMemberGroupsAsync(true);
}
private static async Task<string> GetAppTokenAsync()
{
var authContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(ServiceRoot);
var token = await authContext.AcquireTokenAsync(GraphUrl,new ClientCredential("clientId", "clientSecret"));
return token.AccessToken;
}
但是該方法掛起即使菲德勒我看到該請求已經succedeed幷包含正確的組。
我的問題是Azure ActiveDirectory Graph API GraphClient not returning AD Groups的重複。解決方法存在但不解釋爲什麼該方法不起作用。
你能在你的例子提供多一點(HTTP://? stackoverflow.com/help/mcve)很高興看到調用此方法的代碼。 –
我在示例中添加了調用方法 – jlp