This discussion is archived
4 Replies Latest reply: Jul 17, 2012 2:45 PM by EJP RSS

Error while connecting to the LDAP server

949657 Newbie
Currently Being Moderated
In LDAP Server, i have configured OU with the following characteres.

OU=Administración.

Now when i try to connect LDAP server from my application, am getting the following exception.

[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0]
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0]
     at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3041)
     at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
     at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2789)
     at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2703)
     at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
     at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
     at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
     at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
     at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
     at javax.naming.InitialContext.init(InitialContext.java:223)
     at javax.naming.InitialContext.<init>(InitialContext.java:197)
     at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)


When i search for this, i got the this [link |http://esupport.trendmicro.com/solution/en-us/1037285.aspx/] saying some Accent characters are not converted correctly into 8-bit Unicode Transformation Format (UTF-8).
Here i have used URLEncoder.encode(mySearchbase, "UTF-8"); to encode the special characters into UTC-8.

I would like to know whether its a known issue with accent characters or anything else i missed here to handle those characters.

Thanks,
-Konanki
  • 1. Re: Error while connecting to the LDAP server
    DrClap Expert
    Currently Being Moderated
    Well, if you're passing an array of bytes to that LDAP access code, then that isn't the right way to encode a String to an array of bytes in UTF-8 encoding. And anyway it's been a long time since I wrote LDAP access code, but I don't recall having to pass arrays of bytes to any of those JNDI classes, so that idea is probably wrong in any case.

    I would suggest, if that page you linked to is actually relevant, that you just install the hot-fix it refers to. On the other hand if it doesn't actually apply to your situation, then you should just ignore it.

    My guess is that UTF-8 or not, your OU value on the server is in fact not "Administraci&oacute;n" -- that's based on the number of mis-encoded characters I see there. So perhaps what you are passing to the JNDI classes does in fact not match the server's value and it isn't an encoding issue at all.
  • 2. Re: Error while connecting to the LDAP server
    EJP Guru
    Currently Being Moderated
    And I don't know why you think URLEncoder will solve it. There is nothing in any LDAP RFC that I have ever seen that says anything about that encoding. What happens when you just pass the string as-is?
  • 3. Re: Error while connecting to the LDAP server
    949657 Newbie
    Currently Being Moderated
    I tried by passing the string as it is without encode, getting the same exception. I tried with following string also.

    OU=Administración.
  • 4. Re: Error while connecting to the LDAP server
    EJP Guru
    Currently Being Moderated
    Sting.getBytes("UTF-8");

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points