go-ldap / ldap

Basic LDAP v3 functionality for the GO programming language.
Other
2.23k stars 352 forks source link

request: notification example #302

Open jdef opened 3 years ago

jdef commented 3 years ago

I see the API has a ControlTypeMicrosoftNotification, presumably to support async search results coming back from the server. I spent a few minutes skimming the search code and it's not immediately clear to me how to perform an async search using the v3 API.

Would someone be so kind as to provide an example? Or, if not possible given the current API, perhaps suggest a set of changes that might suffice to enable such?

stefanmcshane commented 3 years ago

Hi @jdef,

The controls can be passed into the search requests using []Control. Here is an example for manual paging, which does an overlay on how to pass in controls. Beherap Policy is another example where such controls are used.

Let me know if this helps or if there is anything else I can do to help.

Thanks, Stefan

jdef commented 3 years ago

Thanks for the pointers. It's unclear whether these examples are applicable. AFAICT from the Microsoft documentation, when a client requests notifications, then the server will continue to send updates on the already-established connection w/o need for further requests from the client. The pagination example issues repeated requests for each page, and is a distinct different flow. The go LDAP code looks like it expects calling code to model the typical request/response pattern, vs. request-and-then-listen-for-multiple-responses (for notifications).

Am I missing something obvious?

On Fri, Mar 26, 2021 at 2:59 PM Stefan McShane @.***> wrote:

Hi @jdef https://github.com/jdef,

The controls can be passed into the search requests using []Control. Here is an example https://github.com/go-ldap/ldap/blob/c9551dc8a15abc270d5ea1a59366622cba6c09a5/examples_test.go#L309 for manual paging, which does an overlay on how to pass in controls. Beherap Policy https://github.com/go-ldap/ldap/blob/c9551dc8a15abc270d5ea1a59366622cba6c09a5/examples_test.go#L225 is another example where such controls are used.

Let me know if this helps or if there is anything else I can do to help.

Thanks, Stefan

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/go-ldap/ldap/issues/302#issuecomment-808447385, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR5KLDVNVI2AIB6CE7MLATTFTKSHANCNFSM4VZW65OA .

-- James DeFelice 585.241.9488 (voice) 650.649.6071 (fax)

stefanmcshane commented 3 years ago

Hi @jdef, Thanks for clarifying. I'm going to dig further into this at the weekend and will get back to you then. From what I know, the LDAP client should still receive notifications, however I see your issue in that there may not be an exposed method for listening to the responses, unless it was a direct request-response method.

In theory, they should appear in the debug logs in line 498 or 502. I don't believe that you are missing anything obvious. If the feature exists, ill add an example for this so it is more obvious in future. If you have any specific usecases you would like me to test, let me know.

Thanks, Stefan