0

I am trying to create an LDAP user with a single custom attribute, but I am getting a

javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - 0000207D: UpdErr: DSID-0315166D, problem 6002 (OBJ_CLASS_VIOLATION), data -2131045114

When I remove the userId custom attribute from the code, it runs perfectly and so that i can create the user, but this custom attribute is used by a third party app and I should create it with this attribute for sure.

Can you give me any idea about what is going on with this attribute? What can be the problem? Thanks

Here is the code that i am getting the error:

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);

3 Answers 3

1

Unless you have modified the schema for one of those objectClass-es, you need to add the extensibleObject object class to use custom attributes.

Sign up to request clarification or add additional context in comments.

Comments

1

Assuming the schema has been modified for the "single custom attribute". (you do not cover that in the question), you probably need to create the user then add the custom attribute value AFTER the Add operation.

Comments

0

Have you tried defining your custom attribute the same way like all the others above ?

Attribute loginId= new BasicAttribute("loginId", "aaa");
---
container.put(loginId);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.