I have created an intranet application that needs to know who the authenticated windows user is for security and roles-based authentication.
No problems with Edge... the authenticated user is identified correctly. In Chrome, though, the users are continually prompted (even if they enter their credentials in the prompt).
I am prompted when running the web app locally (IIS Express) as well as when deployed to a web server running IIS 7.5
I have tried various iis app pool configurations, none of which prevent the authentication prompt. The url is in the trusted list of websites in Internet Options. Windows Authentication and Identity Impersonation are enabled in IIS.
Home component API call:
constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string)
{
http.get<User>(baseUrl + 'api/Auth/GetUserName', {withCredentials: true}).subscribe(result =>
{
this.user = result;
}, error => console.error(error));
}
C# Controller:
[Route("api/[controller]")]
[ApiController]
public class AuthController : Controller
{
[AllowAnonymous]
[HttpGet("[action]")]
public User GetUserName()
{
WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
string domainContextName = "";
try
{
DomainContext domainContext = AppHelper.CurrentDomainContext;
domainContextName = domainContext.UserId;
}
catch(Exception ex)
{
domainContextName = ex.Message;
}
User user = new User()
{
WindowsIdentityGetCurrent = currentUser.Name,
HttpContextUserIdentityName = HttpContext.User.Identity.Name,
DomainContextName = domainContextName
};
return user;
}
}