I created a list using a provider hosted app. I changed the permissions to that list for a specific usergroup:

private void CreateList(string ListName)
    Web web = clientContext.Web;

    ListCreationInformation listCreationInfo = new ListCreationInformation
        Title = ListName

    var newList = web.Lists.Add(listCreationInfo);

private void AddPermissionsToList(List list)
    Log.DebugFormat("[{0}] AddPermissionsToList", ListName);

    var contributor = AppContext.Web.RoleDefinitions.GetByType(RoleType.Contributor);
    var reader = AppContext.Web.RoleDefinitions.GetByType(RoleType.Reader);

    list.BreakRoleInheritance(false, true);
    list.RoleAssignments.Add(GetPermission(contributorGroup), new RoleDefinitionBindingCollection(AppContext) { "EditUsers"});
    list.RoleAssignments.Add(GetPermission(readerGroup), new RoleDefinitionBindingCollection(AppContext) { "ReadUsers" });


(private Group GetPermission(string permissionName) returns a group when entering the group name as string)

As you can see, the groups "EditUsers" and "ReadUsers" haver write/read permissions to that list.

Now I got the problem that the app itself cannot access the List anymore. It does not even find the lists anymore.

So how can I make sure that the App itself still has access to the lists? (I do not want to add the app to those lists)

1 Answer 1


At the end, it was quite simple. Just get the AppOnly-ClientContext and then the "CurrentUser" returns the App-User which then can be added to the list-permissions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.