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

Update Role Permissions at Site Level

You can set permissions when you add roles. So updating role permissions at site level is not necessary for the tasks here. But sometimes developers need to change permission after a SharePoint site goes live and roles have been created, so I added this method here for illustration purposes.

The permissions for SharePoint sub sites can be set at two levels: site level and list level. The Permissions service provides methods for working with the permissions for a site or list. The URL for this web service is http://Server_Name/[sites/][Site_Name/]_vti_bin/Permissions.asmx. For example, if the sub site URL is http://testserver/sites/granttest/GRANTTEST2/default.aspx, then the web service URL is http://testserver/sites/granttest/GRANTTEST2/ vti_bin/Permissions.asmx. No matter at which level the sub site resides, this service is always available. This is different than some of the services that are only available to the top level site.

The UpdatePermission method of the Permissions service modifies site-level permissions for the specified site group, or modifies permissions to the list for the specified user, site group, or cross-site group. Its input parameters are defined as follows:

·         objectName   A string that contains the name of the list or site. It can be an empty string if it is a site.

·         objectType   A string that specifies either List or Web.

·         permissionIdentifier   A string that contains the name of the site group, the name of the cross-site group, or the user name (DOMAIN\User_Alias) of the user to whom the permission applies.

·         permissionType   A string that specifies user, group (cross-site group), or role (site group). The user or cross-site group has to be valid, and the site group has to already exist on the site.

·         permissionMask   A 32-bit integer that specifies the new permission mask (See table 1).

Listing 3 – Update permissions at site level

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 = 0x00000400|0x00000800|0x00000100|0x00000002|0x00000004|0x00000008
ws.UpdatePermission("""Web","Manager""role", iMask);

View Entire Article

User Comments

Title: SoapServerException   
Name: Raj
Date: 2009-05-26 2:28:10 AM
good artical
Title: SoapServerException   
Name: Grant Zhang
Date: 2008-11-06 8:59:26 AM
Title: SoapServerException   
Name: Srinivas Reddy
Date: 2008-11-06 7:23:25 AM
Title: Reply to Get a Exception on AddRole   
Name: Grant Zhang
Date: 2007-09-05 9:15:04 AM
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
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:

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
good article.
I like it
Title: This Approach is not for MOSS 7   
Name: Sourabh
Date: 2007-06-08 11:14:53 AM
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
Thanks.. It is working. I was using "AddUserToGroup"..

Thanks again
Title: Good Article   
Name: Prasant
Date: 2007-05-23 7:24:11 AM
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.

Title: Excellent Article   
Name: Anil
Date: 2006-12-27 9:43:40 AM
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
Helped a lots in getting us started with Sharepoint web services.
Title: Useful but   
Name: Anvar
Date: 2006-04-04 3:38:29 AM
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
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  |  Page Processed at 2024-04-15 7:06:41 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search