spring-projects / spring-ldap

Spring LDAP
https://spring.io/spring-ldap
Apache License 2.0
342 stars 481 forks source link

LDAP-91: Spaces after commas in distinguished names #131

Closed spring-projects-issues closed 16 years ago

spring-projects-issues commented 16 years ago

["Morten Olsen":https://jira.spring.io/secure/ViewProfile.jspa?name=morols](Migrated from ["LDAP-91":https://jira.spring.io/browse/LDAP-91?redirect=false]) said:

I'm looking up LDAP objects and using the mapper to extract their distinguished names (like in the below mapper). The DNs returned include spaces after the delimiting commas. This behavior I have observed with DirContextAdapter.getNameInNamespace() and DirContextAdapter.getDn(). A perhaps simpler example is seen further below where a DN object is constructed without spaces after the comma and when written out a space is added.

From reading the RFC 4514 it seems to me that these spaces should not be there. Please point me to some documentation if I'm wrong.

Thanks, Morten

protected static class TestContextMapper implements ContextMapper {
    public final Object mapFromContext(Object context) {
        DirContextAdapter ctx = (DirContextAdapter) context;
        System.out.println("\nDN: " + ctx.getDn());
    }
}

    DistinguishedName dn = new DistinguishedName("o=test,ou=customers");
System.out.println("DN: " + dn);

Btw, I tried to upgrade my small example to use spring-ldap 1.2, but as backward compatibility has been broken this proved a task I didn't bother to follow through. After changing he maven group id and adding the word core in a lot of package references to spring ldap in class and xml files i hit the below exception...

Caused by: java.lang.NoClassDefFoundError: com.sun.jndi.ldap.ctl.ResponseControlFactory at org.springframework.ldap.core.support.LdapContextSource.class$(LdapContextSource.java:43) at org.springframework.ldap.core.support.LdapContextSource.(LdapContextSource.java:43) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:756) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:721) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:384) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109) at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:389) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:120) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:799) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:717) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:384) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at dk.unwire.sso.ldap.Tester.main(Tester.java:24)

spring-projects-issues commented 16 years ago

["Morten Olsen":https://jira.spring.io/secure/ViewProfile.jspa?name=morols] said:

I just gave it another go and googled the solution to my 1.2 problem and confirmed that the spaces after commas are also present in 1.2.

spring-projects-issues commented 16 years ago

["Morten Olsen":https://jira.spring.io/secure/ViewProfile.jspa?name=morols] said:

Just wanted to add that the LDIF used to create my objects were without the spaces and using different LDAP browsers to look at the objects doesn't show the spaces. I'm using Sun DS and the Sun web interface for browsing the directory doesn't show the spaces either.

I believe I will just make a small function for cleaning up the DNs coming out of the spring-ldap API before passing hem on (so that different systems communicating with our directory servers and storing the DNs will be able to easily compare stored values).

I'm new to LDAP and directory servers, so if you have any cues why I should/n't do this I'd appreciate your advice.

spring-projects-issues commented 16 years ago

["Mattias Hellborg Arthursson":https://jira.spring.io/secure/ViewProfile.jspa?name=marthursson] said:

The formatting of the DN is actually not significant. Syntactically, @cn=john doe, ou=company1, c=SE@ is completely equivalent to @cn=john doe,ou=company1,c=SE@. They are both valid DNs and all LDAP server should ignore the format difference. Which format to use is pretty much a matter of choice.

Personally, I think the former is more readable, and thus @DistinguishedName.toString()@ produces strings in that format. That said, it would be quite possible to introduce e.g. a @DistinguishedName.toCompactString()@ method, producing strings in without the spaces. We'll consider that for a later version.

With regards to the NoClassDefFound problem that is caused by a dependency on Sun's LDAP booster pack. That should never have been there and has now (finally) been removed for the 1.2.1 version to be released very soon.

spring-projects-issues commented 16 years ago

["Mattias Hellborg Arthursson":https://jira.spring.io/secure/ViewProfile.jspa?name=marthursson] said:

Changed this to improvement and lowered the priority. Will be considered for 1.2.2

spring-projects-issues commented 16 years ago

["Ulrik Sandberg":https://jira.spring.io/secure/ViewProfile.jspa?name=ulsa] said:

Added a toCompactString method to DistinguishedName.