0

我收到了这个奇怪的错误信息:

无法与服务器建立安全连接

当我尝试使用我的 AD 帐户登录时。我尝试在 ASP.NET 网络表单中连接到 LDAP,它似乎在那里工作正常,我不认为它是导致问题的连接字符串。

但是当我使用 MVC 时,会出现解析器错误。我也试图环顾四周并用谷歌搜索,但我似乎找不到正确的解决方案。根据配置错误,它说源错误是:

<add name="AspNetActiveDirectoryMembershipProvider" 
     type="System.Web.Security.ActiveDirectoryMembershipProvider" 
     connectionStringName="ADConnectionString" 
     connectionUsername="cn=actualUser" 
     connectionPassword="actualUsersPassword" />`

这是我的web.config

<connectionStrings>
    <add name="ADConnectionString" connectionString="LDAP://IPadress/DC=example,DC=test"/>
</connectionStrings>
<system.web>
    <authentication mode="Forms">
      <forms name=".ADAuthCookie" loginUrl="~/Account/LogOn" timeout="15" 
             slidingExpiration="false" protection="All" />
    </authentication>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
      <providers>
        <clear/>
        <add name="AspNetActiveDirectoryMembershipProvider" 
             type="System.Web.Security.ActiveDirectoryMembershipProvider" 
             connectionStringName="ADConnectionString" 
             connectionUsername="cn=actualUser" connectionPassword="actualUsersPassword" />
      </providers>
    </membership>
    <trust level="Full" />
    <pages>
       <namespaces>
          <add namespace="System.Web.Mvc" />
          <add namespace="System.Web.Mvc.Ajax" />
          <add namespace="System.Web.Mvc.Html" />
          <add namespace="System.Web.Routing" />
       </namespaces>
    </pages>
</system.web>

这是我的课程,我从“ if (Membership.ValidateUser(model.UserName, model.Password)) {” 收到错误消息,它指向 web.config 中的成员资格提供程序:

    [HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
   if (ModelState.IsValid)
    {
        if (Membership.ValidateUser(model.UserName, model.Password))
        {
            FormsAuthentication.SetAuthCookie(model.UserName,Convert.ToBoolean(model.Password));
            if ((!String.IsNullOrEmpty(returnUrl)))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
        else
        {
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
        }
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}
4

1 回答 1

0

您是否尝试将 Windows 身份验证模式设置为 Windows ?

<authentication mode="Windows" />
于 2012-04-30T17:15:45.380 回答