开发者

ASP.NET MVC2 Authentication form with localization

I have two level authentification, first the user enters their nt/password and it is validated by LDAP and afterward I have a custom role provider that make sure the user has access to said page.

That being said, in my web.config I have:

<authentication mode="Forms">
  <forms loginUrl="~/Account.mvc/LogOn" timeout="2880"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>
<membership defaultProvider="ADMembershipProvider">
  <providers>
    <add connectionStringName="ADConnString"
         name="ADMembershipProvider"
         type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
         attributeMapUsername="sAMAccountName"
         enableSearchMethods="false"
         applicationName="ProgramName"/>
  </providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomRoleProvider">
  <providers>
    <clear />
    <add name="CustomRoleProvider"
         applicationName="ProgramName"
         type="ProgramName.Providers.CustomRoleProvider"
         attributeMapUsername="sAMAccountName"
         />
  </providers>
</roleManager>

Now, If I try to use the language button while in the login form, it calls an action that is unavailable since the user still isn't LDAP-Authenticated. My question is:

Can I avoid the membership check for specific action like I can for role check using the [Authorize] Attribute?

I tried using:

  <location path="~/Home.mvc/ChangeCulture">
    <system.web>
      <authorization>
        <allo开发者_运维知识库w users="*"/>
      </authorization>
    </system.web>
  </location>

And this doesn't work. The action ChangeCulture is never called.

This answer:

ASP.NET MVC Forms authentication and unauthenticated controller actions

shows how to do it for roles, any idea for membership+roles?

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜