Skip to content

Commit

Permalink
Addressing PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joperezr committed May 19, 2020
1 parent c3325d1 commit 1ebc2a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);0649;CA1810</NoWarn>
<IncludeDllSafeSearchPathAttribute>true</IncludeDllSafeSearchPathAttribute>
<TargetFrameworks>$(NetCoreAppCurrent)-OSX;netcoreapp2.0-OSX;$(NetCoreAppCurrent)-Linux;netcoreapp2.0-Linux;$(NetCoreAppCurrent)-Windows_NT;netstandard2.0;netcoreapp2.0-Windows_NT;_$(NetFrameworkCurrent)</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;netcoreapp2.0-Windows_NT;$(NetCoreAppCurrent)-OSX;netcoreapp2.0-OSX;$(NetCoreAppCurrent)-Linux;netcoreapp2.0-Linux;netstandard2.0;_$(NetFrameworkCurrent)</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,23 @@ public static bool IsLibLdapInstalled
{
get
{
#if NETCOREAPP
if (!_isLibLdapInstalled.HasValue)
{
try
if (PlatformDetection.IsOSX)
{
// Attempt PInvoking into libldap on Linux
IntPtr handle = ber_alloc_Linux(1);
ber_free_Linux(handle, 1);
_isLibLdapInstalled = true;
_isLibLdapInstalled = NativeLibrary.TryLoad("libldap.dylib", out _);
}
catch (Exception)
else
{
try
{
// Attempt PInvoking into libldap on OSX
IntPtr handle = ber_alloc_OSX(1);
ber_free_OSX(handle, 1);
_isLibLdapInstalled = true;
}
catch (Exception)
{
_isLibLdapInstalled = false;
}
_isLibLdapInstalled = NativeLibrary.TryLoad("libldap-2.4.so.2", out _);
}
}
return _isLibLdapInstalled.Value;
#else // In .NET Framework ldap is always installed.
return true;
#endif
}
}

internal const string OpenLdapLinux = "libldap-2.4.so.2";
internal const string OpenLdapOSX = "libldap";

[DllImport(OpenLdapLinux, EntryPoint = "ber_alloc_t", CharSet = CharSet.Ansi)]
internal static extern IntPtr ber_alloc_Linux(int option);

[DllImport(OpenLdapLinux, EntryPoint = "ber_free", CharSet = CharSet.Ansi)]
public static extern IntPtr ber_free_Linux([In] IntPtr berelement, int option);

[DllImport(OpenLdapOSX, EntryPoint = "ber_alloc_t", CharSet = CharSet.Ansi)]
internal static extern IntPtr ber_alloc_OSX(int option);

[DllImport(OpenLdapOSX, EntryPoint = "ber_free", CharSet = CharSet.Ansi)]
public static extern IntPtr ber_free_OSX([In] IntPtr berelement, int option);
}
}

0 comments on commit 1ebc2a9

Please sign in to comment.