简体   繁体   English

使用EmployeeID的asp.net成员身份登录

[英]asp.net membership login using EmployeeID

I am trying to use ASP.NET membership in an ASP.NET project. 我正在尝试在ASP.NET项目中使用ASP.NET成员身份。 The only requirement I have is that users will need to login using an EmployeeID as the username instead of the Email. 我唯一的要求是用户将需要使用EmployeeID作为用户名而不是Email登录。 Is this something easily configurable using the default membership provider? 使用默认的成员资格提供程序是否可以轻松配置这些内容?

I see a MobilePin column inside the aspnet_Membership table and I am wondering if there is a way to use that as the username instead. 我在aspnet_Membership表内看到一个MobilePin列,我想知道是否可以使用它作为用户名。

Thanks 谢谢

You can roll your own membership provider and check the DB with the provided values. 您可以滚动自己的成员资格提供程序,并使用提供的值检查数据库。 Since you likely already have a LogonModel that uses the UserName attribute you can change that to EmployeeId instead. 由于您可能已经具有使用UserName属性的LogonModel,因此可以将其更改为EmployeeId。 You may also have to re-generate the Logon view with the altered property. 您可能还必须使用altered属性重新生成“登录”视图。

So instead of a view with 因此,与

        @Html.TextBoxFor(m => m.UserName)

It will be something like 它会像

        @Html.TextBoxFor(m => m.EmployeeId)

Whatever you renamed your Logon model class to have. 无论将您的Logon模型类重命名为什么。

Then you will need to have your own MembershipProvider and override the ValidateUser method so that it validates against the DB. 然后,你需要有自己的MembershipProvider和重写的ValidateUser方法让她能够验证对DB。 Then in your controller method for the HttpPost action use your membership provider implementation. 然后,在用于HttpPost操作的控制器方法中,使用您的成员资格提供程序实现。

That is unless you are hoping to authenticate against the Domain, in which case see the following link 除非您希望针对域进行身份验证,否则请参见以下链接

http://msdn.microsoft.com/en-us/library/ff650308.aspx http://msdn.microsoft.com/en-us/library/ff650308.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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