Share via


SPPolicyCollection.Add method

Creates a policy in the collection based on the specified user name and policy display name.

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

Syntax

'Declaration
Public Function Add ( _
    userName As String, _
    displayName As String _
) As SPPolicy
'Usage
Dim instance As SPPolicyCollection
Dim userName As String
Dim displayName As String
Dim returnValue As SPPolicy

returnValue = instance.Add(userName, displayName)
public SPPolicy Add(
    string userName,
    string displayName
)

Parameters

  • userName
    Type: System.String

    A string that specifies the user name. A string in the User Principal Name (UPN) format (for example, bob@contoso.com) should not be used.

  • displayName
    Type: System.String

    A string that specifies the display name of the policy or an empty string.

Return value

Type: Microsoft.SharePoint.Administration.SPPolicy
An SPPolicy object that represents the new policy.

Remarks

If the collection already contains a policy for the specified user or group, the Add method appends the new policy roles to the existing roles for that user or group. For example, if a user already has a DenyWrite permission and you add a policy for the same user that grants DenyAll, the user gets both DenyWrite and DenyAll rights.

See also

Reference

SPPolicyCollection class

SPPolicyCollection members

Microsoft.SharePoint.Administration namespace