Hi folks,
I am using asp.net core with windows authentication. Here is my docker file
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["WindowsAuth.csproj", "./"]
RUN dotnet restore "./WindowsAuth.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "WindowsAuth.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "WindowsAuth.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WindowsAuth.dll"]
And I have created API Controller:
[HttpGet("test2")]
public ActionResult<IEnumerable<string>> GetADUsername2()
{
var adUsername = User.Identity.Name.Split('\\').Last();
return Ok(adUsername);
}
// GET: api/values/ADUsername
[HttpGet("test3")]
public ActionResult<IEnumerable<string>> GetADUsername3()
{
var isAuthenticated = User.Identity.IsAuthenticated.ToString();
var authenticatType = User.Identity.AuthenticationType;
var adUsername = User.Identity.Name.Split('\\').Last();
return new string[] { adUsername, isAuthenticated, authenticatType };
}
I have set Enable Windows Authentication from IIS Express Launch in Visual studio 2017. It seems ok but if I build and run docker container and image and I am unable to get username when windows logged.
How to implement asp.net core with windows authentication in docker container?
I am waiting for your response.
Thanks in Advance.