Announcement Announcement Module
Collapse
No announcement yet.
SchemaViolationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SchemaViolationException

    hi,

    i want to change (update) password of user, i am using OpenLDAP server, i am using following method for changing password.

    CODE :

    public void changePassword(String uid){

    String newPassword = "spring";
    DistinguishedName dN = new DistinguishedName();
    dN.add("uid", "clientAdmin");
    DirContextOperations context = ldapTemplate.lookupContext(dN);

    try {

    context.setAttributeValues("objectclass", new String[] {"top", "inetOrgPerson"});
    context.setAttributeValue("cn", uid);
    context.setAttributeValue("uid", uid);
    context.setAttributeValue("userPassword", SHA1(newPassword));
    ldapTemplate.modifyAttributes(context);
    } catch(Exception e){
    e.printStackTrace();
    }
    }


    But in context.setAttributeValue(xxx) i am not setting all attributes, just these 3 with new password, but while update using LDAP Template i got an exception

    Exception

    org.springframework.ldap.SchemaViolationException: [LDAP: error code 65 - attribute 'gidNumber' not allowed]; nested exception is javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - attribute 'gidNumber' not allowed]; remaining name 'uid=clientAdmin'
    Caused by: javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - attribute 'gidNumber' not allowed]; remaining name 'uid=clientAdmin'
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:3016)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2931)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2737)
    at com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapC tx.java:1437)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_mod ifyAttributes(ComponentDirContext.java:255)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.modifyAttributes(PartialCompositeDirContext.java :172)
    at javax.naming.directory.InitialDirContext.modifyAtt ributes(InitialDirContext.java:153)
    at org.springframework.ldap.core.LdapTemplate$19.exec uteWithContext(LdapTemplate.java:969)
    at org.springframework.ldap.core.LdapTemplate.execute WithContext(LdapTemplate.java:807)
    at org.springframework.ldap.core.LdapTemplate.execute ReadWrite(LdapTemplate.java:802)
    at org.springframework.ldap.core.LdapTemplate.modifyA ttributes(LdapTemplate.java:967)
    at org.springframework.ldap.core.LdapTemplate.modifyA ttributes(LdapTemplate.java:1338)


    Can any body plz tell me about some solution.

    thanks

    Kashif Bashir

    [email protected]

  • #2
    You should look at the example code in this post, and replace MD5 with SHA1.

    Comment

    Working...
    X