Aspnet Core 1.1 Missing Windows Authentication when published

帅比萌擦擦* 提交于 2019-12-07 06:06:26

So, I'm using IIS/Kestrel on .NET Core 1.1 compiled against full framework 4.6.2 and Windows authentication without issue. First thing, I have in my project a web.config with my config that gets published with my application, so I don't have to overwrite it everytime, it is part of my project and contains quite a lot of customization useful to me, unless I missunderstood you could use that as well. Then, in my case, forwardWindowsAuthToken="true" is good enough to be able to retrieve the windows authentication with a piece of code like that HttpContext.User.Identities.FirstOrDefault(id => id.GetType() == typeof(WindowsIdentity));

I think you are missing settings on the IIS level, forwardWindowsAuthToken is not enough, you also have to tell IIS that this particular web application is using windows authentication. To do so, I configure the "authentication" part of the web app, enable windows authentication, and pick the proper provider (negotiate in my case). If you just let the anonymous authentication enabled, then IIS won't ask to the client the identity of the user (using authentication protocol like negotiate and kerberos ticket) and won't transmit it to your .NET Core application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!