AnsweredAssumed Answered

Get access permissions

Question asked by tsx on May 22, 2008
I have a content node. As an admin, is there a way to get names and all the permission a user has for a node using the web service api?

Here is what I have right now. From what I understand the code below does not handle inherited authorities/permissions. Is there a better way to find out than recursively looking up at the parents for permissions? Or is there a method that checks if a user X has permissions to a given node Y (looks like hasPermissions method checks only for currently authenticated user)?

Any help would be appreciated.

-tanmay


private static List<String> getACL(
            AccessControlServiceSoapBindingStub accessService,
            Reference reference) throws AccessControlFault, RemoteException {

        System.out.println("Getting ACL for " + reference.getUuid());

        List<String> acls = new ArrayList<String>();

        Predicate predicate = new Predicate();
        predicate.setNodes(new Reference[] { reference });

        ACL[] aclArray = accessService.getACLs(predicate, null);

        for (ACL acl : aclArray) {
            ACE[] aces = acl.getAces();
            if (aces != null) {
                for (ACE ace : aces) {
                    System.out.println("Permissions -> " + ace.getAuthority()
                            + " : " + ace.getPermission());
                }
            }
        }

        return acls;

    }

Outcomes