1

I am actually coding in JAVA and got some problems when a particular user is trying to update/ delete an entry an another user's lotus Calendar.

There are two users userA and userB. userA has only "read" rights on the calendar of userB. As a matter of fact when userA is trying to update the calendar of userB , I have the following error since userA has only read rights:

NotesException: Notes error: You are not authorized to perform that operation

What I want to do in java , is to check whether userA has read rights or edit rights before proceeding to update the calendar of userB.

4

1 回答 1

3

使用“queryAccess” - Database- 类的方法,您可以找出当前的访问级别。如果此访问级别 > ACL.LEVEL_AUTHOR,那么用户肯定可以写入日历。

如果访问权限较低,那么事情就会变得有点复杂。

日历文件很特别。它们被称为“公共文件”。因此,访问级别并不是正确访问的唯一指标。

有两种可能性,用户可以获得“阅读”权限——访问日历文档:

访问级别 >= ACL.LEVEL_READER 或用户在 Acl 中启用了“读取公共文档”。

这可以使用数据库类的“queryAccessPrivileges”方法进行检查。

为了能够编写日历条目,必须启用“编写公共文档”。

这是代码,它尊重所有这些方面:

import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();

          Database db = agentContext.getCurrentDatabase();
          String user = session.getUserName();
          int accLevel = db.queryAccess(user);
          int accPriv = db.queryAccessPrivileges(user);
          boolean blnCanWriteCalendar = false;
          boolean blnCanReadCalendar = false;
          blnCanWriteCalendar = ((accPriv & Database.DBACL_WRITE_PUBLIC_DOCS) > 0)
               | accLevel > ACL.LEVEL_AUTHOR;
          blnCanReadCalendar = ((accPriv & Database.DBACL_READ_PUBLIC_DOCS) > 0)
               | accLevel >= ACL.LEVEL_READER;

      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}
于 2013-07-16T11:22:53.000 回答