我正在尝试读取当前帐户的经理。
下面你会看到读取“Me”对象的函数的代码片段。我已经在 Azure AD 的帐户中设置了 Manager 并仔细检查了。
尽管我可以在 Azure 管理门户中查看管理器对象,但它始终为空。
有没有人解决这个问题?谢谢。
public async Task<Office365User> GetCurrentUser()
{
var currentUser = await this.Authentication.GetCurrentUser();
var activeDirectoryClient = GetActiveDirectoryClient();
var myAccount = await activeDirectoryClient.Me.ExecuteAsync();
if(myAccount.Manager != null)
{
var managerAccount = await activeDirectoryClient.Users.GetByObjectId(myAccount.Manager.ObjectId).ExecuteAsync();
if(managerAccount != null)
{
currentUser.Manager = managerAccount.ToOffice365User(currentUser.TenantId);
}
}
return currentUser;
}