SharePoint workflow task Permissions

Source: Internet
Author: User

Scenario 1: A workflow customized using SharePoint designer or a workflow provided by a template

You can use the eventhandler Extension Method to add the permission control statement to the itemadded eventhandler task list of the new task.

Only assign the permission of the current item to the task assign to object, or assign the read-only permission to other users. 

Code
Private   Void Setownerasonlyeditor (splistitem item)
{
Spweb myweb1 = Item. Web;

/**/ /**/
/**/ ////Get the task owner from the item. 'assigned to 'is a built-in property, so it shoshould be in all lists.
String Authorvalue = Item [ " Assigned " ]. Tostring ();

Spfielduservalue authoruservalue =   New Spfielduservalue (myweb1, authorvalue );

Spuser authoruser = Authoruservalue. user;

// Break the security of the item from the list, but keep the Permissions

Item. breakroleinheritance ( True );

Sproleassignment roleassignment =   New Sproleassignment (authoruser. loginname, authoruser. Email, authoruser. Name, authoruser. Name );
Roleassignment. roledefinitionbindings. Add (myweb1.roledefinitions [ " Contribute " ]);


Foreach (Sproleassignment roleassignment In Item. roleassignments)
{
// Delete the existing Permissions
Roleassignment. roledefinitionbindings. removeall ();
// Add the reader permission

// Change the permissions of everyone with access to this item so they are readers only
Roleassignment. roledefinitionbindings. Add (myweb1.roledefinitions [ " Read " ]);
Roleassignment. Update ();
// Item. Update ();

}
Item. roleassignments. Add (roleassignment );
Item. Update ();

}

 

Source code

Scenario 2: Custom workflows using vs2005 Encoding 

Assign a value to the specialpermission attribute in createtask, and write the user to which the permission is to be granted.
Note the following two points:
1. To use specialpermission, you must first define a global public variable.
Public hybriddictionary task1permission = new hybriddictionary ();
2To assign this new variable to the specialpermission attribute of createtask, click the blue exclamation point next to the specialpermission attribute. This will bring up the property binding window to bind this variable.

 

 

After the above two points are completed, you can implement permission control.
KeyCodeYes:
Task1permission. Add (taskprops. assignedto,Sproletype. Contributor );

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.