如何在 Android 应用程序中访问 graph.windows.net Microsoft Azure Graph API? [英] How to access graph.windows.net Microsoft Azure Graph API in an android app?

查看:28
本文介绍了如何在 Android 应用程序中访问 graph.windows.net Microsoft Azure Graph API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已要求我的 IT 管理员以目录扩展的形式将名为 EmployeeId 的属性添加到与我们的现场 AD 同步的 Azure Active Directory.当给定用户登录我的 Android 应用程序时,我正在尝试检索此值.

I've asked my IT Admin to add an attribute called EmployeeId in the form of a directory extension to azure active directory which syncs with our onsite AD. I'm trying to retrieve this value for a given user when they sign into my android app.

我已关注 this该指南允许我使用当前登录的用户(即名字、姓氏等)从 URL graph.microsoft.com 检索数据.

I've followed this guide which has allowed me to retrieve data from the URL graph.microsoft.com with the currently logged in user i.e. givenname, surname etc.

问题在于,当我运行架构扩展的获取请求 (https://graph.microsoft.com/beta/schemaExtensions) 以尝试检索 EmployeeId 它只返回一些关于属性的元数据,而不是它本身的属性:

The issue is that when I run the get request for schema extensions (https://graph.microsoft.com/beta/schemaExtensions) to try to retrieve the value of EmployeeId it just returns some metadata about the attribute, not the attribute it'self:

{
        "id": "exti1rcdc4h_Employee",
        "description": "Baker is testing extension",
        "targetTypes": [
            "user"
        ],
        "status": "Available",
        "owner": "XXXXXXXXXXXXXXXXXX",
        "properties": [
            {
                "name": "EmployeeId",
                "type": "Integer"
            }
        ]
    }

在做了一些研究后,我发现我可以使用 this 图浏览器轻松检索值(通过使用获取请求 https://graph.windows.net/mydomain.com/users/user@mydomain.com).

After doing some research I've found that i can use this graph explorer to easily retrieve the value (by using the get request https://graph.windows.net/mydomain.com/users/user@mydomain.com).

但是,问题在于 URL graph.explorer.net 似乎与上述指南不兼容.

The issue is however that the URL graph.explorer.net doesn't seem to be compatible with the guide mentioned above.

有没有更好的方法来解决这个问题?

Is there a better way to approach this issue?

--编辑--

澄清一下,我只能使用 Azure 成功检索 extension_980f32feca7d475f9e1b90a410dbee63_employeeID 的值AD Graph explorer 当我访问 微软图形浏览器

Just to clarify I was only able to retrive the value for extension_980f32feca7d475f9e1b90a410dbee63_employeeID successfully using the Azure AD Graph explorer the value is not returned when i access the /users endpoint on Microsoft graph explorer

在 GET https://graph.microsoft.com/v1.0/users 请求中为每个用户返回的数据:

Data returned for each user in GET https://graph.microsoft.com/v1.0/users request:

"id": "d0be2ebd-0c7b-4c10-aebe-9db4c90a9594",
        "businessPhones": [],
        "displayName": "username",
        "givenName": "Jhon",
        "jobTitle": null,
        "mail": "user@mydomain.com",
        "mobilePhone": null,
        "officeLocation": null,
        "preferredLanguage": null,
        "surname": "Smith",
        "userPrincipalName": "user@mydomain.com"

推荐答案

是的,这是可能的.您应该能够运行几个不同的查询,例如:

Yes this is possible. You should be able to run a couple of different queries like:

  1. 查找具有特定员工 ID 的用户:

GET https://graph.microsoft.com/v1.0/users?$filter=extension_980f32feca7d475f9e1b90a410dbee63_employeeID eq 'S09655'

  1. 获取所有用户及其employeeId(需要使用$select)

GET https://graph.microsoft.com/v1.0/users?$select=id,displayName,extension_980f32feca7d475f9e1b90a410dbee63_employeeID

此外(在积压中,但正在积极进行中)我们正在努力将本地 employeeId 作为 Microsoft 中 user 实体的一级属性公开图形.不过,我还没有这方面的预计到达时间.

Additionally (in the backlog, but actively in progress) we are working to expose on-premises employeeId natively as a first-class property on the user entity in Microsoft Graph. I don't have an ETA for this yet though.

希望这会有所帮助,

这篇关于如何在 Android 应用程序中访问 graph.windows.net Microsoft Azure Graph API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆