I have a problemwith LDAP. I would like to modify couple of attributes but it doesn’t work. With cursor().get().put(attr, value) the value is modified only local and if I check if that changed attribute was changed on server side, the old value remains untouched.
How can I send modified value, so it will we saved in database?
{
LdapConnectionConfig config = new LdapConnectionConfig();
config.setUseSsl(true);
config.setLdapHost(server);
config.setLdapPort(port);
config.setName(
"cn=%s,DC=xyz,DC=local".formatted(user)
);
config.setCredentials(password);
config.setTrustManagers(new X() {
public boolean isClientTrusted(someMethod[] cert) { some auth code
});
try(LdapConnection conn = new LdapNetworkConnection(config)) {
conn.connect();
conn.bind();
SearchRequestImpl queryRequest = new SearchRequestImpl();
queryRequest.setScope(SearchScope.SUBTREE);
EntryCursor cursor = conn.search(base, query, SearchScope.SUBTREE);
String queryResult = "";
if(cursor.next()) {
System.out.println("cursor before:<<<<<<<<<<<<<<<<<<<< " + cursor.get().toString());
cursor.get().removeAttributes("xxx");
cursor.get().put("xxx", "111");
System.out.println("cursor after:<<<<<<<<<<<<<<<<<<<< " + cursor.get().toString());
queryResult += cursor.get().toString();
}
conn.unBind();
} catch(IOException e) {
throw new RuntimeException(e.getMessage());
}
}