Sharepoint Online - How to set item list visibility

Viewed 57

I am preparing a small service which aligns sharepoint-online with SQL data.

Regarding some lists, I have to configure the visibility of the items, to make sure that they are visible (editable) only by a specific user (plus any default group).

I am using the following code,

User usr1 = this.uc.FirstOrDefault(x => x.Title.ToUpper() == oo.ToString().ToUpper());
if (usr1 != null)
{
    RoleDefinitionBindingCollection collRoleDefinitionBinding = new RoleDefinitionBindingCollection(Context);
    RoleDefinition oRoleDefinition = Context.Web.RoleDefinitions.GetByType(RoleType.Editor);
    collRoleDefinitionBinding.Add(oRoleDefinition);
    Principal pa = usr1 as Principal;
    rac.Add(pa, collRoleDefinitionBinding);
}

but it always generates the following error

The object is used in the context different from the one associated with the object.

Can you help me?

Ciao Davide

0 Answers
Related