Online Training On SharePoint
                      

Friday, 26 June 2009

Creating a SharePoint List based on a List Template using Object Model

We can create a SharePoint list based on List Template available. We were using SharePoint Object Model to create the lists dynamically based on a specific List template. Following is the code snippet which can be used for this purpose:

SPSite _site = new SPSite("http://localhost");
SPWeb _web = _site.OpenWeb();
SPListTemplateCollection listcoll = _web.Site.GetCustomListTemplates(_web);
_web.Lists.Add("ListName", "List Descriptioon", listtempcol["TemplateName"]);
SPList _list = oweb.Lists["ListName"];
_list.OnQuickLaunch = true;
_list.Update();
_web.Dispose();
_site.Dispose();

Monday, 8 June 2009

Access is not displaying data from SharePoint List

I was working on a SharePoint Site where users were accessing the data from SharePoint Lists using Access. One day they were not able to connect to SharePoint list through Access and the following error was thrown while they were opening SharePoint List:

Earlier it was working fine for these users. The users were having contributor permission level. Upon further investigation it was found that from the contributor permission level two permissions was removed accidentally. Here are those permission:

So if we remove Use Remote Interface and Use Client Integration Feature Permissions from the specific permission level the users can not use the SharePoint integration with access and excel which are associated with that specific permission level. Once these permissions are given the users were able to open the SharePoint list in Access.

Lets see what is the effect of these two permission level
These are the actions which are available when these two permission are given in a SharePoint List:
Once these permissions are removed only following options will be shown to the users in Actions menu in the SharePoint list:

Also various option on document library such as upload multiple document and Open with Windows Explorer are not available if we remove these permissions.

These are the options available when these permissions are there:

Upon removing these permission:


You can reach on any specific permission level by this path:
People and Groups -- Site Permission -- Settings -- Permission Level

Farm Administrator can also remove these permission for the entire web applications from the Central Administration. To do so go to Application Management -- Application Security -- User Permissions for Web Applications and un-check these two permission. In that case no user can access these feature on the Web Application.

Tuesday, 2 June 2009

Finding the Site Definition used to create the Sites in SharePoint

I was working on a big site collection which was having more than 1000 different sub site created using different Site Definitions. I had a task to list all these sub sites and find out the site definitions used to create these sites.

This can be done easily using SharePoint Object Model. The below code will list all the sites and the definition used to create these sites:

SPSite site = new SPSite("SiteURL");
SPWebCollection webs = site.AllWebs;
foreach (SPWeb web in webs)
{
try
{
string template = web.WebTemplate;

Console.WriteLine(web.Url.ToString()+ " : " + template.ToString());
}
finally
{
web.Close();
site.Close();
}
}
Related Posts with Thumbnails