我使用這個代碼段添加用戶到LDAP錯誤時附加使用到LDAP [LDAP:錯誤代碼17 - javaSerializedData:屬性類型未定義]
**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);
}**
但它給在
異常線程「main」 javax.naming.directory.InvalidAttributeIdentifierException:[LDAP: 錯誤代碼17 - javaSerializedData:attribute type undefined]; 剩餘名稱爲 'uid = chamils,OU =用戶,DC = LDAP,DC = ,DC =' 處 COM com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3110)。 sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)at com.sun.jndi.ldap.LdapCtx.c_bind( LdapCtx.java:397)at com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:354)at com.sun.jndi.toolkit.ctx.ComponentContext.p_bind(ComponentContext.java:596) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(PartialCompositeContext.java:183) at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(PartialCompositeContext.java:173) at javax.naming.InitialContext.bind(InitialContext.java:400)at LdapNew.main(LdapNew.java:49)at sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang中.reflect.Method.invoke(Method.java:597)在 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
這是爲什麼。