Full_Name: Philip Brusten Version: 2.4.47 OS: URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (2a02:2c40:100:b210::1:c3bc)
Hi
we are experiencing issues with MS LDAP clients that connect to our OpenLDAP servers since v2.4.47, because of the fix for issue ITS#8840
That fix was based on (old?) documentation of MS from https://msdn.microsoft.com/en-us/library/aa366979%28v=vs.85%29.aspx The is no current version of this document. At https://docs.microsoft.com/en-us/windows/win32/api/_ldap/ there is a link to Lightweigt Directory Access Protocol (https://docs.microsoft.com/en-us/windows/desktop/ldap), but it gives a 404.
MS is the owner of that LDAPControl LDAP_SERVER_DOMAIN_SCOPE_OID 1.2.840.113556.1.4.1339. According to the RFC4511 [1] the controlValue is defined by its specification:
The controlValue may contain information associated with the controlType. Its format is defined by the specification of the control. Implementations MUST be prepared to handle arbitrary contents of the controlValue octet string, including zero bytes. It is absent only if there is no value information that is associated with a control of its type. When a controlValue is defined in terms of ASN.1, and BER-encoded according to Section 5.1, it also follows the extensibility rules in Section 4.
The latest specification can be found at: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/ba5f20c...
"When sending this control to the DC, the controlValue field of the Control
structure is omitted."
We observed that whenever MS clients are sending the domainScope control they add an octet string as the controlValue with bytes "04 00". But this causes the OpenLDAP code if ( !BER_BVISNULL( &ctrl->ldctl_value )) { to evaluate to true, which returns the LDAP_PROTOCOL_ERROR in OpenLDAP.
The LDAP Extended Control spec of MS states [2]:
If the controlValue field contains data that is not in conformance with the specification of the control, including the case where the controlValue field
contains
data and the specification of the control states that the controlValue field
is omitted,
then if the control is marked critical the server returns the error unavailableCriticalExtension / ERROR_INVALID_PARAMETER. If the controlValue
field is
incorrect but the control is not marked critical, the server ignores the
control.
So the server should only return an error when the control is marked critical. Otherwise it should *ignore* the control.
Is it possible to relax the validation of the LDAP control at [3]? Since there is no value associated with this control, it should not matter if the controlValue is missing or an empty octet string {0,NULL}...
The ldapsearch code sets the controlValue to [4]:
c[i].ldctl_value.bv_val = NULL; c[i].ldctl_value.bv_len = 0;
We observed that the controlValue is than missing via Wireshark. So we see a difference on the line for empty octet strings, but should it matter?
Wireshark trace of MS LDAP client with domainScope control: https://i.imgur.com/gwBjLMr.png Wireshark trace of ldapsearch with domainScope control: https://i.imgur.com/2RbFkIY.png
Regards, Philip
[1] https://tools.ietf.org/html/rfc4511#section-4.1.11 [2] https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3c5e87d... [3] https://github.com/openldap/openldap/blob/master/servers/slapd/controls.c#L1... [4] https://github.com/openldap/openldap/blob/master/clients/tools/ldapsearch.c#...