So often, the easiest answer is the right! It works! With this here
<code>
protected void mapSearchResultToUser( SearchResult result, UserEntity user) throws NamingException {
if (ldapConfigurator.getUserIdAttribute() != null) {
user.setId(result.getAttributes().get(ldapConfigurator.getUserIdAttribute()).get().toString());
}
if (ldapConfigurator.getUserFirstNameAttribute() != null) {
try{
user.setFirstName(result.getAttributes().get(ldapConfigurator.getUserFirstNameAttribute()).get().toString());
}catch(NullPointerException e){
user.setFirstName("");
}
}
if (ldapConfigurator.getUserLastNameAttribute() != null) {
try{
user.setLastName(result.getAttributes().get(ldapConfigurator.getUserLastNameAttribute()).get().toString());
}catch(NullPointerException e){
user.setLastName("");
}
}
if (ldapConfigurator.getUserEmailAttribute() != null) {
user.setEmail(result.getAttributes().get(ldapConfigurator.getUserEmailAttribute()).get().toString());
}
}
</code>
Everything works fine. And the mystery with Klaus Kerberos is solved, too. There was a third user beginning with ker, the user "waskerb". This user has no lastname. Therefore, when i typed in "kerb", there were 2 users matching: Klaus Kerberos and "waskerb". Because waskerb has no name, the exception was thrown. Now, both Users are displayed correctly in the User Form Type!
I know that you sould not catch Runtime-Exceptions, but it can always happen that a user has not all properties in LDAP. Therefore, activiti developers, could you add this try-catch Block in the official distro? That would help a lot of people and then, the user form type can be used with LDAP.
Very cool!!
Thanks a lot @tombo for the great ideas.