go-ldap / ldap

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

ControlSyncRequest Encode: cookie optionality #459

Closed zeslava closed 1 year ago

zeslava commented 1 year ago

In SyncRequest cookie is optional, so do not add cookie if empty

zeslava commented 1 year ago

@t2y FYI

t2y commented 1 year ago

According to https://www.rfc-editor.org/rfc/rfc4533.html#section-2.2 , a cookie is optional. You are right.

      syncRequestValue ::= SEQUENCE {
          mode ENUMERATED {
              -- 0 unused
              refreshOnly       (1),
              -- 2 reserved
              refreshAndPersist (3)
          },
          cookie     syncCookie OPTIONAL,
          reloadHint BOOLEAN DEFAULT FALSE
      }

It works that I send nil cookie as no cookie to OpenLDAP server (2.4/2.5). https://www.rfc-editor.org/rfc/rfc4533.html#section-2.1 describes as below.

   The syncCookie is a notational convenience to indicate that, while
   the syncCookie type is encoded as an OCTET STRING, its value is an
   opaque value containing information about the synchronization session
   and its state.  Generally, the session information would include a
   hash of the operation parameters that the server requires not be
   changed and the synchronization state information would include a
   commit (log) sequence number, a change sequence number, or a time
   stamp.  For convenience of description, the term "no cookie" refers
   either to a null cookie or to a cookie with pre-initialized
   synchronization state.

      syncCookie ::= OCTET STRING

I wonder how we handle reloadHint when we don't send a cookie.

mode
cookie
reloadHint
mode
reloadHint

or

mode

@cpuschma What do you think about proper implementation?

t2y commented 1 year ago

@zeslava Thank you for notifying me. I am new to LDAP protocol. I want to think together about which implementation is better.

cpuschma commented 1 year ago

Agreed, we should stick to the LDAP RFCs and not derivate whereever possible