Add support for TLS and connectionless LDAP connections on Linux (#52904)
authoriinuwa <isaiah.inuwa@gmail.com>
Thu, 3 Jun 2021 18:21:41 +0000 (13:21 -0500)
committerGitHub <noreply@github.com>
Thu, 3 Jun 2021 18:21:41 +0000 (11:21 -0700)
commit32918374655b5e1c3fc7810bbb0c06a0d03265b7
treeb5d9b38e32c17070a9d1f3a4bbe5308f2b80dfc2
parent01a8f497a0fb02aac891ae400fd59b5de65c0244
Add support for TLS and connectionless LDAP connections on Linux (#52904)

* Set LDAP version with pointers on Linux

* Replace deprecated OpenLDAP methods

In OpenLDAP, ldap_simple_bind_s is deprecated in favor of
ldap_sasl_bind_s with the LDAP_SASL_SIMPLE auth method[1][].
Similarly, ldap_init is deprecated in favor of ldap_initialize[2][].
The newer APIs also allows us to specify a URI to use TLS with OpenLDAP.

[1]: https://git.openldap.org/openldap/openldap/-/blob/OPENLDAP_REL_ENG_2_4_58/include/ldap.h#L1278
[2]: https://git.openldap.org/openldap/openldap//blob/OPENLDAP_REL_ENG_2_4_58/include/ldap.h#L1513

* Add TLS and connectionless LDAP support to Linux

This commit manually specifies the LDAP URI option during connect
(but before binding). This is necessary because in order to know the
correct scheme, we need access to SessionOptions, which is not available
until after initialization.

Finally, it removes the PlatformUnsupportedException from the
SessionOptions.SecureSocketLayer property.

This makes it possible to use LDAP over TLS and connectionless (UDP)
LDAP.

* Add test configuration for LDAP TLS server
src/libraries/Common/src/Interop/Interop.Ldap.cs
src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs
src/libraries/Common/tests/System/DirectoryServices/LDAP.Configuration.xml
src/libraries/Common/tests/System/DirectoryServices/LdapConfiguration.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/LdapPal.Linux.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Linux.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Windows.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs
src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesProtocolsTests.cs