2016-05-03 122 views
0

我用這對嘗試登錄,在ASP.NET C#4.5 LDAP如果我試圖用這個,我不能什麼都不訪問(對於拒絕用戶=?)ASP.NET 4.5 C#的Active Directory拒絕訪問

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

任何解決方案嘗試阻止導航其他頁面沒有驗證?我可以登錄這個數據,但我不能阻止沒有驗證連接)

+0

我不太明白。你的意思是未認證的用戶仍然可以訪問該網站嗎? –

+0

完全困惑,請儘量簡單 –

+0

@GabrielLuci對不起,我的英語。 我試圖解釋... 如果我使用這個配置,沒有人可以訪問我的網站,但是如果我刪除該行所有用戶都可以訪問我的網站。 登錄控件正常工作。我的問題是授權 –

回答

0

我仍然不明白問題是什麼,但我會解釋它應該如何工作,也許這將有助於。

?表示匿名用戶。

*意味着所有人。

因此<deny users="?"/>表示它將禁止訪問匿名(未經身份驗證的)用戶。

但是,這不適用於您在<forms>標記中指定爲loginUrl的頁面。任何未經身份驗證的用戶都可以訪問該頁面,以便他們可以登錄。

如果不是重定向到登錄頁面,然後嘗試添加applicationName您提供:

<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" /> 
+0

如果我嘗試使用它,結果是這樣的:http://puu.sh/oEKUG/d180f9e4c1.png 我無法訪問login.aspx –

+0

所以它不重定向到Login.aspx什麼時候應該?嘗試添加'applicationName'屬性給你的提供者(我更新了我的答案)。 –

+0

如果我使用IISExpress for VisualStudio,可以看到我的登錄控制http://puu.sh/oEMAk/c5815984b8.png,但是我可以在沒有身份驗證的情況下輸入其他頁面。 如果我使用我的IIS這個配置:http://puu.sh/oEMyV/b9ec5db66f.png我不能輸入任何東西 我更改applicationName =「Expedientes」 –