简体   繁体   中英

ASP.NET 4.5 C# Active Directory Access Denied

I used this for try login with LDAP in ASP.NET C# 4.5 If i try use this, i cant access nothing (For deny users=?)

<authentication mode="Forms">
  <forms name=".ASPXAUTH" loginUrl="Login.aspx" defaultUrl="Default.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile" domain="" />
</authentication>
<authorization>
  <deny users="?"/>
  <allow users="*" />
</authorization>
<membership defaultProvider="ADConnection">
  <providers>
    <add name="ADConnection" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          connectionProtection="Secure" connectionStringName="ADConnection" connectionUsername="cpdprt01" connectionPassword="prt2016" attributeMapUsername="sAMAccountName"
          enableSearchMethods="false"/>
  </providers>
</membership>

Any solution to try block navigate for others pages without autentication? (I can login with this data but i can't block not autentication connection)

I still don't understand what the problem is, but I'll explain how it is supposed to work, and maybe that will help.

? means anonymous users.

* means everyone.

So <deny users="?"/> means it will disallow access to anonymous (unauthenticated) users.

However, that does not apply to the page that you specify as the loginUrl in the <forms> tag. Any unauthenticated user can access that page, so they can login.

If it is not redirecting to your Login page, then try adding applicationName to your provider:

<add name="ADConnection" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
      connectionProtection="Secure" connectionStringName="ADConnection" connectionUsername="cpdprt01" connectionPassword="prt2016" attributeMapUsername="sAMAccountName"
      enableSearchMethods="false" applicationName="Something" />

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