代码之家  ›  专栏  ›  技术社区  ›  Abe Miessler

如何在Active Directory中使用ASP.NET身份验证?

  •  1
  • Abe Miessler  · 技术社区  · 14 年前

    我的配置设置如下:

    <configuration>
      <connectionStrings>
        <add name="ADConnectionString" connectionString="LDAP://myldap/CN=Users,DC=nevco,DC=local"/>
      </connectionStrings>
    <system.web>
    <authentication mode="Forms">
      <forms name=".ADAuthCookie" timeout="10" loginUrl="Login.aspx" defaultUrl="Default.aspx" />
    </authentication>
        <membership defaultProvider="DomainLoginMembershipProvider">
          <providers>
            <clear/>
            <add name="DomainLoginMembershipProvider"
                 type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                 connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
          </providers>
         </membership>
      </system.web>
    </configuration>
    

    我可以尝试登录,但每次它说我使用的用户名/密码不正确时。上面我好像做错什么了吗?我有没有办法找到更多关于为什么找不到我的用户名/通行证的信息?

    更新:

    我是否需要在我的会员/提供商部分提供用户名和密码?

    2 回复  |  直到 14 年前
        1
  •  1
  •   Abe Miessler    14 年前

    好吧,我最终使用LDAP浏览器来检查结构。在稍微敷衍了一下之后,我将LDAP URL改为:

    LDAP://myldap/DC=nevco,DC=local
    

    它开始工作了。希望这能帮助别人!

        2
  •  0
  •   Lareau    14 年前

    为什么要让用户登录?

    尝试此提供商

    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />
    

    然后你可以做些事情看看他们是否被授权 Roles .

    Roles.IsUserInRole("someGroupInAd")
    

    您的网站必须与 Integrated Windows Authentication 在IIS中