简体   繁体   中英

How to use ASP.NET authentication with active directory?

I have my config setup like below:

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

I can attempt to log on but every time it says I am using the incorrect username/password. Does it look like I am doing anything wrong above? Is there any way for me to find more information on why it's not finding my username/pass?

UPDATE:

Do I need to provide a Username and Password in my membership/providers section?

Ok, I ended up using an LDAP browser to examine the structure. After a little fudging around I changed my LDAP url to this:

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

And it started working. Hope this helps someone!

Why make the user login in at all?

Try this provider

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

you can then do something to see if they are authorized Roles .

Roles.IsUserInRole("someGroupInAd")

Your web site would have to be setup with Integrated Windows Authentication in IIS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM