Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Vishnu Shanmughan 7 posts 78 karma points
    Sep 20, 2018 @ 13:56
    Vishnu Shanmughan
    0

    Programatically add folder permission to user

    I can see its possible to add start node for each user manually is there any way to add start node for user programatically ? or add user permission to a particular folder using c# code

  • Kevin Jump 2342 posts 14869 karma points MVP 8x c-trib
    Sep 20, 2018 @ 15:00
    Kevin Jump
    1

    HI

    you can set the start nodes, using the UserService for example :

    var user = Services.UserService.GetUserById(myUserId);
    user.StartContentIds = new int[] { contentId, anotherContentId };
    Services.UserService.Save(user);
    

    equally you can add and remove permissions on nodes using the AssignUserGroupPermission and ReplaceUserGroupPermissions functions on the user service

    var edtiorGroup = Services.UserService.GetUserGroupByAlias("editor");
    Services.UserService.AssignUserGroupPermission(edtiorGroup.Id, 'U', new int[] { 1412 });
    

    again you need to know your content Ids first (use the ContentService) and you will need to reference the User Permission Codes to understand what letters to set on permissions.

Please Sign in or register to post replies

Write your reply to:

Draft