Skip to content

Commit c820654

Browse files
Isaiah InuwaIsaiah Inuwa
authored andcommitted
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.
1 parent 126eeaa commit c820654

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Linux.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ private int InternalConnectToServer()
3232
// available during init.
3333
Debug.Assert(!_ldapHandle.IsInvalid);
3434

35-
string scheme = "ldap://";
35+
string scheme = null;
3636
LdapDirectoryIdentifier directoryIdentifier = (LdapDirectoryIdentifier)_directoryIdentifier;
37+
if (directoryIdentifier.Connectionless)
38+
{
39+
scheme = "cldap://";
40+
}
41+
else if (SessionOptions.SecureSocketLayer)
42+
{
43+
scheme = "ldaps://";
44+
}
45+
else
46+
{
47+
scheme = "ldap://";
48+
}
3749

3850
string uris = null;
3951
string[] servers = directoryIdentifier.Servers;

src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.Linux.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ public partial class LdapSessionOptions
99
{
1010
private static void PALCertFreeCRLContext(IntPtr certPtr) { /* No op */ }
1111

12-
[SupportedOSPlatform("windows")]
13-
public bool SecureSocketLayer
14-
{
15-
get => throw new PlatformNotSupportedException();
16-
set => throw new PlatformNotSupportedException();
17-
}
12+
public bool SecureSocketLayer { get; set; }
1813

1914
public int ProtocolVersion
2015
{

0 commit comments

Comments
 (0)