Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jul 17, 2023

Conversation

buyaa-n
Copy link
Member

@buyaa-n buyaa-n commented Jul 13, 2023

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

internal const string OpenLdap = "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

…Dll event that tries to load other libraries
@ghost
Copy link

ghost commented Jul 13, 2023

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

internal const string OpenLdap = "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: -

Copy link
Member

@joperezr joperezr left a comment

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.

Copy link
Member

@steveharter steveharter left a comment

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

@buyaa-n
Copy link
Member Author

buyaa-n commented Jul 17, 2023

Failures unrelated and known

@buyaa-n buyaa-n merged commit 90b85ea into dotnet:main Jul 17, 2023
100 of 103 checks passed
@buyaa-n buyaa-n deleted the add_libldap_callback branch July 17, 2023 21:03
@ghost ghost locked as resolved and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants