close

  本來沒有想過權限議題,因為無法Update Notes Server幾乎是因為無法連線,但在有連線狀態下無法Update資料,大概只有權限了。Notes本身架構算完整了,對映到的Java API的物件體系也很完整,但不敢恭維的是在Exception表示方式,千篇一律像以下的Exception Stack:

NotesException: Notes error: ??????????
    at lotus.domino.NotesExceptionHelper.read(Unknown Source)
    at lotus.domino.NotesExceptionHolder._read(Unknown Source)
    at lotus.priv.CORBA.iiop.RepImpl.invoke(Unknown Source)
    at lotus.priv.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at lotus.domino.corba._IDocumentStub.save(Unknown Source)
    at lotus.domino.cso.Document.save(Unknown Source)
    at lotus.domino.cso.Document.save(Unknown Source)

  上面的Exception是對Notes DB做create document因權限不足引發Exception,而做Update、Delete一定要先search,但也因權限不足導致找不到相符資料可以Update、Delete,也不會有Exception。

  Notes的權限架構在Database物件的ACL,Sample如下:

Session s = NotesFactory.createSession("1.2.3.4:63148", "admin", "password");
Database db = s.getDatabase("pc1234", "TESTDB.NSF");
System.out.println("CurrentAccessLevel:" + db.getCurrentAccessLevel());
ACL acl = db.getACL();
ACLEntry entry = acl.getFirstEntry();
while (entry != null) {
    System.out.println(entry.getName() + ":" + entry.getLevel());
    entry = acl.getNextEntry();
}

  在Database物件設有七個存取等級:

  • 0 - ACLLEVEL_NOACCESS (設為0,導致連search都找不到資料)
  • 1 - ACLLEVEL_DEPOSITOR
  • 2 - ACLLEVEL_READER
  • 3 - ACLLEVEL_AUTHOR
  • 4 - ACLLEVEL_EDITOR
  • 5 - ACLLEVEL_DESIGNER
  • 6 - ACLLEVEL_MANAGER

  之後可以用Iterator方式取得每個ACL Entry,得到每個資源(像LDAP的描述式如:CN=admin/O=mycompany)對該DB的存取權限。更高階的議題下次遇到再說。

arrow
arrow
    全站熱搜

    Jemmy 發表在 痞客邦 留言(0) 人氣()