登录 Outlook Web 插件时获取用户 AD 详细信息

Get users AD details when logged into Outlook Web Addin

我仍在努力尝试在 im 开发中提取已登录 (Outlook) 用户的详细信息。

我已经探索了 EWS 服务,但据我所知,我需要的功能不可用,所以我开始查看 Outlook REST API。

我可以通过以下调用获取非常基本的用户详细信息:

    function sendFindPersonRequest() {

    //get auth token for Graph
        Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) {
        if (result.status === "succeeded") {
            var accessToken = result.value;
            console.log('REST Access Token : ' + accessToken);
            // Use the access token.
            getCurrentItem(accessToken);
        } else {
            // Handle the error.
        }
    });}

    function getCurrentItem(accessToken) {

    // Construct the REST URL to the current item.
    // Details for formatting the URL can be found at
    // https://docs.microsoft.com/previous-versions/office/office-365-api/api/version-2.0/mail-rest-operations#get-messages.
    var getMessageUrl = Office.context.mailbox.restUrl +
        '/v2.0/me/';

    $.ajax({
        url: getMessageUrl,
        dataType: 'json',
        headers: { 'Authorization': 'Bearer ' + accessToken }
    }).done(function (item) {
        // Message is passed in `item`.
        var subject = item.displayName;
        console.log('item subject: ' + subject);

  }).fail(function (error) {
    // Handle error.
});
}

但是这不会超过别名、显示名称和电子邮件地址。

@odata.context: "https://outlook.office365.com/api/v2.0/$metadata#Me"
@odata.id: "https://outlook.office365.com/api/v2.0/Users('')"
Alias: "Joe.Bloggs"
DisplayName: ""
EmailAddress: "Joe.Bloggs@emailhere.co.uk"
Id: "baf52ae4-............"
MailboxGuid: "257f3fe1-6.............."

我希望获得扩展的详细信息,例如职位、办公室地址等(这是标准的 AD 字段)。

我也查看了 GetUser 方法,但 returns 相同。我真的不想走 Graph 路线,感觉我错过了一些东西,因为我真的希望其他字段在那里。

有没有其他人用这个来更好地影响?

谢谢

我没有看到我们可以在哪里为基于 Office 365 Data Extensions and Outlook Extended Properties 的用户创建扩展。

而且Microsoft.OutlookServices.User也没有Jobtitle、OfficeAddress等属性

当我尝试使用 OData $select 查询参数时:

https://outlook.office365.com/api/v2.0/me?$select=DisplayName,Jobtitle,OfficeAddress 

会报错:"Could not find a property named 'Jobtitle' on type 'Microsoft.OutlookServices.User'."

恐怕您想要的在 Outlook REST 中不可用 API。您应该改用 Microsoft Graph API 或 AAD Graph API。


更新:

我们可以使用GET https://outlook.office365.com/api/v2.0/me/people?$search=""来查找此人的信息。