hi,
i am trying to read the Tasks list in my sub site programmatically and trying to break the role inheritance and apply contribute permissions to a set of users.
but when i
private bool ApplyContriToTasklistforSubSite(string strBIFNodePathhURL, IList<SPUser> spuserCollecApprovers)
{
bool isPermiApplied =false;
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite subNodeSite = new SPSite(strBIFNodePathhURL))
{
using (SPWeb subNodeWeb = subNodeSite.OpenWeb())
{
subNodeWeb.AllowUnsafeUpdates = true;
SPList splistTasksList = subNodeWeb.Lists.TryGetList("Tasks");
if (!splistTasksList.HasUniqueRoleAssignments)
splistTasksList.BreakRoleInheritance(true);
foreach(SPUser singleeUser in spuserCollecApprovers)
{
//SPGroup _singleWebCurentSelectedGroup = subNodeSiteforCTypeWeb.SiteGroups[currSelectedGroupNameforCType];
SPRoleAssignment _singleWebRoleAssignment = new SPRoleAssignment(singleeUser);
SPRoleDefinition _singleTaskRoleDefinition = subNodeWeb.RoleDefinitions["Contribute"];
_singleWebRoleAssignment.RoleDefinitionBindings.Add(_singleTaskRoleDefinition);
splistTasksList.RoleAssignments.Add(_singleWebRoleAssignment);
}
splistTasksList.Update();
subNodeWeb.AllowUnsafeUpdates = false;
}
}
});
}
catch(SPException spekl) { }
return isPermiApplied;
}
Any idea what may be the reason for this.