Share via


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

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);

See Also

Reference

SPPermissionCollection Class

SPPermissionCollection Members

Microsoft.SharePoint Namespace