SPPermissionCollection.Add Method
NOTE: This API is now obsolete.
Creates a permission object with the specified member and permissions in the collection.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<ObsoleteAttribute("Use the SPRoleAssignmentCollection class instead")> _
Public Sub Add ( _
member As SPMember, _
permissionMask As SPRights _
)
'Usage
Dim instance As SPPermissionCollection
Dim member As SPMember
Dim permissionMask As SPRights
instance.Add(member, permissionMask)
[ObsoleteAttribute("Use the SPRoleAssignmentCollection class instead")]
public void Add(
SPMember member,
SPRights permissionMask
)
Parameters
member
Type: Microsoft.SharePoint.SPMemberAn Member object that represents the member.
permissionMask
Type: Microsoft.SharePoint.SPRightsAn SPRights value that specifies the permissions.
Examples
The following code example modifies the permissions of a group for the Announcements list of the current site.
Dim site As SPWeb = SPContext.Current.Web
Dim destList As SPList = site.Lists("Announcements")
Dim destPermissions As SPPermissionCollection = destList.Permissions
Dim member As SPMember = site.SiteGroups("Group_Name")
destPermissions.Add(member, SPRights.EditListItems Or
SPRights.ViewListItems)
SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Announcements"];
SPPermissionCollection collPermissions = oList.Permissions;
SPMember oMember = oWebsite.SiteGroups["Group_Name"];
collPermissions.Add(oMember, SPRights.EditListItems |
SPRights.ViewListItems);