Hello,
I currently have a problem with a new scenario I have to implement :
-
I must provide a form to users which will contain an autocomplete input. This autocomplete input must be linked to the company LDAP directory (Active Directory to be exact). We are a medium size company (about 500 people) so I think there won’t be any performance problem.
For example, if I start to type “Gaël”, it must automatically propose “Gaël XXX” and “Gaël YYY” which are present in the company. -
The solution I imagined was :
- Before the form creation, I call LDAP connector (the default provided connector). The informations I need are “Common Name” and “mail”, I don’t need anything else. For that, I put in *Attributes * parameter : “CN,mail”.
- My problem is that I have an error while trying to get the outputs operations. The LDAP connector answers with a List called ldapAttributeList. I just want to get the different values into an Hashmap<String (cn),<Hashmap<String (cn),String (mail)>>.
For that, after several trial, I found a code in another topic which is :
import org.bonitasoft.connectors.ldap.LdapAttribute; import java.text.AttributedCharacterIterator.Attribute; import java.util.HashMap; import java.util.Map; //res_hashmap is the dictionnary returned HashMap<String, HashMap<String, String>> res_hashmap = new HashMap<String, HashMap<String, String>>(); //Creating working variables String temp_value = new String() String temp_name = new String() // Creating patterns (regexp based) matching illegal xml caracters (XML1.0 & XML1.1) String xml10pattern = "[^" + "\u0009\r\n" + "\u0020-\uD7FF" + "\uE000-\uFFFD" + "\ud800\udc00-\udbff\udfff" + "]"; String xml11pattern = "[^" + "\u0001-\uD7FF" + "\uE000-\uFFFD" + "\ud800\udc00-\udbff\udfff" + "]+"; for (user in ldapAttributeList){ //Creating temp_hashmap for storing the users attribute HashMap<String, String> temp_hashmap = new HashMap<String, String>(); for (attr in user){ if (attr.getValue() != null & attr.getName() != null & attr != null){ //Converting value of attribute in UTF8 try{ temp_value = attr.getValue().replaceAll(xml10pattern, "").replaceAll(xml11pattern, "") temp_value = new String(temp_value.getBytes("UTF8"), "UTF8"); } catch (UnsupportedEncodingException e) { temp_value = e.printStackTrace(); } //Converting name of attribute in UTF8 try{ temp_name = attr.getName().replaceAll(xml10pattern, "").replaceAll(xml11pattern, "") temp_name = new String(temp_name.getBytes("UTF8"), "UTF8"); } catch (UnsupportedEncodingException e) { temp_name = e.printStackTrace(); } } //Storing them into the temp_hashmap temp_hashmap.put(temp_name, temp_value) } //Adding user attrs hasmap to the hashmap of user attrs res_hashmap.put(temp_hashmap["cn"], temp_hashmap); } return new HashMap<String, HashMap<String, String>>(res_hashmap)
I’ve created a variable listeLDAP (java.util.Map) to take value of this code. But I have this unserializable output error each time I test my connector :
So here are my two questions :
- Do you think my solution for having an autocomplete input in a form “linked” to the Active Directory is correct? Could I have done it in a better way?
- How can I fix this serialization error?
Thanks for your help!
PS : I’m using Bonita 7.0.1.