I'm trying to give a user rights to...
Articles and Tips: qna
01 Jul 2003
Q.
I'm trying to give a user rights to a home directory, using the Beans for Novell Services. I can create the directory (in the first part of the code below), but assigning an owner to the directory fails.
volAdmBean = new NWVolAdm(); int dir = com.novell.beans.NWVolAdm.NWEntry.DIR; volAdmBean.setFullName(volume); volEntries = volAdmBean.findEntry(parentDir).getEntries(); if (volEntries.addElement(dirName, dir)) { System.out.println("Full: " + volEntries.getElement(dirName). getFullName()); //this is where it starts to fall apart volEntries.getElement(dirName).setOwner(owner); volEntry = volEntries.getElement(dirName); if (volEntry != null) { volEntry.setOwner(owner);
It doesn't appear to be a rights issue because I can set the owner in ConsoleOne with the logged in user.
A.
Rights are given by setting a trustee (the user owning the rights).
// Sets trustee and rights. //In this method: // volume- is an existing NWVolAdm object // parent and child are directories as in // context.vol.parent.child and child // is the directory for which rights are set // trustee is a user object owner of the rights // pathToUser specifies the path to user such as // ".itse.empl.abby.test.ucfv" where "ucfv" is the first // directory under the tree public boolean addTrustee(String parent,String child, com.novell.beans.NWDir.NWEntry trustee, String pathToUser)throws NWBeanException{ int canRead=com.novell.beans.NWVolAdm.NWRights.READ; int canWrite=com.novell.beans.NWVolAdm.NWRights.WRITE; int canCreate=com.novell.beans.NWVolAdm.NWRights.CREATE; int canAccess=com.novell.beans.NWVolAdm.NWRights.ACCESS; int canDelete=com.novell.beans.NWVolAdm.NWRights.ERASE; int canChange=com.novell.beans.NWVolAdm.NWRights.MODIFY; int canScan=com.novell.beans.NWVolAdm.NWRights.SCAN; int defRights=canRead | canWrite | canScan | canDelete | canChange | canCreate; com.novell.beans.NWVolAdm.NWEntry parentEntry=volume. findEntry(parent); if(isFile(parentEntry)) //can't have a File as parent return false; com.novell.beans.NWVolAdm.NWEntries entries=parentEntry. getEntries(); com.novell.beans.NWVolAdm.NWEntry childEntry=entries. getElement(child); com.novell.beans.NWVolAdm.NWTrustees trustees=childEntry. getTrustees(); return trustees.addElement(trustee.getShortName()+pathToUser, defRights); }
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.