var finalusersId = "";
$.each(users, function () {
$.ajax({
url: webUrl + "/_api/web/siteusers(@v)?@v='"+encodeURIComponent(this.Key)+"'",
type: "GET",
async: false,
headers: {
"Accept": "application/json;odata=verbose",
},
cache: false,
success: function (data) {
var result=data.d;
finalusersId=result.Id;
},
error: function (data) {
}
});
});
//根据用户登录名获取ID
function getUserIdByLoginName(loginName) {
var context = new SP.ClientContext.get_current();
this.user = context.get_web().ensureUser(loginName);
context.load(this.user);
context.executeQueryAsync(
Function.createDelegate(null, ensureUserSuccess),
Function.createDelegate(null, onFail)
);
}
function ensureUserSuccess() {
alert(this.user.get_id())
}