Office365 在SharePoint 2013 Online中使用JSOM通过电子邮件获取用户配置文件
我正在使用JSOM在SP 2013 Online中开发SharePoint托管的应用程序。我的要求是使用电子邮件id获取用户配置文件属性。 我知道我们可以使用输入作为帐户名获取任何用户配置文件,例如Office365 在SharePoint 2013 Online中使用JSOM通过电子邮件获取用户配置文件,office365,sharepoint-online,Office365,Sharepoint Online,我正在使用JSOM在SP 2013 Online中开发SharePoint托管的应用程序。我的要求是使用电子邮件id获取用户配置文件属性。 我知道我们可以使用输入作为帐户名获取任何用户配置文件,例如 userProfileProperty = peopleManager.getUserProfilePropertyFor(accountName, propertyName) 但是,是否可以使用用户的电子邮件id执行相同的操作?方法要求以索赔格式提供accountName参数 关于身份声明格式
userProfileProperty = peopleManager.getUserProfilePropertyFor(accountName, propertyName)
但是,是否可以使用用户的电子邮件id执行相同的操作?方法要求以索赔格式提供accountName
参数
关于身份声明格式
SharePoint 2013和SharePoint 2010使用以下编码格式显示标识声明:
<IdentityClaim>:0<ClaimType><ClaimValueType><AuthMode>|<OriginalIssuer (optional)>|<ClaimValue>
索赔可通过以下电子邮件地址构成:
function toClaim(email)
{
return String.format('i:0#.f|membership|{0}',email);
}
例子
用法
工具书类
非常感谢@Vadim为我澄清了疑问。我有一个关于帐户名格式的问题。您提到帐户名的格式为i:0#.f |成员身份|username@tenant.onmicrosoft.com. 帐户名是否总是以“.onmicrosoft.com”结尾?是否可以将此更改为类似i:0#.f |成员身份|username@tenant.com?
function toClaim(email)
{
return String.format('i:0#.f|membership|{0}',email);
}
var email = 'username@tenant.onmicrosoft.com';
var profilePropertyName = "PreferredName";
var accountName = toClaim(email);
function getUserProfilePropertyFor(accountName,profilePropertyName,success,failure)
{
var context = SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(context);
var userProfileProperty = peopleManager.getUserProfilePropertyFor(accountName,profilePropertyName);
context.executeQueryAsync(
function(){
success(userProfileProperty);
},
failure);
}
getUserProfilePropertyFor(accountName,profilePropertyName,
function(property){
console.log(property.get_value());
},
function(sender,args){
console.log(args.get_message());
});