Create Permission Level in SharePoint :-
public void CreatePermissionLevels(bool aOverwriteRoleDefinition)
{
SPRoleDefinition aRoleDefinition = null;
SPBasePermissions aBasePermission;
SPRoleDefinition spRoleDefinition = null;
string[] strarrRoleDefName = { "Admin No List Delete"};
string[] strarrRoleDesc = { "Description of admin No list Delete"};
try
{
using (SPWeb oweb = Site.OpenWeb())
{
aRoleDefinition = oweb.RoleDefinitions.GetByType(SPRoleType.Contributor);
aBasePermission = aRoleDefinition.BasePermissions;
spRoleDefinition = null;
for (int i = 0; i < strarrRoleDefName.Length; i++)
{
if (!this.SPRoleDefinitionExists(strarrRoleDefName[i], false))
{
spRoleDefinition = new SPRoleDefinition();
switch (strarrRoleDefName[i])
{
case "Admin No List Delete":
aBasePermission-= SPBasePermissions.ManageLists;
spRoleDefinition.BasePermissions = aBasePermission;
break;
}
spRoleDefinition.Name = strarrRoleDefName[i];
spRoleDefinition.Description = strarrRoleDesc[i];
oweb .AllowUnsafeUpdates = true;
oweb .RoleDefinitions.Add(spRoleDefinition);
oweb .Update();
oweb .AllowUnsafeUpdates = false;
}
}
}
}
}