我正在尝试使用单个自定义属性创建LDAP用户,但我得到了
javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - 0000207D: UpdErr: DSID-0315166D, problem 6002 (OBJ_CLASS_VIOLATION), data -2131045114
当我从代码中删除userId
自定义属性时,它会完美运行,以便我可以创建用户,但是这个自定义属性由第三方应用程序使用,我应该使用此属性创建它肯定的。
你能告诉我这个属性发生了什么吗?可能是什么问题?感谢
以下是我收到错误的代码:
Attributes container = new BasicAttributes();
Attribute objClasses = new BasicAttribute("objectClass");
objClasses.add("top");
objClasses.add("person");
objClasses.add("organizationalPerson");
objClasses.add("user");
this.cnValue = new StringBuffer(firstName).append(" ").append(lastName).toString();
Attribute cn = new BasicAttribute("cn", cnValue);
Attribute sAMAccountName = new BasicAttribute("sAMAccountName", userName);
Attribute principalName = new BasicAttribute("userPrincipalName", userName + "@" + DOMAIN_NAME);
Attribute givenName = new BasicAttribute("givenName", firstName);
Attribute sn = new BasicAttribute("sn", lastName);
Attribute uid = new BasicAttribute("uid", userName);
Attribute sshPublicKey = new BasicAttribute("sshPublicKey", "AAAAAAAAAAAAAAAAAAAAAAAA");
Attribute userPassword = new BasicAttribute("userpassword", password);
container.put(objClasses);
container.put(sAMAccountName);
container.put(principalName);
container.put(cn);
container.put(sn);
container.put(givenName);
container.put(uid);
container.put(userPassword);
container.put(sshPublicKey);
container.put("loginId", "aaa"); //When I remove this, user can be created successfully
this.context.createSubcontext(getUserDN(cnValue, organisationUnit), container);
答案 0 :(得分:1)
假设已针对"单个自定义属性"修改了架构。 (您不会覆盖问题中的内容),您可能需要创建用户,然后在添加操作后添加自定义属性值。
答案 1 :(得分:1)
除非您修改了其中一个objectClass
- es的架构,否则需要添加extensibleObject
对象类以使用自定义属性。