Skip to content

Register a callback that tries to load other versions Open LDAP library if the default is failed - #88851

Merged
buyaa-n merged 4 commits into
dotnet:mainfrom
buyaa-n:add_libldap_callback
Jul 17, 2023
Merged

Register a callback that tries to load other versions Open LDAP library if the default is failed#88851
buyaa-n merged 4 commits into
dotnet:mainfrom
buyaa-n:add_libldap_callback

Conversation

@buyaa-n

@buyaa-nbuyaa-n commented Jul 13, 2023

Copy link
Copy Markdown
Contributor

Register a callback that tries to load other versions of Open LDAP library if the default is failed

Open LDAP library version is hardcoded in runtime and used for native calls

internalconststringOpenLdap="libldap-2.4.so.2";

From Ubuntu 22.04 only the new version of the library (libldap-2.5.so.0) is included in OS, so System.DirectoryServices.Protocols.LdapConnection fails to find the new version of the LDAP library as mentioned in the issue.

@AaronRobinsonMSFT pointed out that we can register a callback to AssemblyLoadContext.Default.ResolvingUnmanagedll event. This event is raised if the native library could not be resolved via the default resolution logic.

The PR doesn't include a specific test, I don't think I can test the logic added here specifically, let me know if you have a testing idea. Though all existing tests that connects to LDAP server would test this, run the tests locally on Ubuntu 22.04, after the fix all tests that require LDAP server passed. (No CI test runs LDAP server so they are skipped in CI)

Fixes#69456

@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014
See info in area-owners.md if you want to be subscribed.

Issue Details

Register a callback that tries to load other versions of Open LDAP library if the default is failed

Open LDAP library version is hardcoded in runtime and used for native calls

internalconststringOpenLdap="libldap-2.4.so.2";

From Ubuntu 22.04 only the new version of the library (libldap-2.5.so.0) is included in OS, so System.DirectoryServices.Protocols.LdapConnection fails to find the new version of the LDAP library as mentioned in the issue.

@AaronRobinsonMSFT pointed out that we can register a callback to AssemblyLoadContext.Default.ResolvingUnmanagedll event. This event is raised if the native library could not be resolved via the default resolution logic.

The PR doesn't include a specific test, I don't think I can test the logic added here specifically, let me know if you have a testing idea. Though all existing tests that connects to LDAP server would test this run the tests locally, all passes. (No CI test runs LDAP server so they are skipped in CI)

Fixes #69456

Author:buyaa-n
Assignees:-
Labels:

area-System.DirectoryServices

Milestone:-

Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/System.DirectoryServices.Protocols/src/Resources/Strings.resx Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated

@joperezrjoperezr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @buyaa-n. Changes LGTM but I'll defer to @AaronRobinsonMSFT and @elinor-fung for what the best approach to hook to that event is.

Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
Comment threadsrc/libraries/Common/src/Interop/Linux/Interop.Libraries.cs

@stevehartersteveharter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending question on patch versions

Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
@buyaa-n
buyaa-nforce-pushed the add_libldap_callback branch from 8b65ba2 to 4d776fdCompareJuly 14, 2023 21:24
@buyaa-n
buyaa-n requested a review from elinor-fungJuly 14, 2023 21:26
Comment threadsrc/libraries/Common/src/Interop/Linux/OpenLdap/Interop.Ldap.cs Outdated
@buyaa-n

Copy link
Copy Markdown
ContributorAuthor

Failures unrelated and known

@buyaa-n
buyaa-n merged commit 90b85ea into dotnet:mainJul 17, 2023
@buyaa-n
buyaa-n deleted the add_libldap_callback branch July 17, 2023 21:03
@ghostghost locked as resolved and limited conversation to collaborators Aug 17, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.DirectoryServices.Protocols.LdapConnection fails to find the new version of the LDAP library on Ubuntu 22.04

6 participants

@buyaa-n@jkoritzinsky@steveharter@joperezr@AaronRobinsonMSFT@elinor-fung