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.

Armand
  • 726
  • 11
  • 29
user2002713
  • 11
  • 1
  • 3

1 Answers1

3

Using the "queryAccess" - Method of the Database- class, you can find out the current access level. If this access- level is > ACL.LEVEL_AUTHOR then the user can for sure write to the calendar.

If the access is lower, then things become a little more complicated.

Calendar document are something special. They are so called "Public documents". Therefor the access- level is not the only indicator for the right access.

There are two possibilities, a user can gain "read"- access to calendar documents:

access level >= ACL.LEVEL_READER OR user has "Read Public documents" enabled in the Acl.

This can be checked using the "queryAccessPrivileges"- method of the database class.

To be able to write calendar entries, one has to have "Write Public documents" enabled.

Here is code, that respects all of these aspects:

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();
       }
   }
}
Tode
  • 11,795
  • 18
  • 34
  • thank you very much sir, i have implemented it but this returns me whether the user has Author/depositor/access.. rights. dbMail = notesSession.getDatabase(doc.getItemValueString("MailServer"), doc.getItemValueString("MailFile")); int accLevelCal = dbMail.queryAccess(notesSession.getUserName()); String titleMail = dbMail.getTitle(); i am still unable to retrieve the read/edit/delete rights on the users Calendar. Any help – user2002713 Jul 17 '13 at 06:11