如何获取Office 365的当前用户凭据 [英] how to get current user credentials for office 365

查看:156
本文介绍了如何获取Office 365的当前用户凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all

i需要让当前用户登录Office 365而不是在我的代码中将其用作静态



Hello all
i need to get the current user logged into office 365 instead of using it as static in my code

SecureString password = new SecureString();
foreach (char c in "eman".ToCharArray()) password.AppendChar(c);
clientContext.Credentials = new SharePointOnlineCredentials("e@eman.onmicrosoft.com", password);

推荐答案

var theData = {

propertiesForUser:{

__ metadata:{type:SP.UserProfiles.UserProfilePropertiesForUser},

accountName:i:0# .f | membership | mgangwar@server32.onmicrosoft.com,

propertyNames:[电子邮件,电话]

}

};



var requestHeaders = {

接受:application / json; odata = verbose,

X-RequestDigest:jQuery(#__ REQUESTDIGEST)。val()

};



jQuery.ajax ({

url:_spPageContextInfo.webAbsoluteUrl +/ _ api / SP.UserProfiles.PeopleManager / GetUserProfilePropertiesFor,

类型:POST,

data:JSON.stringify(theData),

contentType:applic ation / json; odata = verbose,

header:requestHeaders,

success:function(data){

console.log(data) ;

},

错误:函数(jqxr,errorCode,errorThrown){

console.log(jqxr.responseText);

}

});
var theData = {
"propertiesForUser": {
"__metadata": { "type": "SP.UserProfiles.UserProfilePropertiesForUser" },
"accountName" : "i : 0#.f|membership|mgangwar@server32.onmicrosoft.com",
"propertyNames": ["Email", "Phone"]
}
};

var requestHeaders = {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
};

jQuery.ajax({
url:_spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertiesFor",
type:"POST",
data: JSON.stringify(theData),
contentType : "application/json;odata=verbose",
headers: requestHeaders,
success:function(data){
console.log(data);
},
error:function(jqxr,errorCode,errorThrown){
console.log(jqxr.responseText);
}
});


这篇关于如何获取Office 365的当前用户凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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