in my event receiver i have to write the below functionality:
Deny permission for all but one user .
i tried below : but it throws an error on this line :
SPRoleDefinition biffroledefi = CurrentWeb.RoleDefinitions[SPRoleType.None];
how can i deny access for the currentlistitem to the all users in my site collection and then i want to add only one person to access this listitem.
CurrentWeb.RoleDefinitions[SPRoleType.None];
try
{
string currentuserIdd = properties.CurrentUserId.ToString();
...............
...........
CurrentWeb.AllowUnsafeUpdates = true;
CurrentListItem.BreakRoleInheritance(false);
SPRoleAssignment AllBIFRoleassignment = new SPRoleAssignment(myusersGroup);
SPRoleDefinition biffroledefi = CurrentWeb.RoleDefinitions[SPRoleType.None);
AllBIFRoleassignment.RoleDefinitionBindings.Add(biffroledefi);
CurrentListItem.RoleAssignments.Add(AllBIFRoleassignment);
// added on 7 pm 04-june-2014
SPRoleAssignment mroleAssignmentforCurrUser = new SPRoleAssignment(currUser);
SPRoleDefinition mroleDefinitionforCurrUser = CurrentWeb.RoleDefinitions["Full Control"];
mroleAssignmentforCurrUser.RoleDefinitionBindings.Add(mroleDefinitionforCurrUser);
CurrentListItem.RoleAssignments.Add(mroleAssignmentforCurrUser);
this.EventFiringEnabled = false;
CurrentListItem["Author"] = currentuserIdd;
CurrentListItem.Update();
CurrentListItem["Editor"] = currentuserIdd;
CurrentListItem.Update();
this.EventFiringEnabled = true;
CurrentWeb.AllowUnsafeUpdates = false;