2016-03-28 16 views
0

Ich benutze openDJ für LDAP und ich bin nicht in der Lage, ds-pwp-account-disabled Attributwert in openDJ von Frühjahr ldap Vorlage zu ändern.Kann den Wert von ds-pwp-account-disabled in openDJ nicht ändern durch Spring LDAP

Ich habe DirContextOperations Klasse-Objekt durch Feder ldap erstellt. Wenn ich den Wert des Attributs ds-pwp-account-disabled mit Hilfe von Spring ldap erhalte, wird es angegeben. Es ist jedoch nicht möglich, den Attributwert ds-pwp-account-disable über Spring ldap zu aktualisieren. Kannst du mir helfen, wie ich den Wert des Attributes ds-pwp-account-disabled über Spring ldap aktualisieren soll? Ich lese so viele Artikel in Google, Es kann Änderungsprivileg in opendj durch Springldap sein oder kann andere sein.

ich einige Code teilen bin zu identifizieren, wie soll ich Frühling ldap mit Verwendung offener DJ--

privaten LdapTemplate ldapTemplate;

ErrorDTO createAccountIfNotExists(Account account){ 

    DirContextAdapter context = new DirContextAdapter(dn); 
    context.setAttributeValues(OBJECTCLASS, new String[] { TOP, USERACCOUNTS }); 
    mapToContext(account, context); 
    try { 
     ldapTemplate.bind(context); 

    } catch (Exception e) { 
    } 
    return error; 
} 

public LdapTemplate getLdapTemplate() { 
    return ldapTemplate; 
} 

public void setLdapTemplate(LdapTemplate ldapTemplate) { 
    this.ldapTemplate = ldapTemplate; 
} 

void mapToContext(Account account, DirContextOperations context) { 
    context.setAttributeValue("cn", account.getFirstName()); 
    context.setAttributeValue("sn", account.getLastName()); 
    context.setAttributeValue("x-user-id", account.getUserId()); 
    context.setAttributeValue("mail", account.getEmail()); 
    context.setAttributeValue("givenname", account.getFirstName()); 
    context.setAttributeValue("mobile", account.getMobilePhone()); 
    context.setAttributeValue("telephonenumber", account.getBusinessPhone()); 
    context.setAttributeValue("title", account.getJobTitle()); 
    context.setAttributeValue("x-incident-ref", account.getIncidentRef()); 
    context.setAttributeValue("x-client-category", account.getClientCategory()); 
    context.setAttributeValue("x-organization", account.getOrganization()); 
    context.setAttributeValue("facsimiletelephonenumber", account.getFax()); 
    context.setAttributeValue("x-bureau", account.getBureau()); 
    context.setAttributeValue("x-company", account.getCompany()); 
    context.setAttributeValue("ds-pwp-account-disabled", account.getEnabled()); 
    if (account.getAccountCode() != null) { 
     context.setAttributeValue("x-account-code", account.getAccountCode()); 
     context.setAttributeValue("uid", account.getAccountCode() + "#" + account.getUserId()); 
    } else { 
     context.setAttributeValue("uid", account.getUserId()); 
    } 

} 

Es wird unter Fehler gegeben - org.springframework.ldap.InvalidAttributeValueException: Malformed 'ds-PWP-Konto-disabled' Attributwert; Die verschachtelte Ausnahme ist javax.naming.directory.InvalidAttributeValueException: Falscher Attributwert 'ds-pwp-account-disabled'; verbleibender Name 'uid = coy # user8, ou = Benutzerkonten'

+0

Setzen Sie bitte die Codezeilen in 'markdown like this'. – surajsn

+0

Hallo, ich würde es begrüßen, wenn Sie mir sagen könnten, wie Sie diesen DS-Pwp-Account-deaktiviert bekommen haben? Ich extrahiere Benutzerattribute, kann dies aber nicht. – karansardana

Antwort

0

Das Attribut ds-pwp-account-disable hat eine LDAP-Syntax Boolean. Die einzigen vom OpenDJ-Server akzeptierten Werte sind "wahr" und "falsch". Ich bin kein Experte in Spring LDAP, aber wenn die Syntax des Attributs unbekannt ist, bezweifle ich, dass die Bibliothek die booleschen Java-Werte ordnungsgemäß in die richtigen LDAP-Werte transponieren wird.

0

Wie ich weiß, wenn

ds-pwp-account-disabled
Attribut nicht in einem Eintrag vorhanden ist, wird der Benutzer nicht deaktiviert = der Benutzer ist aktiviert.

Also versuchen Sie es, dieses Attribut nicht hinzuzufügen ist der Benutzer aktiviert ist.

if(!account.getEnabled()){ //suppose that it's returning a boolean 
    context.setAttributeValue("ds-pwp-account-disabled", "true"); 
}