How to apply a permission programmatically on particular Forum

I wanted to apply permission "Forum - Read Posts" for the logged user for particular Forum, programmatically from code behind.

How can I do that using any of these Telligent API - In Process or REST ? (without Widget API)

Telligent community 7.6

  • Maybe create a role in the control panel with the desired permission, then add the user to the role programmatically.

  • In reply to Luke D:

    I want to set permission "Forum - Read Posts" to particular Role "Registered Users" for particular Forum ( 'Application' in telligent/zimbra words ) that I will be creating from external form.

  • In reply to Harsh Baid:

    If you look at the global permissions, what are the permissions set for the "Registered Users" role?  Seems like this should already inherit those permissions?

  • In reply to Luke D:

    You are right we can inherit the permissions but that would apply in all the forums.

    I want to set permission for the role to only the newly created Forum.

  • In reply to Harsh Baid:

    First, permissions per user is not a platform feature.  Permissions are applied to roles, roles are applied to users.  You can add users to roles using this API: telligent.com/.../34263.roleusers-in-process-api-service.aspx   or by using the membership model(adding users as memebers to group grants permissions to members).

    As for manipulating permissions per application until 8.0 there is no way for you to do this using an API

  • In reply to Patrick Mason:

    Thanks Patrick for your response.

    Correction: I wanted to apply permission on Role "Registered User" for particular Forum, sample code below.

    Can you please point us to the way we can use this in Telligent/Zimbra 8.0?

    @pmason is right there is not any documented api in Telligent 7.6 but we have used 'Reflector' to find the method, code as below. However we are upgrading to Telligent 8.0 soon, so we can use the in-built mechanism.

    private void AddForum(int groupID, params string[] forumList)
    {
    
    	iForums = Telligent.Common.Services.Get<IForums>();
    
    	roleService = Telligent.Common.Services.Get<IRoleService>();
    
    	Role role = roleService.GetRoleByName("Registered Users");
    
    	foreach (string name in forumList)
    	{
    
    		var forum = iForums.Create(groupID, name);
    
    		IList<PermissionEntry> permissionEntries = new List<PermissionEntry>();
    
    		permissionEntries.Add(new PermissionEntry { PermissionId = "Forum_CreateReply", IsAllowed = true, IsImmediate = true, RoleId = role.Id, NodeId = forum.ApplicationId });
    
    		roleService.AddNodePermissions(forum.ApplicationId, role, permissionEntries);
    
    	}
    
    }
Related