//
// Include JQuery reference
// ... script continues ...
// 0#.w|domain\user
/// username should be passed as 'domain\username'
function GetUserId(userName) {
/// change this prefix according to the environment.
/// In below sample, windows authentication is considered.
var prefix = "VIC\\";
/// get the site url
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
/// add prefix, this needs to be changed based on scenario
var accountName = prefix + userName;
/// set domain Name
/// make an ajax call to get the site user
$.ajax({
url: siteUrl + "/_api/web/siteusers(@v)?@v='" +
encodeURIComponent(accountName) + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
///popup user id received from site users.
alert("Received UserId" + data.d.Id);
alert(JSON.stringify(data));
},
error: function (data) {
console.log(JSON.stringify(data));
}
});
}