在 .NET 4 MVC 2 中启用 Windows 身份验证
我有一个 Intranet 站点读取 Windows 用户名并使用它在网站中进行身份验证。
我的代码在本地运行,但在 Windows Server 2003 上使用 IIS 6 托管并检查匿名访问时,不会读取登录名。如果我取消选中匿名访问,那么在 Firefox 中,我会不断弹出用户名和密码的窗口,而且永远不会结束。在 IIS 6 中,它设置为框架 4,并拥有自己的应用程序池。
用户.身份.名称
-在服务器上返回空白,但在本地
web.config 上工作正常: <身份验证模式=“Windows”/>
我有一个较旧的 3.5 Webforms 网站,可以在同一台服务器上正常运行。
I have an Intranet site reading the windows user name and using it for authentication in the website.
My code works locally but does not read the login name when hosted using IIS 6 on Windows Server 2003 with anonymous access checked. If I un-check anonymous access then in Firefox I keep getting a pop up for username and password which never ends. In IIS 6 it is set to framework 4 and has its own application pool.
User.Identity.Name
-returns blank on the server but works fine locally
web.config:<authentication mode="Windows"/>
<identity impersonate="true"/>
I have an older 3.5 webforms site that works fine on the same server..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看分配用于运行应用程序池的 Windows 帐户。它对您的.Net 应用程序有授权吗?
要使用 Windows 身份验证,您需要取消选中匿名访问。
删除 impersonate 属性,或将其设置为 false(默认值)。
您可以将应用程序池设置为使用 Network Service 帐户,然后授予 Network Service 帐户对 MVC 文件夹的读/写权限。
Look at the Windows account assigned to run the app pool. Does it have authorization to your .Net application?
To use Windows auth, you'll want to un-check anonymous access.
Either remove the impersonate attribute, or set it to false (the default).
You can set the app pool to use the Network Service account and then grant the Network Service account read/write authorization to your MVC folder.