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)

public SPPolicy Add(
	string userName,
	string displayName


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.

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.

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.