Thursday 3 July 2014

List Template IDs in Sharepoint 2010



Template ID List Name
100 Generic list
101 Document library
102 Survey
103 Links list
104 Announcements list
105 Contacts list
106 Events list
107 Tasks list
108 Discussion board
109 Picture library
110 Data sources
111 Site template gallery
112 User Information list
113 Web Part gallery
114 List template gallery
115 XML Form library
116 Master pages gallery
117 No-Code Workflows
118 Custom Workflow Process
119 Wiki Page library
120 Custom grid for a list
130 Data Connection library
140 Workflow History
150 Gantt Tasks list
200 Meeting Series list
201 Meeting Agenda list
202 Meeting Attendees list
204 Meeting Decisions list
207 Meeting Objectives list
210 Meeting text box
211 Meeting Things To Bring list
212 Meeting Workspace Pages list
301 Blog Posts list
302 Blog Comments list
303 Blog Categories list
1100 Issue tracking
1200 Administrator tasks list

Tuesday 1 July 2014

Access denied using SPSecurity.RunWithElevatedPrivileges - Sharepoint 2010

SPSecurity.RunWithElevatedPrivileges - Sharepoint 2010

--Executes the specified method with Full Control rights even if the user does not otherwise have Full Control.

Whenever we use SPSecurity.RunWithElevatedPrivileges(), it will execute the code under the context of Application Pool identity. Now we can see a scenario where we will get the “Access denied” exception from the code block even if you use SPSecurity.RunWithElevatedPrivileges.

Using SharePoint context with an unauthenticated user does not actually elevate privileges:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // do something with SPContext.Current.Web 
    // fails with a AccessDenied Exception
    // because SPContext is loaded with the site,
    // not within this delegate block.
   // if anonymous user logged in, context will be loaded with the ANONYMOUS USER's only.
});

So to get actual elevated privileges (i.e., App Pool Identity), you have to reload the context:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    using (SPSite site = new SPSite(SPContext.Current.Web.Site.Url))
    {
        using (SPWeb oWeb = site.OpenWeb())
        {
            // do something with oWeb
                    // oWeb is loaded with the Application pool identity
        }
    }
});


Happy Coding J..