Select the search type
  • Site
  • Web
Search
You are here:  Support/Forums
Support

Bring2mind Forums

Adding permissions to a folder
Last Post 02/05/2013 8:52 PM by Synoptek Web Team. 2 Replies.
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Synoptek Web Team
New Member
New Member
Posts:10


--
02/04/2013 9:31 PM
I am using DMX v6.1.3 and am trying to add a folder and set permissions using the API.

The following function is adding the folder correctly, but not setting any permissions. I am guessing it is because I am doing something wrong with the EntryPermissionCollection.

public EntryInfo AddPropertyDocumentRepository(PortalSettings portalSettings, string propertyName)
{
var locale = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
var portalId = portalSettings.PortalId;
var propertiesFolder = API.GetFolderByPath(portalSettings.PortalId, 0, "Properties", locale , true);
var propertyRole = GetPropertyRole(portalId, propertyName);

//TODO: These permissions are not being saved with the new folder. It may be because the EntryID is -1.
var permissions = new EntryPermissionCollection();
permissions.AddPermission(portalSettings.PortalId, -1 , "VIEW", propertyRole.RoleID, -10);
permissions.AddPermission(portalSettings.PortalId, -1 , "EDIT", propertyRole.RoleID, -10);
permissions.AddPermission(portalSettings.PortalId, -1 , "ADD", propertyRole.RoleID, -10);

//TODO: Need to add permissions for the 'Administrators' role.
permissions.AddPermission(portalSettings.PortalId, -1, "VIEW", portalSettings.AdministratorRoleId, -10);
permissions.AddPermission(portalSettings.PortalId, -1, "EDIT", portalSettings.AdministratorRoleId, -10);
permissions.AddPermission(portalSettings.PortalId, -1, "ADD", portalSettings.AdministratorRoleId, -10);



var propertyFolder = API.AddFolder(portalSettings.PortalId, propertiesFolder.EntryId, propertyName, portalSettings.UserInfo, permissions);

return propertyFolder;
}
Peter Donker
Veteran Member
Veteran Member
Posts:4536


--
02/05/2013 8:11 PM
Hi,

You could also use these API calls from DMX.Security.Permissions.EntryPermissionsController:

Public Shared Sub AddRolePermission(ByVal PortalId As Integer, ByVal EntryId As Integer, ByVal PermissionKey As String, ByVal RoleId As Integer)
Public Shared Sub AddUserPermission(ByVal PortalId As Integer, ByVal EntryId As Integer, ByVal PermissionKey As String, ByVal UserId As Integer)

I'll make a note to add a more concise API call in a future version.

Peter
Synoptek Web Team
New Member
New Member
Posts:10


--
02/05/2013 8:52 PM
Thank you. That did the trick!
You are not authorized to post a reply.