This article describes how to set permissions on a SharePoint list using Kivati. These concepts also apply to webs and list items.
In SharePoint 2007, you can set permissions on webs, lists, and list items. This article describes how to set permissions on a list, but the concept will apply to other objects that have security settings as well.
Note: Depending on your configuration, you may need to break role inheritance on the web containing the list. See the Break Role Inheritance task for more information.
To grant a user permissions on a list:
- Obtain a reference to the list you want to apply permissions to using a task such as Open List or Create List.
- Add a new Get Role Definition by Type task. On this task, set the RoleType property to the role you want to add the user to.
- Add a new Add Role Assignment task. On this task:
- Chain the SecurableObject property from the List property on the task referenced in step 1.
- Chain the DefaultRoleDefinition property from the RoleDefinition property of the task created in step 2.
- Set the LoginName property to a value such as "DOMAIN\username".
- Set the Name property to a value such as "John Doe".
- Set the Email property to a value such as johndoe@domain.com (optional).
- Set the Notes property to a value such as "John can read this list" (optional).
- Build and run your project.
To remove a user's permissions on a list:
- Obtain a reference to the list you want to apply permissions to using a task such as Open List or Create List.
- Add a new Get Role Assignment task. On this task:
- Chain the SecurableObject property from the List property on the task referenced in step 1.
- Chain the WebReference property to the web reference that contains the list.
- Set the PrincipalName property to a value such as "DOMAIN\username".
- Add a new Remove Role Assignment task. On this task:
- Chain the SecurableObject property from the List property on the task referenced in step 1.
- Chain the RoleAssignment property from the RoleAssignment property on the task created in step 2.
- Build and run your project.
You may also want to create and define your own role definitions to define your own custom permissions. You must either do this at the root web of your portal, or you must break role inheritance on the web. To add a new role definition, use the Add Role Definition task:
- Obtain a reference to the web you want to apply permissions to using a task such as Create Site or Open Site.
- Add a new Add Role Definition task. On this task:
- Chain the WebReference property from the web reference on the task referenced in step 1.
- Set the Name property to a value such as "My Role Definition".
- Set the Description property to an appropriate description for the role definition.
- Set the BasePermissions property to a valid combination of permissions for your role definition. More information on this property can be found below.
- If desired, set the OpenOnExists property to true if you want to open the role definition if it already exists.
- Use another task, such as Add Role Assignment, to consume the RoleAssignment property from your new role definition.
The BasePermissions property has the following restrictions and notes:
- EmptyMask cannot be specified with any other setting.
- FullMask cannot be specified with any other setting.
- Some properties depend on others. See the SharePoint documentation for additional details.
Depending on your needs, you may want to create an aggregate to perform these functions. For more information on how to create and manage aggregates, see the Kivati documentation.