runtime: Missing package libldap-2.4.so.2 at runtime:5.0-buster-slim
Steps to reproduce the issue
- Create a .NET 5.0 Console app
- Run:
dotnet new nugetconfig
dotnet nuget add source -n dotnet5 https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet5/nuget/v3/index.json
- Get night build from System.DirectoryServices.Protocols, version 5.0.0-preview.6.20272.2
- Add the following code:
var credential = new NetworkCredential("<username>", "<password>");
var connection = new LdapConnection(new LdapDirectoryIdentifier("<ip(13.0.0.0)>", 389, false, false), credential);
connection.Bind();
- Run into container runtime:5.0-buster-slim Reference Dockerfile
FROM mcr.microsoft.com/dotnet/core/runtime:5.0-buster-slim AS base
RUN apt-get update && apt-get install -y libldap-2.4-2
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:5.0-buster AS build
WORKDIR /src
COPY ["TesteLdap/TesteLdap.csproj", "TesteLdap/"]
COPY ["nuget.config", "/src"]
RUN dotnet restore "TesteLdap/TesteLdap.csproj" --configfile "nuget.config"
COPY . .
WORKDIR "/src/TesteLdap"
RUN dotnet build "TesteLdap.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TesteLdap.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TesteLdap.dll"]
Expected behavior
Run without bugs
Actual behavior
We got this error at logs:
Unable to load shared library 'libldap-2.4.so.2' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibldap-2.4.so.2: cannot open shared object file: No such file or directory
Additional information (e.g. issue happens only occasionally)
The next version of System.DirectoryServices.Protocols has a dependency of libldap-2.4.
related to:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 41 (17 by maintainers)
@istretyakov - You would need to install the appropriate LDAP library in your Dockerfile. Examples provided below.
Debian/Ubuntu:
Alpine:
I’m sorry, i didn’t catch what is solution of this problem. For example, i have .NET 5.0 in Docker. And how can i use System.DirectoryServices.Protocols for connecting to Active Directory? What and how need i install? I understood that some libs there aren’t in .NET Docker images, but how to get round the problem?
This issue is still getting significant activity. I propose we update the error message, like the following:
From a container standpoint, I think think we made the best choice, to not install the ldap component. However, we need to do more to make this dependency problem self-diagnosable.
Also, this document doesn’t make any mention of a dangling dependency: https://docs.microsoft.com/dotnet/api/system.directoryservices.protocols.ldapconnection.
Related, this dependency likely isn’t constant across all distros. We should capture that somewhere, possibly at https://github.com/dotnet/core/blob/main/release-notes/6.0/linux-packages.md.
/cc @joperezr
So I finally did get this to work with the following docker file
I was still having issues with my connection not working with the cert so I add the libldap-common package and copied over a ldap.conf file that set the “TLS_REQCERT never”, after that I was able to query the AD and authenticate users.
@adithyasai - Your Dockerfile is installing the package in a Dockerfile stage that’s not being used when running your app. It’s being installed in the
buildstage which is only used to build your project. That stage is not used when actually running the app.Here’s the suggested update:
cc @joperezr - Just an FYI that we’ve decided to not include the libldap package in our Docker images.