Using SharePoint Web Services to Change Subsite Permissions
page 5 of 5
by Grant Zhang
Feedback
Average Rating: 
Views (Total / Last 10 Days): 40401/ 57

Add, Update Permissions at List Level

In SharePoint, if you don’t define the permissions of a user, a role or a group on a specific list, the permissions that are defined at site level will be inherited. But you can define a unique permission collection for a user, a role, or a group on a specific list. In our example, the manager role has all the list permissions including Manage Lists, Cancel Check-Out, Add Items, Edit Items, Delete Items, and View Items on all the lists, except only Add Items, Edit Items, Delete Items, and View Items on Shared Documents.

We use the same web method to update list permission as we did to update site permissions. Listing 4 shows the code to do that. UpdatePermission is not required and can be combined into AddPermission, but for illustrate purpose, I list them separately.

Listing 4 – Updating role permission on a list

ws_Permissions.Permissions ws = newws_Permissions.Permissions();
NetworkCredential nc = newNetworkCredential(sUserName, sPassword, sDomain);
ws.Credentials = nc;
ws.Url = sOneSubSite +@"/_vti_bin/permissions.asmx";
int iMask = 0x00000001;
ws.AddPermission("Shared Documents","List""Manager""role", iMask);
int iMask2 =0x00000001|0x00000002|0x00000004|0x00000008;
ws.UpdatePermission("Shared Documents","List""Manager""role", iMask2);

Downloads

[Download Sample]

Conclusion

The SharePoint web services that Microsoft has provided are very powerful. Developers can programmatically do everything with SharePoint sites.


View Entire Article

User Comments

Title: SoapServerException   
Name: Raj
Date: 2009-05-26 2:28:10 AM
Comment:
good artical
Title: SoapServerException   
Name: Grant Zhang
Date: 2008-11-06 8:59:26 AM
Comment:
\
\
Title: SoapServerException   
Name: Srinivas Reddy
Date: 2008-11-06 7:23:25 AM
Comment:
\
Title: Reply to Get a Exception on AddRole   
Name: Grant Zhang
Date: 2007-09-05 9:15:04 AM
Comment:
Check details in SoapException and you'll find teh real reason why it failed.
Title: Get a Exception on AddRole   
Name: Dinesh Chaudhari
Date: 2007-09-05 8:54:07 AM
Comment:
Hello ,
This article is very nice to learn SP webservices. I tired the sample with making necessary changes .But i got following Exception :So can you tell me where I go wrong or is there any setting i need to do for removing this exception .I am waiting for reply:
My Conatact Email id: dinchaudhari@gmail.com

Role Manager can not be added to the site: http://ps2454:41300/1100. The error: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

The permissions can not be updated for http://ps2454:41300/1100. The error: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.

The permissions can not be updated for http://ps2454:41300/1100. The error: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.
Title: Using SharePoint Web Services to Change Subsite Permissions   
Name: nak
Date: 2007-06-14 7:24:44 AM
Comment:
good article.
I like it
Title: This Approach is not for MOSS 7   
Name: Sourabh
Date: 2007-06-08 11:14:53 AM
Comment:
Hi all this is not a supported modal for MOSS 7 or sharepoint 2007 instead use the roledefinition as the permission is depricated.
Title: Good Article   
Name: Prasant
Date: 2007-05-23 7:28:18 AM
Comment:
Thanks.. It is working. I was using "AddUserToGroup"..

Thanks again
Title: Good Article   
Name: Prasant
Date: 2007-05-23 7:24:11 AM
Comment:
I have one question:
I am trying to add user to "Contributor" Site group.but it gives error that "Cross-site group cannot be found".

How we can add user to built-in site groups.

Thanks
Title: Excellent Article   
Name: Anil
Date: 2006-12-27 9:43:40 AM
Comment:
Excellent article,this helped me a lot in getting started with Sharepoint web services.Example is too.. good.
Title: Very useful article   
Name: Anupam
Date: 2006-04-05 7:43:36 AM
Comment:
Helped a lots in getting us started with Sharepoint web services.
Title: Useful but   
Name: Anvar
Date: 2006-04-04 3:38:29 AM
Comment:
HI this is a useful and great article.
Will you please give what are parametrs are there in network credential information. Even i am having administrator power i t is not allowing me to get in. please help me.
Title: Great Article   
Name: Niels Hansen
Date: 2006-03-25 8:27:26 PM
Comment:
Great Article. This is exactly the information I was looking for. Please do more on how to progamatically use SPS.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-28 4:21:17 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search