Changing Access Rights of a User for a Folder

After you grant privileges to a user, you might need to change the access rights for that user on a folder. To do so, you use the following procedure:

  1. Get the access control list.

  2. Create a new entry for the user whose access rights you want to change.

  3. Call the addEntries method of the access control list, passing the new entry in a vector. The new entry will replace the previous entry for that user.

Important: In order for one user to change or grant privileges to another user on a folder, the grantor must have FULL_CONTROL privileges for that folder.

Example: Changing the access rights of a user

The following code example changes the access rights for a single user of a folder. This code constructs a new entry for John Jones, giving him WRITE privilege, and it adds the entry to the access control list. This code assumes that a PersistenceManager called pmMyFolder exists and that the user of this code has FULL_CONTROL privileges for the MyFolder folder.


//create the vector and the new entry Vector entries = new Vector(); AclEntry newEntry =   new AclEntryImpl(new UserImpl("John Jones"), Privilege.WRITE); // add the new entry to the vector entries.addElement(newEntry); try{   // get the access control list for MyFolder   AclObject acl = (AclObject) pmMyFolder.getAcl();   // add the new entry to the acl object   // the new entry overwrites the previous entry for John Jones   // the true argument grants the same access for the same users   // to the subfolders of MyFolder   acl.addEntries(entries, true); } catch (NamingException ne){   ne.printStackTrace(); }