Windows 身份验证与 NTLM 问题

Windows authentication with NTLM issue

我想制作一个带有 windows 身份验证的 IIS (8.5.9600) Web 服务,提供者是 NTLM。 我的问题是我无法像预期的那样使用我的 windows 域凭据登录网站。 Nither 对我有用。 这一刻我被卡住了,因为我无法登录以查看带有网络服务的网站。

Windows 版本:Microsoft Windows Server 6.2

我认为我的配置没有问题。

我尝试使用以下模式登录: DOMAIN\username 用户名

网站认证配置: https://ibb.co/FBZXqym

网站角色配置: https://ibb.co/qDY1PWb

Webserivce 应用程序身份验证配置: https://ibb.co/LvZdF45

Windows 身份验证提供商: https://ibb.co/FVcxXTm

网络服务应用程序角色配置: https://ibb.co/xHBvq9d

我还为 WebService 应用程序添加了 IIS 应用程序池用户的完全权限。

我的web.config:

<configuration>
<system.web>
  <compilation debug="true" targetFramework="4.7.2" />
  <httpRuntime targetFramework="4.7.2" />
  <authentication mode="Windows"/>
  <authorization>
    <allow users="*" />
  </authorization>
</system.web>
<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
  </compilers>
</system.codedom>
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-4.9.2.0" newVersion="4.9.2.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

我想登录到我的网络服务应用程序并查看标准 .asmx 页面。 目前我不能。

您的 web.config 中需要一个 system.webServer 部分来启用 Windows 身份验证,但同时禁用匿名身份验证:

<system.webServer>
   <security>
      <authentication>
         <anonymousAuthentication enabled="false" />
         <windowsAuthentication enabled="true" />
      </authentication>
   </security>
</system.webServer>

更多信息在这里:https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/

你提到了一个网站和一个web服务,但是你没有说这两者之间的关系是什么(用户登录网站,网站调用web服务?)。因此,如果您对此有更多问题,则必须提供有关您正在做的事情的更多信息。

您可以在应用程序 web.config 文件中使用以下代码来仅允许域用户并拒绝其他用户:

<system.webServer>
  ...
  <security>
    <authorization>
      <add accessType="Deny" users="?" />
      <add accessType="Allow" roles="YOUR_DOMAIN\Domain Users" />
    </authorization>
  </security>
  ...
</system.webServer>

您也可以允许多个域用户。

更多详细信息,您可以阅读以下文章:

Security Authorization

我所要做的就是重新启动整个 IIS 应用服务器。 之后它开始正常工作,这意味着我必须登录到应用程序。

谢谢大家的帮助!