Cannot handle spaces in Java LDAP.

When calling the javax.naming.ldap.InitialLdapContext search () method passing in DN ...

OU=User Structure, OU=Acecity(LTO), OU=AceCloud,OU=Hosting, DC=AceCloud,DC=local

An error is issued: Authentication failed. failed to authenticate user:[LDAP: error code 32 - 0000208D: NameErr: DSID-0315270B, problem 2001 (NO_OBJECT), data 0.

LdapName baseDN = new LdapName(baseDN
NamingEnumeration results = ctx.search(baseDN, "("+ identity.getBindAttribute() + "=" + acctname + ")", sc);

The problem arises due to space in User Structure. When I put users in another organizational unit that does not contain a space, I can authenticate. Ive tried all of the following:

OU=User\ Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User\20Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User\\20Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User%Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User\ Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User\\ Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local
OU=User\\\\ Structure, OU=Acecity(LTO), OU=AcecityCloud,OU=Hosting, DC=AcecityCloud,DC=local

Nothing works. Any ideas?

+5
source share
1 answer

Spaces can cause problems with openldap if they are not properly escaped.

'OU="User Structure",OU=Acecity(LTO),OU=AceCloud,OU=Hosting,DC=AceCloud,DC=local'

To avoid problems, enclose all BINDDN with single quotation marks and enclose a common name (CN), organization unit (OU), or domain component (DC) containing a double quotation mark.

0

All Articles