dimanche 22 mars 2015

is web.get_siteGroups() work with all site users including visitors



I need to validate if the current user whiten specific group using JavaScript, but first i want to make sure is the following code work with all site users including visitors (read only permission):



var context = new SP.ClientContext.get_current();
var web = context.get_web();
var user = context.get_web().get_currentUser();
var groups = web.get_siteGroups();
var group = groups.getByName("Managers");
var groupUsers = group.get_users();

context.load(user);
context.load(groups);
context.load(group);
context.load(groupUsers);

context.executeQueryAsync(success, failure);

function success(sender, args) {
var userInGroup = false;
var enumerator = groupUsers.getEnumerator();
while (enumerator.moveNext()) {
var tempUser = enumerator.get_current();
if (tempUser.get_id() == user.get_id()) {
//TODO
break;
}
}
}

function failure(sender, args) {
}


In another word, is the above code need any specific permeation to execute. as example, accessing information about all site groups is allow for read only permission?








0 commentaires:

Enregistrer un commentaire