-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send 32 instead of 2 for empty SearchResultDone #58
base: master
Are you sure you want to change the base?
Conversation
Send NO_SUCH_OBJECT (32) instead of SUCCESS (2) as code of SearchResultDone message when no entries where returned. This matches the ldap spec, and behavior of other ldap server implementations.
I had first hacked together this monstrosity in my search() function in GenericRequestHandler
but then later found This to cause random issues all over the place. I assume this kills the connection which breaks some requests for some clients, but haven't investigated further. This needs to be fixed in the library, not GenericRequestHandler. |
Hi @Redjard ! Thanks for taking the time to report this. It appears like when to return https://datatracker.ietf.org/doc/html/rfc4511#section-4.5.3
So I take that to mean that a So in the request handler $baseDn = $search->getBaseDn();
// Logic here to figure out if that base actually exists.
// ....
if ($noSuchObject) {
throw new OperationException(
'No such object',
ResultCode::NO_SUCH_OBJECT
);
} This seems like an unfortunate detail that request handler implementations will need to be aware of, otherwise it would require a change in the interface to force them to specify whether the baseDn exists or not, along with the entries contained in it. |
Right, I completely missed that, thanks. FreeDSx\Ldap\Protocol\ServerProtocolHandler\ServerSearchHandler->handleRequest()
replaced with
FreeDSx\Ldap\Protocol\ServerProtocolHandler\ServerSearchTrait->sendEntriesToClient()
replaced with
I assume this is horrendous, that's why I didn't open another merge request, this is how I implemented it in my project now. |
Ah, that's right. Now that I look at your solution I understand the problem. The issue is that we need to intercept operation exception when the I need to think a little bit about a good way to handle it. I don't think we want to put any potential operation exception code into |
Ok, I believe this PR should clear it up: #63. I'm not sure if you have any way to test if the changes in that PR helps with your situation. The tricky part was changing this in all the spots that handle searches in different ways:
But I believe it now properly sets the diagnostic message / result code / baseDN from the search request in the |
I've merged that fix into main. It's going to be rough keeping compatibility between my new |
Send NO_SUCH_OBJECT (32) instead of SUCCESS (2) as code of SearchResultDone message when no entries where returned. This matches the ldap spec, and behavior of other ldap server implementations.