2016-04-14 108 views
0

我試圖根據使用SharePoint Rest API的組名稱獲取SharePoint用戶組權限(例如:Read,Contribute)。我的目標是根據權限級別獲取組的權限級別並禁用我們的自定義應用中的功能。我已經嘗試了下面的URL來獲取組屬性,但無法獲得組的權限級別。任何人都可以請指導我如何獲得用戶組權限。基於組名稱獲取SharePoint組權限級別名稱使用SharePoint Rest API

選項嘗試:

URL = http://Servename/Site/api/web/SiteGroups/getByName( '組名')

回答

0

下面的信息返回用戶組權限級別冠軍和休息的功能:

function init() {  
    clientContext = new SP.ClientContext.get_current(); 
    oWeb = clientContext.get_web(); 
    currentUser = oWeb.get_currentUser(); 
    allGroups = currentUser.get_groups(); 
    clientContext.load(allGroups); 

    clientContext.executeQueryAsync(OnSuccess, OnFailure); 
    function OnSuccess() { 
     var grpsEnumerator = allGroups.getEnumerator(); 

     while (grpsEnumerator.moveNext()) {   
     var group = grpsEnumerator.get_current(); 
     var grpTitle = group.get_title(); 
     var grpid = group.get_id(); 
     console.log('Group Id :' + grpid); 
     console.log('Group Title :'+ grpTitle); 

     roleBindings = oWeb.get_roleAssignments().getByPrincipalId(grpid).get_roleDefinitionBindings(); 
     clientContext.load(roleBindings); 

      clientContext.executeQueryAsync(function() { 
       var iterator = roleBindings.getEnumerator(); 
       while (iterator.moveNext()) { 
        current = iterator.get_current(); 
        console.log('Show Role Defination Title : '+ current.get_name()); 

        } 
      }); 
     } 
    } 

    function OnFailure(){ 
    console.log('Process Failed'); 
    } 
}