我正在使用以下代码查找部门名称:
GraphServiceClient graphServiceClient = connectToGraphAPI(Globals.adTenantId, Globals.adClientId, Globals.adClientSecret);
var Peoples = await graphServiceClient.Users[userid].People.Request().GetAsync();
foreach (Person People in Peoples) {
if (People.DisplayName != null && People.DisplayName.Equals(userName)) {
return People.Department.ToString();
}
}
但是,我想获取组织中所有部门的列表,而不是查找特定用户的部门。
最佳答案
正如@Matt.G 所说,Department 是User-Profile 页面上Job Info 部分下的一个字符串值。没有用于列出组织中所有部门的 API。您需要遍历用户以获取 departmentName。
关于c# - 如何使用 MS Graph API 获取组织中的所有部门,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60509639/