Tuesday, April 20, 2010

Template ID of SharePoint Libraries and Lists

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

Tuesday, March 30, 2010

Breakroleinheritance takes a long time to excute.

This is an issue in SharePoint Service Pack 1 and hotfix is available here http://support.microsoft.com/kb/941422


http://support.microsoft.com/kb/941422

Or you can upgrade to SharePoint SP 2.

Monday, February 22, 2010

70-541: Enumerate list items.[perform enabling permissions]

using (SPSite spSite = new SPSite("http://testsite"))


{

using (SPWeb objWeb = spSite.OpenWeb())

{

SPUser objUser = objWeb.EnsureUser("manuhsolutions\\samarendra");

SPList objLst = objWeb.Lists["ListName"];

SPListItem lstItem = objLst.GetItemById(1);



// break inheriting parent permissions for this List.

lstItem.BreakRoleInheritance(false);



// assign Role to the defined User

SPRoleDefinitionCollection objWebRoleDefn = objWeb.RoleDefinitions;

SPRoleAssignment objRoleAssign = new SPRoleAssignment(objUser);



// change the name of the role definition to [Contribute]

objRoleAssign.RoleDefinitionBindings.Add(objWebRoleDefn["Contribute"]);



lstItem.RoleAssignments.Add(objRoleAssign);



}

}

70-541: Change a user's permissions to edit a list.

using (SPSite spSite = new SPSite("http://testsite/"))


{

using (SPWeb objWeb = spSite.OpenWeb())

{

SPUser objUser = objWeb.EnsureUser("manuhsolutions\\samarendra");

SPList objLst = objWeb.Lists["ListName"];



// break inheriting parent permissions for this List.

objLst.BreakRoleInheritance(false);



// assign Role to the defined User

SPRoleDefinitionCollection objWebRoleDefn = objWeb.RoleDefinitions;

SPRoleAssignment objRoleAssign = new SPRoleAssignment(objUser);



// change the name of the role definition from [Limited Access] to [Full Control]

objRoleAssign.RoleDefinitionBindings.Add(objWebRoleDefn["Full Control"]);



objLst.RoleAssignments.Add(objRoleAssign);

}

}

70-541: Remove a user from a site group

using (SPSite spSite = new SPSite("http://testsite/"))


{

using (SPWeb objWeb = spSite.OpenWeb())

{

SPUser objUser = objWeb.EnsureUser("manuhsolutions/samarendra");

SPGroup objGroup = objWeb.SiteGroups["Test Group Name"];

objGroup.RemoveUser(objUser);

}

}

70-541: Create a custom SPQuery object.

using (SPSite spSite = new SPSite("http://testsite/"))


{

using (SPWeb objWeb = spSite.OpenWeb())

{



SPList objList = objWeb.GetList(objWeb.Url + "/Lists/" + "ListName");



SPQuery query = new SPQuery();

query.RowLimit = 10;

query.Query = "<Where><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + "Samarendra" + "</Value></Eq></Where>";

SPListItemCollection itemColl = objList.GetItems(query);

if (itemColl.Count > 0)

{

SPListItem lstItem = itemColl[0];

}

}

}