cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with getting permissions of KM documents with KM api

Former Member
0 Kudos

Hello,

I'm developing application which is connected to KM file system and has to get permissions of a file. I'm using the following code:

wdUser = WDClientUser.getCurrentUser();

IUser user = wdUser.getSAPUser();

IResourceContext context = ResourceContext.getInstance(user);

RID ridFile = RID.getRID("/documents/Public Documents/IdM.pdf");

IResource resource;

resource = ResourceFactory.getInstance().getResource(ridFile, context);

// get Security Manager

ISecurityManager securityManager = resource.getRepositoryManager().getSecurityManager(resource);

// get ACLSecurity Manager

IResourceAclManager irm = ((IAclSecurityManager)securityManager).getAclManager();

// get ResourceAcl

IResourceAcl aclrec = irm.getAcl(resource);

The problem is that after getting IResourceAcl aclrec = irm.getAcl(resource); the variable aclrec is null. How can i get the ACL for a resource? I looked at an example for creating an acl at: http://forums.sdn.sap.com/thread.jspa?threadID=1983946 but getting of acl is kind of different task. Is there any way to activate ACL and get a real IResourceAcl not null?

Edited by: Teodor Tanev on Feb 7, 2012 3:10 PM

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Teodor,

A resource might have an ACL set on it, or it might not have an "own" ACL but inheriting one. Your case is the latter.

So getInheritedAcl should do the trick.

Hope it helps

Detlev

Former Member
0 Kudos

Hello Detlev,

I tried but this property is also null. Any other suggestions?

detlev_beutner
Active Contributor
0 Kudos

Hi Teodor,

This should only happen if noone ever has set any ACL on the root (I think it's the initial delivery state; at least it was some years ago). So the question is: Did you check if an ACL on the resource or above in the hierarchy is set?!

Best regards

Detlev

Former Member
0 Kudos

Hello Detlev,

By "Is ACL set" do you mean that permissions of the file have to be set? There is a list of user with permissions that are set in the permissions screen that is opened by clicking on details of the file in KM, after that navigating to settings -> permissions. Are ACL permissions set in some other way? The thing is that i want to get this list of permissions that is opened in the described way in my application so is my approach right?

detlev_beutner
Active Contributor
0 Kudos

Hi Teodor,

> By "Is ACL set" do you mean that permissions of the file have to be set?

Right. And with my last post I especially meant that if no ACL is set explicitely anywhere, then there is an implicite fallback scenario (I think it is "Everyone FullControl" or something similar).

Please check for your file in question not only the ACL, but also the PermissionOwner. Has anyone been set? If yes, there is an ACL set on the resource or somewhere above within the hierarchy; if not, you are working in the default delivery with no explicit ACL set anywhere. (If anyone sets an ACL explicitely somewhere, this is the first moment a permission owner is set (that is then the user setting the first explicit ACL).)

In general, to be safe, to get an ACL on a resource, you first check getAcl, if null you check getInheritatedAcl, if this is still null, createAcl. But as said, before you implement this, please check if you see a permission owner. You should not with your results so far. In that case, my second answer was already pointing the the explanation for the behaviour you have realized.

Hope it helps

Detlev

Answers (1)

Answers (1)

Former Member
0 Kudos

Also if the inherited value is null I check if the parent of the RID has also ACL and it really does. So now the problem is solved. Thanks a lot.