SPList.HasUniqueRoleAssignments Property

Gets a Boolean value that specifies whether the list has unique security settings or whether it inherits its role assignments from a parent object.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

Public ReadOnly Property HasUniqueRoleAssignments As Boolean
    Get

Dim instance As SPList
Dim value As Boolean

value = instance.HasUniqueRoleAssignments
public bool HasUniqueRoleAssignments { get; }

Property Value

Type: System.Boolean
true if the list has unique security settings; otherwise, false.

Implements

ISecurableObject.HasUniqueRoleAssignments

Remarks

There is not a method to retrieve user role assignments on a Windows SharePoint Services list object. However, the code below allows you to retrieve this list.

private void AddListRoleAssignmentNodes(SPList objList)
{ 
   try
   {
      if (objList.HasUniqueRoleAssignments)
      {
         SPRoleAssignmentCollection oRoleAssignments =
            objList.RoleAssignments;

         foreach (SPRoleAssignment oRoleAssignment in oRoleAssignments)
         {
            SPPrincipal oPrincipal = oRoleAssignment.Member;
            try
            {
               // Retrieve users having explicit permissions on the list
               SPUser oRoleUser = (SPUser)oPrincipal;
            }
            catch (Exception ex)
            {
               string msg = ex.Message;
            }
            try
            {
               // Retrieve user groups having permissions on the list
               SPGroup oRoleGroup = (SPGroup)oPrincipal;

               if (oRoleGroup.Users.Count > 0)
               { 
                  string strGroupName = oRoleGroup.Name;
                  // Add code here to retrieve Users inside this User-Group
               }
            }
            catch (Exception ex)
            {
               string msg = ex.Message;
            }
         }
      }
   }
   catch (Exception ex)
   {
      string msg = ex.Message;
   }
}

See Also

Reference

SPList Class

SPList Members

Microsoft.SharePoint Namespace