此 AAD powershell 可以轻松列出用户的扩展属性:
> Get-AzureADUser -ObjectId 50413382@wingtiptoys.com |select -ExpandProperty ExtensionProperty
Key Value
--- -----
odata.metadata https://graph.windows.net/d29b7a9b-6edb-4720-99a8-3c5c6c3eeeb0/$metadata#directoryObjects/@Element
odata.type Microsoft.DirectoryServices.User
createdDateTime
employeeId 50413382
onPremisesDistinguishedName
thumbnailPhoto@odata.mediaEditLink directoryObjects/8cc715a1-0698-4d1a-8f49-441a84b6dbc4/Microsoft.DirectoryServices.User/thumbnailPhoto
thumbnailPhoto@odata.mediaContentType image/Jpeg
userIdentities []
extension_10a03227b5f146ad8a0087cf0bafd627_division |30103611|50435526|50230396|10192257|86009851
extension_10a03227b5f146ad8a0087cf0bafd627_company wingtiptoys Inc.
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute10 GF
extension_10a03227b5f146ad8a0087cf0bafd627_employeeID 50413382
extension_10a03227b5f146ad8a0087cf0bafd627_cn 50413382
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute8 wingtiptoys Inc. Inc.
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute7 Chuck
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute6 US11
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute5 US1-Rochester, NY- Site
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute4 USC
extension_10a03227b5f146ad8a0087cf0bafd627_extensionAttribute2 Regular
extension_10a03227b5f146ad8a0087cf0bafd627_employeeType ARR
Run Code Online (Sandbox Code Playgroud)
我现在有一个请求,将这种显示构建到经过身份验证的网页中,在前面的页面中,有人可以输入该对象 ID,并使用 Microsoft Graph 客户端 SDK 在屏幕上查看该输出。
关键问题是我无法对扩展属性列表进行硬编码。我只需要列出该特定用户的内容。
我已经找到了如何在知道扩展属性的名称后获取其值,但是如何在不提前知道属性名称的情况下获取上面的属性列表呢?(-ExpandProperty ExtensionPropertyPowerShell 的一部分)
我尝试通过图形浏览器获取这些数据,但遇到了困难。我试过了:
/v1.0/me/?$select=id&$expand=extensions (返回一个空的扩展元素)/v1.0/me/?$select=onPremisesExtensionAttributes(返回部分属性(但不是全部))