具有本地化功能的 ASP.NET MVC2 身份验证表单
我有两级身份验证,首先用户输入他们的 nt/密码,并通过 LDAP 进行验证,然后我有一个自定义角色提供程序来确保用户有权访问所述页面。
话虽如此,在我的 web.config 中,我有:
<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>
现在,如果我尝试在登录表单中使用语言按钮,它会调用一个不可用的操作,因为用户仍未经过 LDAP 身份验证。我的问题是:
我可以像使用 [Authorize] 属性进行角色检查一样避免对特定操作进行成员资格检查吗?
我尝试使用:
<location path="~/Home.mvc/ChangeCulture">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
但这不起作用。 ChangeCulture 操作永远不会被调用。
这个答案:
ASP.NET MVC Forms 身份验证和未经身份验证的控制器操作< /a>
显示了如何为角色执行此操作,对会员+角色有什么想法吗?
谢谢。
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>
<allow 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论