Published on: 03/27/15 12:45 PM
Category:Javascript SharePoint 2013 Tags: javascript, List, SiteUsersHow to get User Id from Site User if you have User’s active directory name
[code language=”css”]
//Get the id of user from AD name.
function getADNameId(adName) {
var UserData;
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteUsers?$Select=Id,Title&$filter=Title eq ‘" + adName + "’",
type: "GET",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function (data) {
console.log(JSON.stringify(data));
UserData= data.d.results;
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
return UserData;
}
[/code]