-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.js
44 lines (39 loc) · 1.62 KB
/
users.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* get site users information */
function getCurrentUserId() { return _spPageContextInfo.userId; }
function getSimpleLoginName() { return _spPageContextInfo.userLoginName; }
function getFullLoginName(onSuccess, onError) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + '/_api/web/getuserbyid(' + _spPageContextInfo.userId + ')',
method: 'GET',
headers: { 'Accept': 'application/json;odata=verbose' },
success: function (data) { onSuccess(data.d.LoginName); },
error: function (data) { onError(data); }
});
}
function getCurrentUserName(onSuccess, onError) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + '/_api/web/getuserbyid(' + _spPageContextInfo.userId + ')',
method: 'GET',
headers: { 'Accept': 'application/json;odata=verbose' },
success: function (data) { onSuccess(data.d.Title); },
error: function (data) { onError(data); }
});
}
function getUserName(userId, onSuccess, onError) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + '/_api/web/getuserbyid(' + userId + ')',
method: 'GET',
headers: { 'Accept': 'application/json;odata=verbose' },
success: function (data) { onSuccess(data.d.Title); },
error: function (data) { onError(data); }
});
}
function getAllSiteUsers(onSuccess, onError) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + '/_api/web/siteusers',
method: 'GET',
headers: { 'Accept': 'application/json;odata=verbose' },
success: function (data) { onSuccess(data.d.results); },
error: function (data) { onError(data); }
});
}