Issue Details (XML | Word | Printable)

Key: DIRSERVER-309
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Emmanuel Lecharny
Reporter: Alex Karasulu
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Directory ApacheDS

Decoder does no give sufficient information about errors so the LDAP server can respond with correct result code.

Created: 03/Feb/06 06:45 AM   Updated: 02/Oct/06 01:59 PM
Return to search
Component/s: ldap
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Duplicate

Resolution Date: 28/Aug/06 01:23 PM


 Description  « Hide
Right now a communication exception is thrown by the server when a malformed DN is given in a PDU. I tested this with bind for example using a bad BindDN. When the ASN1 codec fails the server cannot really tell the difference between a bad protocol PDU which causes a protocolError (2) resulting in a JNDI CommunicationException from a bad DN which should return a resultCode of namingViolation (64) which in JNDI comes back to the client as an InvalidNameException. For more info on resultCodes mapping to JNDI exceptions see:

http://java.sun.com/products/jndi/jndi-ldap-gl.html#EXCEPT

Basically the ASN1 decoder has to throw exceptions with hints regarding the failure to allow the server to respond appropriately to the client. This can be done by embedding additional info such as a result code in an subclass of DecoderException. Then the LdapProtocolProvider can access this info.

This problem is a direct result of trying to parse a DN for correctness when this is not the responsibility of the ASN1 codec. The LDAP BER codec should be giving stuff back to the server as is and letting the server determine whether or not the dn or other (non-asn1 constrained) constructs are invalid.




 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alex Karasulu added a comment - 03/Feb/06 06:47 AM
Here's a commented out test case (testBadBindDnMalformed) that should be corrected to get the right exception type.

http://svn.apache.org/viewcvs.cgi/directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java?rev=374520&view=markup

Emmanuel Lecharny added a comment - 03/Feb/06 08:31 AM
This is a real problem, but we can fix it fast.

What are our options here ?
1) Just don't take the responsability of detecting bad DN in ASN.1 codec. Then we will send the created DN to the next layer
2) Assume that we test that the DN syntax is valid, but we must throw an error allowing the client to be informed of the cause of the error.

I personnaly assumed that the second solution was better, in a sense that I build a LdapDN (it should be renamed LdapName), which internally contains RDN. So an invalid DN will lead top incorrect inner structure. That was a choice, of course. The alternative was to store the String, instead of building a valid DN.

However, in this case, the thrown exception is not good. May be wa can throw a specific exception for that purpose, but that mean a special handling in the protocol layer. I'm not totally happy with that solution. An other way to go is to set a flag to tell the MessageHandler that the DN was incorrect. Or simply forget about the control, and just store the value as it, without parsing it. We just have to add a method to store this UP name into a ldapDN.

wdyt is best ?

Alex Karasulu added a comment - 17/Aug/06 09:08 PM
I think the best way to approach this problem is as we discussed. Let's make a special message type handler and register it for Exceptions. Instead of propagating exceptions by throwing them we can bubble up the message to this handler which can properly respond to the client.

Emmanuel Lecharny added a comment - 22/Aug/06 11:49 PM
It's exactly the same issue. we will keep 711 alive. We have a fix now, but it must be applied.

Alex Karasulu added a comment - 27/Aug/06 06:05 PM
Emmanuel is currently working on this issue.

Emmanuel Lecharny added a comment - 28/Aug/06 01:23 PM
This is DIRSERVER-711. No need to have two JIRAs for the same issue !

Alex Karasulu added a comment - 02/Oct/06 01:59 PM
fixed and confirmed