权限被拒绝Sharepoint

时间:2015-04-13 04:19:56

标签: javascript sharepoint client-object-model sharepoint-clientobject

你能帮助我吗?我想检查用户是否在组中,但我无法从组中获取用户。如果当前用户不在组中,我收到错误“访问被拒绝”。如果当前用户在组中,一切正常。

    function checkGroup(){    
    var clientContext = SP.ClientContext.get_current();
    var web = clientContext.get_web();

    var allGroups = web.get_siteGroups();   
    clientContext.load(allGroups); 

    clientContext.executeQueryAsync(function(){
        var count = allGroups.get_count();
        for(i = 0; i < count; i++){
            var grp = allGroups.getItemAtIndex(i);
            if(grp.get_loginName() == 'NDA_ADMINS'){
                var groupUsers = grp.get_users();
                clientContext.load(groupUsers);
                clientContext.executeQueryAsync(function(){
                    userInGroup = false;
                    var groupUserEnumerator = groupUsers.getEnumerator();
                    while (groupUserEnumerator.moveNext()) {
                        var groupUser = groupUserEnumerator.get_current();
                        if(groupUser.get_title() == login) {
                            userInGroup = true;
                            console.log('user is in group');
                            break;
                        }
                    }
                    getProjects('');
                },function(sender,args){
                    alert('Request failed' + args.get_message() + '\n' + args.get_stackTrace());    
                });
            }
        }   

    },function(sender,args){
        alert('Request failed' + args.get_message() + '\n' + args.get_stackTrace());
    });
}

我在这里收到错误:

var groupUsers = grp.get_users();

1 个答案:

答案 0 :(得分:0)

用户是服务器场管理员吗?如果nott并且该组被设置为仅向其他成员显示成员,那么您将失去运气。