Version 7.x > API > Setting User Role Permissions for Document Types through API View modes: 
User avatar
alang-atlas-advertising - 11/5/2013 1:57:57 PM
Setting User Role Permissions for Document Types through API
I'm attempting to generate Roles through API code and am looking to set a series of Permissions for the Role that are based on Document Types. Using code like the following, I've been able to add the Permissions for Modules where ResourceName is the code name for the Module, and PermissionName is a Permission defined for the Module:

PermissionNameInfo permission = PermissionNameInfoProvider.GetPermissionNameInfo(PermissionName, ResourceName, null);
if (permission != null)
RolePermissionInfo newRolePermission = new RolePermissionInfo();
newRolePermission.PermissionID = permission.PermissionId;
newRolePermission.RoleID = RoleID;

But I have been unable to get it to successfully add Permissions for Document Types. I've tried using the same code just using the Document Type code name for ResourceName (I've also tried it for the ClassName parameter), but it does not work. Is there a different method that should be used for assigning Permissions for Document Types to a Role? Or is it not possible to do through the API?

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/12/2013 2:47:29 AM
RE:Setting User Role Permissions for Document Types through API
Hi Alan,

Thank you for your message.

What do you mean by settings permission to document type? Document types does not have any permission (you can see in Site manager -> Development -> Document types)

Are you trying to set permission to a document? If so please checkout the http://devnet.kentico.com/docs/devguide/index.html?document_permissions_api_overview.htm

Could you maybe more elaborate on the issue you are trying to do?

Kind regards,
Richard Sustek