看一下openldap的 schema 文件夹下的文件,我想可能是没有定义"properties"
在core.schema 加一个类似这样的attributetype ( 1.1.2.1.1 NAME 'properties'
        DESC 'properties'
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{20}
        SINGLE-VALUE )然后将top改一下
objectclass ( 2.5.6.0 NAME 'top' ABSTRACT
MUST objectClass 
         MAY ( properties) )

解决方案 »

  1.   

    找下面这么做,没有问题的。
    建一个新类,实现了DirContext接口。
    public Person(String uid,String pwd,String sn,String givenname,String telNO,String mail,String department){
    newLdapUserAttrs = new BasicAttributes(true);

    Attribute objClass = new BasicAttribute("objectClass");
    objClass.add("inetorgperson");
    objClass.add("organizationalPerson");
    objClass.add("person");
    objClass.add("top");
    newLdapUserAttrs.put(objClass);

    Attribute ou = new BasicAttribute("ou");
    ou.add("People");
    newLdapUserAttrs.put(ou);

    System.out.println("put Attribute!");
    String cn = sn + givenname;
    newLdapUserAttrs.put("uid",uid);
    newLdapUserAttrs.put("userPassword",pwd);
    newLdapUserAttrs.put("cn",cn);
    newLdapUserAttrs.put("sn",sn);
    newLdapUserAttrs.put("givenName",givenname);
    newLdapUserAttrs.put("departmentNumber",department);
    newLdapUserAttrs.put("telephoneNumber",telNO);
    newLdapUserAttrs.put("mail",mail);
    newLdapUserAttrs.put("preferredLanguage","zh-CN");
    }然后在添加条目的程序中:
    dn = "uid="+uid+",ou=People,o=LeSavonWrox'";
    Person p = new Person(uid,pwd,sn,givenname,telNO,mail,department);
    dirContext.bind(dn,p);