Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Is there an API to return a dataset of tree nodes that user has permissions to View modes: 
User avatar
Certified Developer v6
Certified Developer v6
hoppe - 7/25/2012 3:49:22 PM
   
Is there an API to return a dataset of tree nodes that user has permissions to
I have the following code:
var tree = new TreeProvider(CMSContext.CurrentUser);
using (DataSet nodes = tree.SelectNodes(CMSContext.CurrentSiteName,
String.Empty, String.Empty, true, String.Empty, where, "[DocumentModifiedWhen] DESC", -1, true, 20, "DocumentName, NodeAliasPath, DocumentCulture, ClassName, NodeID"))


This seems to return nodes regardless of the permissions set on them. I.e., I have a user who does not have read permission on a node, the node is still returned by this function call, despite being initialized in the context of the user.

Is there an API call to return a dataset of nodes that the user has read permission(s) to?

Or, do I then need to filter the results using TreeSecurityProvider.FilterDataSetByPermissions(documents,
NodePermissionsEnum.ModifyPermissions, user);?

Thanks!
Joe Hoppe

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 8/8/2012 9:32:30 AM
   
RE:Is there an API to return a dataset of tree nodes that user has permissions to
Hi,

It seems that noone else wants to answer, so I'll try:

Yes, you will then need to filter the results by the TreeSecurityProvider.FilterDataSetByPermissions, just for Read permissions mentioned in your question, the permission enum would be different than Modify :)

This separation is present to allow selecting the documents without permissions, as it's quite resources-consuming filter task. In practice, it is used on a background of the web part security setting "Check permissions"...

Anyway, our developers are already discussing possible revisions and improvements to add the permissions check switch to the SelectNodes (-Documents) methods directly to make the things easier.

Should you need any additional details, please feel free to ask.

Regards,
Zdenek

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 8/9/2012 2:35:58 PM
   
RE:Is there an API to return a dataset of tree nodes that user has permissions to
I was wondering why Kentico doesn't filter by permissions in the database. It seems as though it already manipulates queries quite a bit when it queries the document tree, why not pass in the UserID and manipulate the query to filter out nodes that the user does not have permission to read?

I noticed that if you specify to check permissions when you are select a Top N of tree nodes, it retrieves ALL of the data for the query and then filters for permissions and then returns the TOP N results from that. While that definitely solves the problem where you may select the top 3 nodes from a table with a thousand nodes and it could return nothing because, out of that thousand nodes , the user does not have read permissions on the top 3. It does return every row from the query AND has to run a process on each datarow retrieved. If you were to simply modify the queries to filter out the rows at the database level, it should work more efficiently.


User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 8/23/2012 5:59:26 AM
   
RE:Is there an API to return a dataset of tree nodes that user has permissions to
Hello,

You have a good point, it makes sense.
There are some improvements planned in this matter for the future versions, I will forward your feedback to the developers and check if there's anything going on and optionally let you know.
Thanks again.

Kind regards,
Zdenek