diff --git a/src/libraries/Common/src/Interop/OSX/Interop.Libraries.cs b/src/libraries/Common/src/Interop/OSX/Interop.Libraries.cs
index 6c2a0ab78c8d74..9ba6608df12124 100644
--- a/src/libraries/Common/src/Interop/OSX/Interop.Libraries.cs
+++ b/src/libraries/Common/src/Interop/OSX/Interop.Libraries.cs
@@ -14,6 +14,7 @@ internal static partial class Libraries
internal const string LibSystemCommonCrypto = "/usr/lib/system/libcommonCrypto";
internal const string LibSystemKernel = "/usr/lib/system/libsystem_kernel";
internal const string Odbc32 = "libodbc.2.dylib";
+ internal const string OpenLdap = "libldap";
internal const string SystemConfigurationLibrary = "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration";
internal const string AppleCryptoNative = "System.Security.Cryptography.Native.Apple";
internal const string MsQuic = "msquic";
diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj b/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj
index 2ffb1d93dfbc6a..03d310243f3b35 100644
--- a/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj
+++ b/src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj
@@ -3,7 +3,7 @@
true
$(NoWarn);0649;CA1810
true
- $(NetCoreAppCurrent)-Linux;netcoreapp2.0-Linux;$(NetCoreAppCurrent)-Windows_NT;netstandard2.0;netcoreapp2.0-Windows_NT;_$(NetFrameworkCurrent)
+ $(NetCoreAppCurrent)-Windows_NT;netcoreapp2.0-Windows_NT;$(NetCoreAppCurrent)-OSX;netcoreapp2.0-OSX;$(NetCoreAppCurrent)-Linux;netcoreapp2.0-Linux;netstandard2.0;_$(NetFrameworkCurrent)
true
@@ -57,16 +57,13 @@
Common\Interop\Windows\Wldap32\Interop.Ber.cs
-
+
-
- Common\Interop\Linux\Interop.Libraries.cs
-
Common\Interop\Linux\OpenLdap\Interop.Ldap.cs
@@ -74,6 +71,16 @@
Common\Interop\Linux\OpenLdap\Interop.Ber.cs
+
+
+ Common\Interop\Linux\Interop.Libraries.cs
+
+
+
+
+ Common\Interop\OSX\Interop.Libraries.cs
+
+
diff --git a/src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesTestHelpers.cs b/src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesTestHelpers.cs
index 80ac7ec9c6084c..98d45457c7ae70 100644
--- a/src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesTestHelpers.cs
+++ b/src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesTestHelpers.cs
@@ -16,34 +16,31 @@ public static class DirectoryServicesTestHelpers
// Cache the check once we have performed it once
private static bool? _isLibLdapInstalled = null;
+ ///
+ /// Returns true if able to PInvoke into Linux or OSX, false otherwise
+ ///
public static bool IsLibLdapInstalled
{
get
{
+#if NETCOREAPP
if (!_isLibLdapInstalled.HasValue)
{
- try
+ if (PlatformDetection.IsOSX)
{
- // Attempt PInvoking into libldap
- IntPtr handle = ber_alloc(1);
- ber_free(handle, 1);
- _isLibLdapInstalled = true;
+ _isLibLdapInstalled = NativeLibrary.TryLoad("libldap.dylib", out _);
}
- catch (Exception)
+ else
{
- _isLibLdapInstalled = false;
+ _isLibLdapInstalled = NativeLibrary.TryLoad("libldap-2.4.so.2", out _);
}
}
return _isLibLdapInstalled.Value;
+#else
+ _isLibLdapInstalled = true; // In .NET Framework ldap is always installed.
+ return _isLibLdapInstalled.Value;
+#endif
}
}
-
- internal const string OpenLdap = "libldap-2.4.so.2";
-
- [DllImport(OpenLdap, EntryPoint = "ber_alloc_t", CharSet = CharSet.Ansi)]
- internal static extern IntPtr ber_alloc(int option);
-
- [DllImport(OpenLdap, EntryPoint = "ber_free", CharSet = CharSet.Ansi)]
- public static extern IntPtr ber_free([In] IntPtr berelement, int option);
}
}
diff --git a/src/libraries/System.DirectoryServices.Protocols/tests/System.DirectoryServices.Protocols.Tests.csproj b/src/libraries/System.DirectoryServices.Protocols/tests/System.DirectoryServices.Protocols.Tests.csproj
index 164327720e3302..4c621fb35408be 100644
--- a/src/libraries/System.DirectoryServices.Protocols/tests/System.DirectoryServices.Protocols.Tests.csproj
+++ b/src/libraries/System.DirectoryServices.Protocols/tests/System.DirectoryServices.Protocols.Tests.csproj
@@ -1,6 +1,6 @@
- $(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Windows_NT;$(NetFrameworkCurrent)
+ $(NetCoreAppCurrent);$(NetFrameworkCurrent)