Ошибка при добавлении использования в ldap [LDAP: код ошибки 17 — javaSerializedData: тип атрибута не определен]

Я использую эти фрагменты кода, чтобы добавить пользователя в ldap

**public DirContext getLDAPDirContext() throws NamingException {
    final Hashtable envValues = new Hashtable();
    // Assign the JNDI environment values in Map
    envValues.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    envValues.put(Context.PROVIDER_URL, url);
    envValues.put(Context.SECURITY_PRINCIPAL,dn); // specify the username
    envValues.put(Context.SECURITY_CREDENTIALS,password);           // specify the password
    return new InitialDirContext(envValues);
}
public static void main(String arg[]) throws NamingException {
    LdapNew ldapNew = new LdapNew();
    String groupDN ="ou=user,dc=ldap,dc=***,dc=***";
    BasicAttributes myAttrs = new BasicAttributes(true);  //Basic Attributes
    myAttrs.put("uid","chamils");
    myAttrs.put("objectClass","top");
    myAttrs.put("objectClass","dcObject");
    myAttrs.put("objectClass","organization");
    myAttrs.put("objectClass", "inetOrgPerson");
    myAttrs.put("cn","FNAME LNAME");
    myAttrs.put("displayname", "FNAME LNAMEE");
    myAttrs.put("givenname","Chamilseeee");
    myAttrs.put("sn","Thanthrimudaliged");
    myAttrs.put("mail","*******");
    DirContext ctx = ldapNew.getLDAPDirContext();
    ctx.bind("uid=chamils,ou=user,dc=ldap,dc=****,dc=***",myAttrs);
}**

Но это дает

Исключение в потоке "основной" javax.naming.directory.InvalidAttributeIdentifierException: [LDAP: код ошибки 17 - javaSerializedData: тип атрибута не определен]; оставшееся имя 'uid=chamils,ou=user,dc=ldap,dc=,dc=' в com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx. java:3110) по адресу com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987) по адресу com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794) по адресу com.sun.jndi.ldap .LdapCtx.c_bind(LdapCtx.java:397) в com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:354) в com.sun.jndi.toolkit.ctx.ComponentContext.p_bind(ComponentContext.java:596) ) в com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(PartialCompositeContext.java:183) в com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(PartialCompositeContext.java:173) в javax.naming.InitialContext. bind(InitialContext.java:400) в LdapNew.main(LdapNew.java:49) в sun.reflect.NativeMethodAccessorImpl.invoke0(собственный метод) в sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) в sun.reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl. legatingMethodAccessorImpl.java:25) в java.lang.reflect.Method.invoke(Method.java:597) в com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Это почему.


person Lasith Malinga    schedule 15.08.2012    source источник


Ответы (1)


Вам нужно добавить include schema/java.schema в конфигурацию OpenLDAP.

person user207421    schedule 15.08.2012
comment
Как это сделать с последними версиями OpenLDAP? - person ceving; 21.02.2020