A SharePoint site and its contents can not only be created
and updated manually, but also programmatically. Microsoft has provided
SharePoint class libraries and web services for this purpose. I was involved in
programmatically creating SharePoint sites, adding and updating web parts,
setting permissions, changing lists etc., basically working with every aspect
of SharePoint sub sites. I found generally if anything can be done manually, it
can also be done programmatically. In this article, I'd like to introduce how
to use SharePoint web services to loop through all the sub sites to add roles,
add users to site roles, and update role permissions on site and list levels.
In the attached example program, I’ll accomplish the
following tasks:
·
Work with many sub sites under a top level site;
·
Add a Manager role and add a user “us\grant” to this role in
every sub site;
·
Customize the permissions of the Manager role in every sub site;
·
Customize the permissions of the Manager role to the "Shared
Document" library for every sub site.
The sample program will work only if you update the web
services with the valid URL and change the network credentials to the correct
user name and password.
System Requirements
The server has to be Microsoft Office SharePoint Portal
Server 2003. The development system can be any Windows system with Microsoft
Visual Studio .NET 2003 installed. When calling the web services, the network
credential passed in must have the corresponding permissions on the site.