Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

listItem.RoleAssignments.Add() error. The user or group 'CompanyRoleProvider: Sample Company' is unknown.

$
0
0

 

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?




Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>