使用 ASP.NET 内置控件进行角色管理
我正在使用 ASP.NET 内置登录和角色管理解决方案(创建像 aspnet_Users 等表,并提供对 MembershipUser 等的访问权限)。
然而,在这个阶段,我有点陷入以下困境:
1)我需要能够从我的应用程序中暂停、取消暂停和删除(不必从表中删除,只需禁用)用户。这个功能是内置的吗?
2)我需要拥有三种不同的用户角色,默认情况下始终分配其中一种角色。目前我已经构建了一个没有角色的应用程序。 ASP.NET 能够做到这一点吗?
I am using the ASP.NET inbuilt login and role management solution (creates table like aspnet_Users etc. and gives access to MembershipUser and the such).
However, at this stage I am a bit stuck with the following:
1) I need to be able to Suspend, Unsuspend and Delete (not necessary remove from table, just disable) users from my app. Is this feature inbuilt?
2) I need to have three different user roles, where one of the roles is always assigned by default. Currently I have built an app with no roles. Is ASP.NET capable of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ASP.NET 会员资格对用户有“已批准”和“锁定”(在 X 次登录尝试失败后)的概念,您可以使用这些功能来暂停用户。 4guysfromrolla.com 在 检查 ASP.NET 的成员、角色和配置文件,值得一看。
ASP.NET Membership has concepts for "Approved" and "Locked out" (after X number of failed log in attempts) for users, you can probably use those features for suspending users. 4guysfromrolla.com had a great article series on Examining ASP.NET's Membership, Roles, and Profile , it's worth a look.
DeleteUser
方法。它调用一个存储过程
名为
dbo.aspnet_Users_DeleteUser
。您可以更改该存储过程
暂停用户而不是
删除它们。
DeleteUser
method. It calls a stored procedure
named
dbo.aspnet_Users_DeleteUser
.You can change that stored procedure
to suspend a user instead of
deleting them.
CreateUser
method which calls a stored procedure nameddbo.aspnet_Membership_CreateUser
which you could modify. Or, you could use theRoles.AddUserToRole
method to set the default role when the user is created, calling it in yourCreateUser
method (which would first Membership.CreateUser)