Description
Description
When using System.DirectoryServices.Protocols.LdapConnection to connect to an LDAPS target on CentOS7, throws the error of
Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.DirectoryServices.Protocols.LdapSessionOptions.set_SecureSocketLayer(Boolean value)
at activeDirectoryLdapExamples.Program.Main(String[] str) in /home/iguy/exceptionless/Program.cs:line 23
Example Code:
using System;
using System.Net;
using System.DirectoryServices.Protocols;
namespace LdapsExample
{
class Program
{
static void Main(String[] str)
{
var ldapInfo = new LdapDirectoryIdentifier("1.2.3.4", 636);
using (var ldapConnection = new LdapConnection(ldapInfo))
{
var nC = new System.Net.NetworkCredential("ldaps_login", "my_password");
ldapConnection.AuthType = AuthType.Negotiate;
ldapConnection.SessionOptions.ProtocolVersion = 3;
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.VerifyServerCertificate += delegate { return true; };
ldapConnection.Bind(nC);
}
Console.WriteLine("True");
}
}
}
Configuration
.NET SDK (reflecting any global.json):
Version: 5.0.100-rc.2.20479.15
Commit: da7dfa8840
Runtime Environment:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
Base Path: /usr/share/dotnet/sdk/5.0.100-rc.2.20479.15/
Host (useful for support):
Version: 5.0.0-rc.2.20475.5
Commit: c5a3f49
.NET SDKs installed:
5.0.100-rc.2.20479.15 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
OS: CentOS 7 patched as of 2020-10-01 on x86_64