Skip to content

Commit 4d776fd

Browse files
committed
Do not throw when library not found
1 parent 298469c commit 4d776fd

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,19 @@ static Ldap()
7474
// Register callback that tries to load other libraries when the default library "libldap-2.5.so.0" not found
7575
AssemblyLoadContext.GetLoadContext(currentAssembly).ResolvingUnmanagedDll += (assembly, ldapName) =>
7676
{
77-
IntPtr handle = IntPtr.Zero;
78-
7977
if (assembly != currentAssembly || ldapName != Libraries.OpenLdap)
8078
{
81-
return handle;
79+
return IntPtr.Zero;
8280
}
8381

8482
// Try loading previous (libldap-2.4.so.2) and next (libldap-2.6.so.0) versions
85-
if (NativeLibrary.TryLoad("libldap-2.4.so.2", out handle) ||
83+
if (NativeLibrary.TryLoad("libldap-2.4.so.2", out IntPtr handle) ||
8684
NativeLibrary.TryLoad("libldap-2.6.so.0", out handle))
8785
{
8886
return handle;
8987
}
9088

91-
throw new DllNotFoundException(SR.Format(SR.LDAP_LIBRARY_NOT_FOUND, ldapName));
89+
return IntPtr.Zero;
9290
};
9391

9492
// OpenLdap must be initialized on a single thread, once this is done it allows concurrent calls

src/libraries/System.DirectoryServices.Protocols/src/Resources/Strings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,4 @@
426426
<data name="ReferralChasingOptionsNotSupported" xml:space="preserve">
427427
<value>Only ReferralChasingOptions.None and ReferralChasingOptions.All are supported on Linux.</value>
428428
</data>
429-
<data name="LDAP_LIBRARY_NOT_FOUND" xml:space="preserve">
430-
<value>The OpenLDAP library with version {0} was not found.</value>
431-
</data>
432429
</root>

0 commit comments

Comments
 (0)