go to  ForumEasy.com   
LdapPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Work Around Solution
 
Subject: Work Around Solution
Author: JNDI
In response to: Output
Posted on: 05/18/2007 08:56:32 PM

While insisting that this strange behavior is not a bug, those smart guys in Sun provide a whole different perspective in interpreting those three backslashes.

(see http://java.sun.com/products/jndi/tutorial/beyond/names/syntax.html)

The solution is to process everything in JDNI world:

         /* process results */
         while(enu.hasMore()){
            SearchResult sr = (SearchResult)enu.next();
            String dn = new CompositeName(sr.getName()).get(0); 
            if(sr.isRelative()){
              dn += "," + base_dn;
            }
            System.out.println("dn: " + dn);  
            
            NamingEnumeration attrs = sr.getAttributes().getAll();
            while(attrs.hasMoreElements()){
              BasicAttribute attr = (BasicAttribute)attrs.nextElement();
              String attrType = attr.getID();
              NamingEnumeration vals = attr.getAll();
              while(vals.hasMoreElements()){
                String attrValue = vals.nextElement().toString();
                System.out.println(attrType + ": " + attrValue);
              }
            }
         }


Then the output are correct.

   dn: cn=temp\\tester,cn=users,dc=mydomain,dc=com
   objectclass: top
   objectclass: person
   objectclass: organizationalPerson
   objectclass: inetOrgPerson
   cn: cn=temp\tester
   sn: tester
   givenName: temp
   telephoneNumber: (555)-1234



 

> On 05/18/2007 08:38:28 PM JNDI wrote:

After running the above code, the method
        sr.getName(); 

should return 'cn=temp\\tester' but 'cn=temp\\\tester' instead.

IT HAS THREE (3) BACKSLASH CHARACTERS INSIDE.

The output is as the follows:

   dn: cn=temp\\\tester,cn=users,dc=mydomain,dc=com
   objectclass: top
   objectclass: person
   objectclass: organizationalPerson
   objectclass: inetOrgPerson
   cn: cn=temp\tester
   sn: tester
   givenName: temp
   telephoneNumber: (555)-1234


Notice that the attribute method brings 'cn' back correctly.





References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.