Examples: registerNewUser method

  1. This agent registers jyip.id with cert.id.
    import lotus.domino.*;
    import java.util.Vector;
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Registration reg = session.createRegistration();
          reg.setRegistrationServer("AceOne");
          reg.setCreateMailDb(false);
          reg.setCertifierIDFile("d:\\NotesAdministrator\\cert.id");
          DateTime dt = session.createDateTime("Today");
          dt.setNow();
          dt.adjustYear(1);
          reg.setExpiration(dt);
          reg.setIDType(Registration.ID_HIERARCHICAL);
          reg.setMinPasswordLength(5); // password strength
          reg.setNorthAmerican(true);
          reg.setOrgUnit("AceHardwareNE");
          reg.setRegistrationLog("log.nsf");
          reg.setUpdateAddressBook(true);
          reg.setStoreIDInAddressBook(true);
          if (reg.registerNewUser("Yip", // last name
            "d:\\NotesAdministrator\\jyip.id", // file to be created
            "CN=Mail_AceOne/O=AceHardware", // mail server
            "Jimmy", // first name
            "", // middle initial
            "AceHardware", // certifier password
            "", // location field
            "", // comment field
            "mail\\jyip.nsf", // mail file
            "", // forwarding domain
            "AceHardware")) //user password
            { System.out.println("Registration succeeded"); }
            else { System.out.println("Registration failed"); }
    
        } catch(NotesException e) {
          System.out.println(e.id + " " + e.text);
          e.printStackTrace();
        }
      }
    }
  2. This agent registers three users with alternate names and languages.
    import lotus.domino.*;
    import java.util.Vector;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Registration reg = session.createRegistration();
          reg.setRegistrationServer("AceOne");
          reg.setCreateMailDb(true);
          reg.setCertifierIDFile("c:\\NotesAdministrator\\cert.id");
          DateTime dt = session.createDateTime("Today");
          dt.setNow();
          dt.adjustYear(1);
          reg.setExpiration(dt);
          reg.setIDType(Registration.ID_HIERARCHICAL);
          reg.setNorthAmerican(false);
          reg.setMinPasswordLength(5); // password strength
          Vector orgs = new Vector();
          orgs.addElement("Japanese OU");
          orgs.addElement("PRC OU");
          orgs.addElement("Korean OU");
          reg.setAltOrgUnit(orgs);
          Vector langs = new Vector();
          langs.addElement("ja");
          langs.addElement("zh-CN");
          langs.addElement("ko");
          reg.setAltOrgUnitLang(langs);
          reg.setUpdateAddressBook(true);
          reg.setStoreIDInAddressBook(true);
          if (reg.registerNewUser("Taylor", // last name
            "c:\\NotesAdministrator\\mtaylor.id", // file to be created
            "CN=AceOne/O=AceHardware", // mail server
            "Mike", // first name
            "", // middle initial
            "AceHardware", // certifier password
            "", // location field
            "", // comment field
            "mail\\mtaylor.nsf", // mail file
            "", // forwarding domain
            "AceHardware", //user password
            "Japanese name for Mike", //alternate name
            "ja")) // alternate language
          if (reg.registerNewUser("Miller", // last name
            "c:\\NotesAdministrator\\jmiller.id", // file to be created
            "CN=AceOne/O=AceHardware", // mail server
            "Jane", // first name
            "", // middle initial
            "AceHardware", // certifier password
            "", // location field
            "", // comment field
            "mail\\jmiller.nsf", // mail file
            "", // forwarding domain
            "AceHardware", //user password
            "Chinese name for Jane", //alternate name
            "zh-CN")) // alternate language
          if (reg.registerNewUser("O'Brien", // last name
            "c:\\NotesAdministrator\\sobrien.id", // file to be created
            "CN=AceOne/O=AceHardware", // mail server
            "Steve", // first name
            "", // middle initial
            "AceHardware", // certifier password
            "", // location field
            "", // comment field
            "mail\\sobrien.nsf", // mail file
            "", // forwarding domain
            "AceHardware", //user password
            "Korean name for Steve", //alternate name
            "ko")) // alternate language
            { System.out.println("Registration succeeded"); }
            else { System.out.println("Registration failed"); }
    
        } catch(NotesException e) {
          System.out.println(e.id + " " + e.text);
          e.printStackTrace();
        }
      }
    }