Shows how to add, set and remove trustees using the NWVolAdm ActiveX control in Python.
Here I'm using Python for Windows but it's easy to see what's happening..
Lines prefixed with '>>>' are what I typed, '#' begins a comment until end of line.
In Dos Window::
T:\tmp>rights /t
No trustees are assigned for the specified path.
In Python::
from win32com.client import Dispatch
>>> volctrl = Dispatch("NWVolAdmLib.NWVolAdmCtrl.1")
>>> volctrl.FullName = "\\\\PIT\\SYS" # could also use full NDS name
>>> volEntry = volctrl.Entry # get the NWEntry for volume root
>>> tmpEntry = volEntry.Entries["TMP"] # ask nw entry for it's child named 'tmp'
>>> tmpEntry.FullName # confirm we have the correct nwentry
u'\\\\PIT\\SYS\\tmp'
>>> trustee = tmpEntry.Trustees.Add("NDS:\\\\TESTTREE\\MyCompany\\bkc")
# add bkc as trustee, keep the NWTrustee return object
In DOS window::
T:\tmp>rights /t
PIT\SYS:\TMP
User trustees:
BKC [ R F ]
bkc has been added with default rights, lets change them using the NWtrustee object we kept::
>>> trustee.effectiverights.Supervisor = 1
>>> trustee.effectiverights.Create = 1
In DOS window::
T:\tmp>rights /t
PIT\SYS:\TMP
User trustees:
BKC [SR C F ]
You can also get the trustee entry to change existing trustees, like this::
>>> ttee = tmpEntry.Trustees["NDS:\\\\TESTTREE\\MyCompany\\bkc"]
>>> ttee.fullname
u'NDS:\\\\TESTTREE\\MyCompany\\bkc'
You can remove trustees::
>>> tmpEntry.Trustees.Remove("NDS:\\\\TESTTREE\\MyCompany\\bkc")
In DOS window::
T:\tmp>rights /t
No trustees are assigned for the specified path.
Note, you can also use the FindEntry method of volctrl to jump directly to a specific entry, like this::
>>> bradshome = volctrl.FindEntry("\\\\PIT\\SYS\\usr\\bkc")
© 2008 Novell, Inc. All Rights Reserved.