Skip to content

Commit

Permalink
Do not throw when library not found
Browse files Browse the repository at this point in the history
  • Loading branch information
buyaa-n committed Jul 14, 2023
1 parent 298469c commit 4d776fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,19 @@ static Ldap()
// Register callback that tries to load other libraries when the default library "libldap-2.5.so.0" not found
AssemblyLoadContext.GetLoadContext(currentAssembly).ResolvingUnmanagedDll += (assembly, ldapName) =>
{
IntPtr handle = IntPtr.Zero;

if (assembly != currentAssembly || ldapName != Libraries.OpenLdap)
{
return handle;
return IntPtr.Zero;
}

// Try loading previous (libldap-2.4.so.2) and next (libldap-2.6.so.0) versions
if (NativeLibrary.TryLoad("libldap-2.4.so.2", out handle) ||
if (NativeLibrary.TryLoad("libldap-2.4.so.2", out IntPtr handle) ||
NativeLibrary.TryLoad("libldap-2.6.so.0", out handle))
{
return handle;
}

throw new DllNotFoundException(SR.Format(SR.LDAP_LIBRARY_NOT_FOUND, ldapName));
return IntPtr.Zero;
};

// OpenLdap must be initialized on a single thread, once this is done it allows concurrent calls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,4 @@
<data name="ReferralChasingOptionsNotSupported" xml:space="preserve">
<value>Only ReferralChasingOptions.None and ReferralChasingOptions.All are supported on Linux.</value>
</data>
<data name="LDAP_LIBRARY_NOT_FOUND" xml:space="preserve">
<value>The OpenLDAP library with version {0} was not found.</value>
</data>
</root>

0 comments on commit 4d776fd

Please sign in to comment.