我可以使用 Azure AD“businessPhones”吗?在 URL 参数中?
我可以在 URL 参数中使用多个 Azure AD 配置文件实体字段,将登录用户的配置文件数据解析为 Intranet 上的表单,以进行预填充等。
例如,...URL?officelocation=(user.apiProfile.officeLocation)&fullname=(user.fullName)&email=(user.email)&jobtitle=(user.apiProfile.jobTitle)< /代码>。
根据 https://graph,所有这些字段都是单字符串数据类型.microsoft.com/v1.0/$metadata#users/$entity。
我想知道是否可以使用字符串集合的第一个或第二个值作为 URL 中的参数。如果是这样,怎么办?
以“businessPhones”字段为例。我尝试使用 &userphone=(user.businessPhones[0])
或其他格式,但无法返回字段数据。
在通过 SAML 2.0 使用 Azure AD 作为身份提供程序并使用 Microsoft Graph API 的 Intranet 页面上,我能够在页面上动态显示几乎所有用户配置文件数据作为内容 - 包括数组中的那些字段(或字符串集合),使用下面的脚本和 html 片段作为示例。
<p>First name + Last name: <span id="user-firstname" style="font-weight:600;"></span> <span id="user-lastname" style="font-weight:600;"></span></p>
<p>Full name: <span id="user-fullname" style="font-weight:600;"></span></p>
<p>Email address: <span id="user-email" style="font-weight:600;"></span></p>
<p>Job title: <span id="user-jobtitle" style="font-weight:600;"></span></p>
<p>Office Phone: <span id="user-officephone" style="font-weight:600;"></span></p>
<p>Firm Name: <span id="user-firm" style="font-weight:600;"></span></p>
<p>Firm Address: <!--<span id="user-streetaddress" style="font-weight:600;"></span> <span id="user-city" style="font-weight:600;"></span>, <span id="user-postcode" style="font-weight:600;"></span>, --><span id="user-state" style="font-weight:600;"></span></p>
<p>UID: <span id="user-id" style="font-weight:600;"></span></p>
<p>Embedded Page: <a href="#" id="current-url"><span id="text-url" style="font-weight:600;"></span></a></p>
<script>
$('#user-firstname').html(CONNECTED_USER.firstName);
$('#user-lastname').html(CONNECTED_USER.lastName);
$('#user-fullname').html(CONNECTED_USER.fullName);
$('#user-email').html(CONNECTED_USER.email);
$('#user-jobtitle').html(CONNECTED_USER.apiProfile.jobTitle);
$('#user-officephone').html(CONNECTED_USER.apiProfile.phones[1].value);
$('#user-firm').html(CONNECTED_USER.apiProfile.officeLocation);
/*$('#user-streetaddress').html(CONNECTED_USER.apiProfile.streetAddress);*/
/*$('#user-city').html(CONNECTED_USER.apiProfile.city);*/
/*$('#user-postcode').html(CONNECTED_USER.apiProfile.postalCode);*/
$('#user-state').html(CONNECTED_USER.apiProfile.organizations[0].stateLocation);
$('#user-id').html(CONNECTED_USER.id);
$('#user-url').html(CONNECTED_USER.url);
$('#current-url').attr("href", window.location.href);
$('#text-url').html(window.location.href)
</script>
您可以看到我使用 CONNECTED_USER.apiProfile.phones[1].value
和 CONNECTED_USER.apiProfile.organizations[0].stateLocation
返回我希望显示的数据。
是否可以对 URL 参数执行类似的操作?
I am able to use a number of Azure AD profile entity fields in a URL parameter for parsing the logged in user's profile data into a form on our intranet for pre-fill or the like.
For example, ...URL?officelocation=(user.apiProfile.officeLocation)&fullname=(user.fullName)&email=(user.email)&jobtitle=(user.apiProfile.jobTitle)
.
All of these fields are single string data types according to https://graph.microsoft.com/v1.0/$metadata#users/$entity.
I'd like to know if it's possible to use the first or second value of a collection of strings as a parameter in the URL. And if so, how?
Take the "businessPhones" field for example. I've tried using &userphone=(user.businessPhones[0])
or other formations but am unable to return the field data.
On a page of our intranet which uses Azure AD as the Identity Provider via SAML 2.0 and uses the Microsoft Graph API, I am able to surface almost any user profile data dynamically on the page as content - including those fields which are in an array (or collection of strings), using the below script and html snippet as example.
<p>First name + Last name: <span id="user-firstname" style="font-weight:600;"></span> <span id="user-lastname" style="font-weight:600;"></span></p>
<p>Full name: <span id="user-fullname" style="font-weight:600;"></span></p>
<p>Email address: <span id="user-email" style="font-weight:600;"></span></p>
<p>Job title: <span id="user-jobtitle" style="font-weight:600;"></span></p>
<p>Office Phone: <span id="user-officephone" style="font-weight:600;"></span></p>
<p>Firm Name: <span id="user-firm" style="font-weight:600;"></span></p>
<p>Firm Address: <!--<span id="user-streetaddress" style="font-weight:600;"></span> <span id="user-city" style="font-weight:600;"></span>, <span id="user-postcode" style="font-weight:600;"></span>, --><span id="user-state" style="font-weight:600;"></span></p>
<p>UID: <span id="user-id" style="font-weight:600;"></span></p>
<p>Embedded Page: <a href="#" id="current-url"><span id="text-url" style="font-weight:600;"></span></a></p>
<script>
$('#user-firstname').html(CONNECTED_USER.firstName);
$('#user-lastname').html(CONNECTED_USER.lastName);
$('#user-fullname').html(CONNECTED_USER.fullName);
$('#user-email').html(CONNECTED_USER.email);
$('#user-jobtitle').html(CONNECTED_USER.apiProfile.jobTitle);
$('#user-officephone').html(CONNECTED_USER.apiProfile.phones[1].value);
$('#user-firm').html(CONNECTED_USER.apiProfile.officeLocation);
/*$('#user-streetaddress').html(CONNECTED_USER.apiProfile.streetAddress);*/
/*$('#user-city').html(CONNECTED_USER.apiProfile.city);*/
/*$('#user-postcode').html(CONNECTED_USER.apiProfile.postalCode);*/
$('#user-state').html(CONNECTED_USER.apiProfile.organizations[0].stateLocation);
$('#user-id').html(CONNECTED_USER.id);
$('#user-url').html(CONNECTED_USER.url);
$('#current-url').attr("href", window.location.href);
$('#text-url').html(window.location.href)
</script>
You can see that I use CONNECTED_USER.apiProfile.phones[1].value
and CONNECTED_USER.apiProfile.organizations[0].stateLocation
to return the data I wish to show.
Is it possible to do similar with URL parameters?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这取决于您用于撰写网址的语言。例如,在asp.net core中,当您从graph api获取响应时,您可以看到
BusinessPhones
属性是IEnumerable
,因此您不能使用user.businessPhones[0]
但使用BusinessPhones.FirstOrDefault()
。如果你在javascript中编写url,那么当你使用
user.businessPhones[0]
时它应该可以工作,如果它不起作用,你可以添加console.log(user.businessPhones)
查看数据。顺便说一句,如果某些用户对
businessPhones
属性没有值,您可能需要考虑它。I think it's based on which language you used for composing the url. For example, in asp.net core, when you got the response from graph api, you can see that the
BusinessPhones
property isIEnumerable<string>
, so you can't useuser.businessPhones[0]
butBusinessPhones.FirstOrDefault()
.And if you compose the url in javascript, it should work when you use
user.businessPhones[0]
, if it doesn't work, you may addconsole.log(user.businessPhones)
to see the data.By the way if some users has no value for
businessPhones
property, you may need to consider it.