zoukankan      html  css  js  c++  java
  • Java 实现 Domino邮箱自动注册

    一、前提条件

    Domino服务器需开通DIIOP服务

    二、需要导入Java包

    import lotus.domino.*;

    三、实现Java代码

     1 public  void cerateID(MailPerson person,Boolean createdb) throws Exception{
     2             String employee_name;
     3             String gonghao;
     4             String pinyin;
     5             String department;
     6             String company;
     7             String position;
     8             String telphone;
     9             String altfullname;
    10          if(person!=null){
    11               employee_name=person.getEmployee_name();
    12               gonghao=person.getEmployee_code()==null?"":person.getEmployee_code().toString();
    13               pinyin=person.getPinyin()==null?"":person.getPinyin().toString();
    14               department=person.getDepartment()==null?"":person.getDepartment().toString();
    15               company=person.getCompany()==null?"":person.getCompany().toString();
    16               position=person.getPosition()==null?"":person.getPosition().toString();
    17               telphone=person.getTelphone()==null?"":person.getTelphone().toString();
    18               altfullname=employee_name+"/"+gonghao+"/"+company;
    19               if(!searchPerson(gonghao,pinyin)){
    20                   if(session!=null){
    21                       Registration reg = session.createRegistration();
    22                       reg.setRegistrationServer(serverName);//服务器名
    23                       reg.setCreateMailDb(createdb);
    24                       reg.setCertifierIDFile(certidAddress);//cert.id路径
    25                       DateTime dt = session.createDateTime("Today");
    26                       dt.setNow();
    27                       dt.adjustYear(1);
    28                       reg.setExpiration(dt);
    29                       reg.setIDType(Registration.ID_HIERARCHICAL);
    30                       reg.setMinPasswordLength(5); // password strength
    31                       reg.setNorthAmerican(true);
    32                       reg.setOrgUnit("");//可以为空,中间名
    33                       Vector langs = new Vector();
    34                       langs.addElement("zh-TW");
    35                       langs.addElement("zh-CN");
    36                       langs.addElement("zh-HK");
    37                       reg.setAltOrgUnitLang(langs);
    38                       reg.setRegistrationLog("log.nsf");
    39                       reg.setUpdateAddressBook(true);
    40                       reg.setStoreIDInAddressBook(true);
    41                       //reg.setEnforceUniqueShortName(false);
    42                       String mailInternetAddress=pinyin+gonghao+"@dayang.com";
    43                       reg.setMailInternetAddress(mailInternetAddress);
    44                       String firstn=pinyin;//姓名拼音
    45                       String lastn=gonghao;//工号
    46                       String idname="";
    47                       if("".equals(firstn)){
    48                           idname=lastn;
    49                       }else{
    50                           idname=firstn.substring(0,1)+lastn;//z177223
    51                       }
    52                       String idfile=useridsavepath+idname+".id";//存储用户ID保存路径
    53                       String server=serverName;//服务器名
    54                       String middle="";//中间名
    55                       String certpw=certidPassword;//cert.id密码
    56                       String location="";//
    57                       String comment="";//
    58                       String maildbpath=useridfilename+"\"+idname+".nsf";//邮箱数据库文件路径
    59                       String forward="";//邮件转发地址
    60                       String userpw="password";//用户邮箱帐号默认密码
    61                       //outputMessage+="存储用户ID保存路径:"+idfile+"
    ";
    62                       //outputMessage+="邮箱数据库文件路径:"+maildbpath+"
    ";
    63                       if (reg.registerNewUser(lastn,idfile,server,firstn,middle,certpw,location,comment,maildbpath,forward,userpw)) { 
    64                           outputMessage+=pinyin+gonghao+" 邮箱注册成功!
    "; 
    65                           lotus.domino.Document searchdoc=searchPersonDocument(gonghao,pinyin);
    66                           if(searchdoc!=null){
    67                               searchdoc.replaceItemValue("JobTitle",position);//职位
    68                               searchdoc.replaceItemValue("CompanyName",company);//公司
    69                               searchdoc.replaceItemValue("Department",department);//部门
    70                               searchdoc.replaceItemValue("CellPhoneNumber",telphone);//移动电话
    71                               searchdoc.replaceItemValue("AltFullName",altfullname);//
    72                               searchdoc.replaceItemValue("AltFullNameLanguage","汉语");//
    73                               searchdoc.replaceItemValue("AltFullNameLanguageDisplay","汉语");//
    74                               searchdoc.save();
    75                           }
    76                           //saveMailAccountData(person);
    77                       }else { 
    78                           outputMessage+=pinyin+gonghao+" 邮箱注册失败!
    "; 
    79                       }
    80                     }
    81              }
    82             }
    83     }
    View Code

     四,相关参数解析

    private static Session session;
    private static String ipaddress="192.168.0.XXX";//邮箱服务器ip地址
    private static String administratorUser="domino Administrator";//Domino管理员账户
    private static String administratorPassword="XXXXXXX";//Domino管理员密码

    private static String certidAddress="E:\Program Files\IBM\Domino\data\cert.id";
    private static String certidPassword="XXXXXXX";//
    private static String serverName="domino-server/domino";//服务器名称
    private static String useridfilename="mail";//保存用户id文件名称
    private static String useridsavepath="E:\Program Files\IBM\Domino\data\ids\";//用户id保存路径
    private static String outputMessage="";

  • 相关阅读:
    如何在VS 2010中使用 VS2013的解决方案(转)
    A2W、W2A、A2T、T2A的使用方法
    海康网络摄像机YV12转换为BGR,由opencv Mat显示 (转)
    特征提取代码总结
    请不要做浮躁的人
    linux下操作问题与总结
    项目问题与解决方案
    电脑故障与解决方案
    给年轻工程师的十大忠告
    记忆的马太效应
  • 原文地址:https://www.cnblogs.com/chaoge516/p/7421364.html
Copyright © 2011-2022 走看看