Expose ResultCode and DiagnosticMessage on SearchResult - #626
Open
Pujathacker2210 wants to merge 1 commit into
Open
Pujathacker2210 wants to merge 1 commit into
Pujathacker2210 wants to merge 1 commit into
Conversation
GetLDAPError returns nil when resultCode is 0, discarding the diagnosticMessage. Some servers set this field on success to signal degraded state (e.g. directory reinitializing). Add ResultCode and DiagnosticMessage to SearchResult, populated before GetLDAPError. Add ParseLDAPResult to read all LDAPResult fields without the early return on success. GetLDAPError is unchanged. Existing callers are unaffected.
Author
|
@t2y @cpuschma @johnweldon - Request you to review the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GetLDAPErrorreturnsnilwhenresultCodeis 0 (success), discardingthe
diagnosticMessagefromSearchResultDone. Per RFC 4511 §4.1.9, serversmay set
diagnosticMessageeven on a successful operation to communicateadditional information such as degraded state.
For example, Red Hat IPA sets
diagnosticMessagewhen the directory isreinitializing but still returns
resultCode0 with an empty entry list.Callers of
Search()currently have no way to see that message — they onlysee zero entries and no error, which is indistinguishable from a genuine
empty result.
Solution
ResultCodeandDiagnosticMessagefields toSearchResult.Search(), populate them from theSearchResultDonepacket (case 5) before callingGetLDAPError, so they are preserved even whenGetLDAPErrorreturnsnilon success.ParseLDAPResulthelper that extractsresultCode,matchedDN, anddiagnosticMessagefrom anLDAPResultBER packet without the early return on success thatGetLDAPErrorhas.appendToso paged searches preserve them.Backward compatibility
GetLDAPErroris unchanged.SearchResultis a struct; adding fields is backward compatible in Go.result.DiagnosticMessageafterSearch()returns.References
Prior art
Python's
python-ldaplibrary already exposes the diagnostic message after successful operations by callingget_option(OPT_DIAGNOSTIC_MESSAGE)on the LDAP handle (source). This PR brings the same capability togo-ldapby surfacingdiagnosticMessageon theSearchResultstruct regardless ofresultCode.