如何创建角色和管理用户?
在我的项目中,我需要定义 3 个角色:
- SuperAdmin
- Admin
- RegisteredMembers
我还有一个名为“Users”的表,用于存储以下信息:
- fristName
- lastName
- 生日
- 用户名
- 密码 。 。 。 ?
当用户尝试登录网站时,如何使角色识别哪个用户对应哪个角色
in my Project i need to define 3 roles :
- SuperAdmin
- Admin
- RegisteredMembers
I also have Table which named "Users" that stores information such as:
- fristName
- lastName
- Birthday
- Username
- Password
.
.
.
and etc
How can i make Roles recognize which user is for which Role when users try to log on to website?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,创建
Users
表只是第一步。您还需要一个Role
表和一个UserRole
多对多关系表来存储哪个用户属于哪个角色(在一个简单的场景中)。这是整个概念的数据库部分。
然后,在代码方面...因为您提供的表格与 AspNetMembership 您还需要实现 自定义会员提供程序、自定义角色提供程序< /a> 并且可能是自定义会员用户。
First of all you creating a
Users
table is just the first step. You also need aRole
table and aUserRole
many-to-many relationship table to store which user belongs to which role(In a simple scenario).That's for the database part of the whole concept.
Then, on the code side...since you're providing different tables than the ones in the AspNetMembership you need to also implement a custom membership provider, custom role provider and presumably a custom membership user.