简体   繁体   English

Windows身份验证MVC 4 Intranet

[英]Windows Authentication MVC 4 Intranet

In a mvc 4 intranet site is, how would you force the user to enter windows credentials when the app loads for say the Home Controller Index Action. 在mvc 4内部网站点中,当应用程序加载时,如果主页控制器索引操作,您将如何强制用户输入Windows凭据。 It seems as though the browser is remembering the password. 似乎浏览器正在记住密码。 If so, can you disable the browsers' from remembering? 如果是这样,你可以禁止浏览器记住吗?

I am using IIS Express. 我正在使用IIS Express。

I have allow anonymous authentication disabled windows authentication enabled and the Index Action for the Home Controller has the Authorize attribute. 我允许启用匿名身份验证禁用Windows身份验证,并且主控制器的索引操作具有Authorize属性。 (now trying controller level) (现在尝试控制器级别)

I thought that forces to Enter credentials. 我以为强制输入凭据。

I was following this http://www.itorian.com/2013/05/windows-authentication-in-mvc4-with-iis.html 我正在关注这个http://www.itorian.com/2013/05/windows-authentication-in-mvc4-with-iis.html

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="autoFormsAuthentication" value="false" />
    <add key="enableSimpleMembership" value="false"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Windows" />
    <authorization>
      <deny users="?" />
    </authorization>
    <identity impersonate="true" />    
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

Controller 调节器

[Authorize]
public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

        return View();
    }
    public ActionResult About()
    {
        ViewBag.Message = "Your app description page.";

        return View();
    }

    public ActionResult Contact()
    {
        ViewBag.Message = "Your contact page.";

        return View();
    }
}

This is me just guessing as you haven't provided <appSettings> part: 这是我猜你没有提供<appSettings>部分:

The guide (it's same link as you've provided) says that you should've set these 2 values: 指南 (与您提供的链接相同)表示您应该设置以下两个值:

<add key="autoFormsAuthentication" value="false" />
<add key="enableSimpleMembership" value="false"/>

This is the only thing that comes to mind and every source I could find points to autoFormsAuthentication change. 这是唯一想到的东西,我可以找到指向autoFormsAuthentication更改的每个源。

Another thing I've found is Microsoft's guide . 我发现的另一件事是微软的指南 It's fo MVC 3, but I don't thing there were any major changes regarding this. 这是MVC 3,但我不认为这有任何重大变化。 It's longer than your original tutorial, but it covers all the setup and explains everything you need to do. 它比原始教程更长,但它涵盖了所有设置并解释了您需要做的所有事情。

When you know why the prompt appears, you know how to turn it on and off, 当您知道提示出现的原因时,您知道如何打开和关闭它,

http://support.microsoft.com/kb/258063 http://support.microsoft.com/kb/258063

The following conditions must be met for Internet Explorer to automatically authenticate a user's logon and password and maintain security: Internet Explorer必须满足以下条件才能自动验证用户的登录名和密码并保持安全性:

  • Windows Integrated authentication, also known as Windows NT Challenge/Response, must be enabled in the Web site properties in IIS. 必须在IIS的网站属性中启用Windows集成身份验证,也称为Windows NT质询/响应。 Anonymous authentication is attempted first, followed by Windows Integrated authentication, Digest authentication (if applicable), and finally Basic (clear text) authentication. 首先尝试匿名身份验证,然后是Windows集成身份验证,摘要身份验证(如果适用),最后是基本(明文)身份验证。
  • Both the client and the Web server must be either in the same Microsoft Windows NT-based or Microsoft Windows 2000-based domain or in trusted Windows NT-based or Windows 2000-based domains in which the user's account can be granted permissions to resources on the IIS-based computer. 客户端和Web服务器必须位于相同的基于Microsoft Windows NT或基于Microsoft Windows 2000的域中,或者位于基于受信任Windows NT或基于Windows 2000的域中,在该域中,可以向用户的帐户授予对资源的权限基于IIS的计算机。
  • The user's browser must be Internet Explorer. 用户的浏览器必须是Internet Explorer。 Internet Explorer is the only browser that supports Windows Integrated authentication (NTCR). Internet Explorer是唯一支持Windows集成身份验证(NTCR)的浏览器。
  • Internet Explorer must consider the requested URL to be on the intranet (local). Internet Explorer必须将请求的URL视为Intranet(本地)。 If the computer name portion of the requested URL contains periods (such as 如果请求的URL的计算机名称部分包含句点(例如 http://www.microsoft.com and 10.0.0.1), Internet Explorer assumes that the requested address exists on the Internet and does not pass any credentials automatically. http://www.microsoft.com和10.0.0.1),Internet Explorer假定Internet上存在请求的地址,并且不会自动传递任何凭据。 Addresses without periods (such as webserver) are considered to be on the intranet (local); 没有句点的地址(例如网络服务器)被认为是在内联网(本地)上; Internet Explorer passes credentials automatically. Internet Explorer自动传递凭据。 The only exception is addresses included in the Intranet zone in Internet Explorer. 唯一的例外是Internet Explorer中的Intranet区域中包含的地址。
  • Internet Explorer's Intranet zone security setting must be set to Automatic logon only in Intranet zone. Internet Explorer的Intranet区域安全设置必须设置为仅在Intranet区域中自动登录。 This is the default setting for Internet Explorer. 这是Internet Explorer的默认设置。 For additional information about Internet Explorer security zones, click the article number below to view the article in the Microsoft Knowledge Base: 有关Internet Explorer安全区域的其他信息,请单击下面的文章编号,以查看Microsoft知识库中相应的文章:

    174360 How to Use Security Zones in Internet Explorer 174360如何在Internet Explorer中使用安全区域

  • The user requesting the Web page must have appropriate file system (NTFS) permissions to the Web page as well as all of the objects referenced in the Web page. 请求Web页面的用户必须具有对Web页面的适当文件系统(NTFS)权限以及Web页面中引用的所有对象。 For example, a user may have Full Control rights to a Web page, but is prompted for a password if the Web page refers to graphics that are in a secure folder. 例如,用户可能对网页具有完全控制权限,但如果网页引用安全文件夹中的图形,则会提示输入密码。

If you intentionally break any of the above condition, you can trigger the prompt. 如果您故意破坏上述任何一种情况,可以触发提示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在ASP.NET MVC中使用自定义登录页面进行Intranet Windows身份验证 - intranet windows authentication with with custom login page in ASP.NET MVC 为ASP.NET MVC Intranet应用程序实施Windows身份验证的最佳方法是什么? - What's the best way to implement Windows Authentication for an ASP.NET MVC intranet application? Windows身份验证Intranet和ASP.NET身份MVC网站之间的安全集成 - Security Integration between Windows Authentication Intranet and ASP.NET Identity MVC Website 在ASP.Net MVC应用程序中将身份验证从个人帐户更改为Windows(Intranet) - Changing Authentication from individual accounts to Windows (Intranet) in ASP.Net MVC app 如何使用基本身份验证来访问从Windows服务使用Windows身份验证的Asp.Net MVC 4 Intranet Web API方法? - How to use Basic Authentication to access Asp.Net MVC 4 Intranet Web API method which uses Windows Authentication from a Windows Service? ASP.MVC内部网和Internet身份验证 - ASP.MVC Intranet and Internet Authentication 测试使用Windows身份验证的Intranet站点 - Testing intranet site that uses Windows authentication ASP.NET MVC 4:身份验证和授权:Intranet应用程序 - ASP.NET MVC 4 : Authentication and Authorization:Intranet Application Intranet站点的ASP.NET身份+ Windows身份验证 - ASP.NET Identity + Windows Authentication for Intranet Site 浏览绑定到Active Directory的Intranet时,禁止自动(Windows)身份验证 - Prevents auto (windows) authentication when browing intranet bound to Active Directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM