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];

}

}

}

70-541: Add a user to a site group

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


{

using (SPWeb objWeb = objSite.OpenWeb())

{

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

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

objGroup.AddUser(objUser);
 
}
 
}

Wednesday, February 10, 2010

How to increase the size limitation while you save site as template include content in MOSS 2007

By using the STSADM command , you can maximize the size limitation while you wish to save site as template include the content.

command:
stsadm -o setproperty -pn max-template-document-size -pv 52428800

(52428800 is in byte format which is equal to 50 Mega Byte)



enjoy.......