Closed t2y closed 1 year ago
https://github.com/go-ldap/ldap/pull/446 will fix DATA RACE with GetLastError()
. It is not an error due to this PR.
I rebased to include #446 for CI (github actions).
@cpuschma @johnweldon I've been waiting for this feature since March 2023 (#422). I have added the syncrepl feature so that the existing process has no side effects. What do you think?
I agree with @cpuschma; thank you for your work on this feature.
My involvement with this project is very limited now, so I'm okay with deferring to the other @go-ldap/committers as far as requested changes.
My overarching values are:
With this in mind, my vote is to approve this MR
@johnweldon Thank you for reviewing! I agree with your idea.
And then, I will try to implement this PR without duplicating the code this weekend. I think it's possible, but it might be a little complex. I will carefully integrate my new code to prevent the side effect.
After I discussed it with @cpuschma, I changed the design for maintainability.
Design
I added the syncrepl feature as one of the asynchronous search functions. The syncrepl is available on slapd in OpenLDAP project and it provides a persistent search. The syncrepl is proposed by rfc-4533.
(the below description is the original when I created this PR)
(Old) Design
At first, I tried to implement syncrepl feature into the same source. For example, the searchResponse struct has an asynchronous search process, DecodeControl() function has to decode various controls. However, I am concerned that they are challenging to handle syncrepl communications with other generic LDAP communications.
It has a complicated specification because syncrepl is proposed by rfc-4533. I think dividing existent control.go/response.go and related syncrepl code is stable and maintainable (Of course both belong to the same
ldap
package). Additionally, they won't put a bug on each other.Data flow
syncrepl has 4 Controls:
Controls
Sync Request Control as the following.
Sync Request with mode=RefreshAndPersist
Got entries and Sync Info Control as the following.
When a user is added
Got the entry and a Sync State Control such as the following.
When a user is modified
Got the entry and a Sync State Control such as the following.
When a user is deleted
Got the entry and a Sync State Control such as the following.
Sync Request with mode=RefreshOnly
Got entries and a Sync Done Control such as the following.
How to test
To enable syncrepl on the server side, add the below configuration into slapd.conf.
Then, call
Syncrepl()
method described in examples_test.go. I confirmed syncrepl feature works with OpenLDAP server 2.4/2.5 in my environment.I need more test patterns or more considerations since I'm new to LDAP protocol. Could you review it?
References
422
440