Windows身份验证与NTLM问题

时间:2019-07-27 17:49:51

标签: c# iis windows-authentication

我想使用Windows身份验证制作IIS(8.5.9600)Web服务,该提供程序为NTLM。 我的问题是我无法使用Windows域凭据登录到网站,正如我期望的那样。尼瑟为我工作。 目前,由于无法登录查看具有Web服务的网站,我陷入了困境。

Windows版本:Microsoft Windows Server 6.2

我认为我的配置没错。

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

网站身份验证配置: https://ibb.co/FBZXqym

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

Webserivce应用程序认证配置: https://ibb.co/LvZdF45

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

Webservice应用程序角色配置: https://ibb.co/xHBvq9d

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

我的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>

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

3 个答案:

答案 0 :(得分:0)

您需要在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服务?)。因此,如果对此有更多问题,则必须提供有关您正在做的事情的更多信息。

答案 1 :(得分:0)

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

MVC.NET

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

有关更多详细信息,请关注以下文章:

Security Authorization

答案 2 :(得分:0)

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

谢谢大家的帮助!