Announcement Announcement Module
Collapse
No announcement yet.
BadLdapGrammarException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BadLdapGrammarException

    I'm using a ContextMapper with search() and in it I have a println for debugging. After being called 9 times (it prints 9 lines) it bombs with a BadLdapGrammarException.

    Is it possible that the cn value it's complaining about is malformed because it has a slash in it? All of the previous ones which it prints out don't have a slash in them.

    Code:
    private class
    AffilsContextMapper implements ContextMapper {
        public Object
        mapFromContext(final Object context) {
            final DirContextAdapter ctx = (DirContextAdapter) context;
            System.out.println("ctx: " + ctx);
            final String affil = ctx.getStringAttribute(attrNameAffilsName);
    
            return(affil);
        }
    }
    Code:
    Operation failed; nested exception is javax.naming.NamingException: problem generating object using object factory [Root exception is net.sf.ldaptemplate.BadLdapGrammarException: Not a proper name (such as key=value): "cn=LBL/DOE Postdoc]; remaining name 'ou=affiliations'
    net.sf.ldaptemplate.UncategorizedLdapException: Operation failed; nested exception is javax.naming.NamingException: problem generating object using object factory [Root exception is net.sf.ldaptemplate.BadLdapGrammarException: Not a proper name (such as key=value): "cn=LBL/DOE Postdoc]; remaining name 'ou=affiliations'
    Caused by: javax.naming.NamingException: problem generating object using object factory [Root exception is net.sf.ldaptemplate.BadLdapGrammarException: Not a proper name (such as key=value): "cn=LBL/DOE Postdoc]; remaining name 'ou=affiliations'
            at com.sun.jndi.ldap.LdapSearchEnumeration.createItem(LdapSearchEnumeration.java:111)
            at com.sun.jndi.ldap.LdapNamingEnumeration.nextAux(LdapNamingEnumeration.java:256)
            at com.sun.jndi.ldap.LdapNamingEnumeration.nextImpl(LdapNamingEnumeration.java:236)
            at com.sun.jndi.ldap.LdapNamingEnumeration.next(LdapNamingEnumeration.java:184)
            at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:201)
            at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:167)
            at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:355)
            at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:293)
            at net.sf.ldaptemplate.LdapTemplate.search(LdapTemplate.java:315)
            at waitlistd.ldap.LdapAffiliationsImpl.getAffiliations(LdapAffiliationsImpl.java:36)
            at test.Ldap3Test.testGetAffiliations(Ldap3Test.java:18)
            at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
    Caused by: net.sf.ldaptemplate.BadLdapGrammarException: Not a proper name (such as key=value): "cn=LBL/DOE Postdoc
            at net.sf.ldaptemplate.support.LdapRdn.parseLdap(LdapRdn.java:118)
            at net.sf.ldaptemplate.support.LdapRdn.<init>(LdapRdn.java:64)
            at net.sf.ldaptemplate.support.DistinguishedName.parse(DistinguishedName.java:133)
            at net.sf.ldaptemplate.support.DistinguishedName.<init>(DistinguishedName.java:89)
            at net.sf.ldaptemplate.support.DefaultDirObjectFactory.stripBasePath(DefaultDirObjectFactory.java:90)
            at net.sf.ldaptemplate.support.DefaultDirObjectFactory.getObjectInstance(DefaultDirObjectFactory.java:54)
            at javax.naming.spi.DirectoryManager.createObjectFromFactories(DirectoryManager.java:218)
            at javax.naming.spi.DirectoryManager.getObjectInstance(DirectoryManager.java:197)
            at com.sun.jndi.ldap.LdapSearchEnumeration.createItem(LdapSearchEnumeration.java:105)
    Last edited by lumpynose; Aug 29th, 2006, 04:58 PM.

  • #2
    Looks like it might be a bug in Sun's software?

    http://bugs.sun.com/bugdatabase/view...bug_id=4307193

    Comment


    • #3
      Well, it's not a bug in sun's software but indeed something similar to the problem referred in sun's bug report (which was btw discarded as not being a bug).

      The problem here seems to be that JNDI treats a forward slash ('/') as a meta character, causing the entire DN to be enclosed in quotes (") by sun's CompositeName when one is present. The quotes don't work with our LdapName implementation, causing the parsing to break. We'll need to figure something out to handle it.

      In the mean time I can think of a couple of workarounds:
      * Don't use a base path on your ContextSource, as this will eliminate the need for us to parse the DN.
      * Implement your own DirObjectFactory that removes any enclosing quotes or doesn't use our LdapName.
      * Use AttributesMapper instead, as this will ignore the DN.

      Comment


      • #4
        Great, thanks. I'll try using AttributesMapper first and see how that works.

        Comment


        • #5
          Hi, this problem does not seem to have been solved in 1.3.

          I am trying to retrieve an ldap entry with the DN: ou=Companyname A/S,ou=companies,dc=org. I can see from the ldap logs that it fails because it ignores everything that comes after the forslash.

          Also not setting the base property in my LdapContextSource gives me an exception when using PoolingContextSource.

          Any help would be highly appreciated!

          Michael

          Comment

          Working...
          X