1

I know this question was asked but nobody answer it.

I'm building web API on Core 2.2 with JWT token bearer. In token request I added check if user exist on our LDAP.

All working properly on IIS and console app but when I run with docker I'm getting:

"Unable to load DLL 'activeds.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)" 

error.

If user exist all working fine but when user not exist Im checking user status with:

UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);

Which causing error above.

Im new to docker. I have tried to play with images:

mcr.microsoft.com/dotnet/core/sdk mcr.microsoft.com/dotnet/core/aspnet microsoft/aspnetcore-build

In all cases the same result

I have exposed LDAP ports in docker file (or I think I exposed) and still getting the same error.

My current dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 383
EXPOSE 636

FROM mcr.microsoft.com/dotnet/core/sdk AS build
WORKDIR /src
COPY ["USITWebApi/USITWebApi.csproj", "USITWebApi/"]
RUN dotnet restore "USITWebApi/USITWebApi.csproj"
COPY . .
WORKDIR "/src/USITWebApi"
RUN dotnet build "USITWebApi.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "USITWebApi.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "USITWebApi.dll"]

I'm using Windows containers.

I spent three days trying to solve this. If you have any ideas please help me solve this issue.

addicted
  • 53
  • 1
  • 8

1 Answers1

0

Looks that it is a limitation based on the image that you are using as base. If you would like to use LDAP use any server core image based on your host OS. This is what I am doing. This is a example for Windows 2019 Server as host.

FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS base

WORKDIR /app

EXPOSE 80

RUN powershell Set-ExecutionPolicy RemoteSigned

RUN powershell iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

RUN powershell choco install dotnet-6.0-runtime -Y
RUN powershell choco install dotnet-6.0-sdk -y

ENV ASPNETCORE_URLS=http://+80

RUN powershell fsutil behavior set symlinkEvaluation L2L:1 L2R:1 R2R:1 R2L:1

RUN powershell Set-ExecutionPolicy Bypass -Scope Process

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build

WORKDIR /src

COPY ["src/Your.ProjectFile.csproj", "src/Your.Project.Folder/"]
COPY ["./NuGet.Config", "src/Your.Project.Folder"]

RUN dotnet restore "src/Your.Project.Folder/Your.ProjectFile.csproj"

COPY . .
WORKDIR "/src/src/Your.Project.Folder"
RUN dotnet build "Your.ProjectFile.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Your.ProjectFile.csproj" -c Release -o /app/publish

FROM base

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "Your.ProjectFile.dll"]
Flavio Francisco
  • 755
  • 1
  • 8
  • 21