[SOLVED] How to get output informations from LDAP connector?

1
0
-1

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>.
      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 :

395490Capture.jpg

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.

Comments

Submitted by yannick.lombardi on Wed, 08/12/2015 - 11:42

The serialization message is not an error. It's just a warning to inform you.
I don't think you can fix this.

1 answer

1
0
-1

Hello Yannick,

Sorry but I didn't see that you answered to my post (I thinked I would receive a mail).

Indeed, you're right, this is not an error message!
My scenario can run even with this message...
I think Bonita could be improved with this message (I've seen in not the first one to ask about it) :)

Thanks for your help!

Gaël

Notifications