When I try to add do a Role Assignment for my list item.
I keep getting "The user or group 'CompanyRoleProvider: Sample Company' is unknown."
When I add the same "CompanyRoleProvider: Sample Company'" group from site permissions in the site settings, the group resolves fine in the people picker and also gets added to the site permissions.
Below is the code that is causing the error.
-------------------------------------------------------------------------------------------------------------------------------------------
SPRoleAssignment ass = new SPRoleAssignment(companyRoleName, string.Empty, companyName, string.Empty);
ass.RoleDefinitionBindings.Add(ContributeWithoutDelete);
listItem.RoleAssignments.Add(ass);
-------------------------------------------------------------------------------------------------------------------------------------------
As a fix I tried running
Site.EnsureUser(companyRoleName); (Adds the user to the site)
also tried
root.SiteUsers.Add(companyRoleName, "", "", "");
But I am still getting the same error.
Any one with the same issue?