0

I'm working with the MVC .NET and I used the WebSecurity layer in order to manage logins and roles.

What happens if I have several users with the same "username" in my db and I call the following funciton?

Roles.GetRolesForUser(username)

Is it possible to say to my dbo.User table that I want that the pair "username+column2" must be unique? If yes, how can I retrieve the roles for that pair?

Matteo Gariglio
  • 482
  • 5
  • 12
  • 3
    Why would you allow several users with the same username? – krillgar Jul 28 '14 at 16:17
  • The application is quite complex, and the username has not to be unique.. I understand your question, but the idea is that the same person can have two profiles and so different roles depending on the profile in use. – Matteo Gariglio Jul 28 '14 at 16:39
  • If profiles can have same username, how are differentiating between profiles? – mxmissile Jul 28 '14 at 16:42
  • You have a difficult decision on your hands then. If you can't refactor your system to require unique usernames, then you'll have to be in charge of all of the Roles on your own in the database. That's not that big of a stretch. It'll wind up being just another entity in your data layer to keep track of. – krillgar Jul 28 '14 at 16:47
  • I thought to create another column (a sort of combination between two) and use it as "username" but I do not think it's very clean. Otherwise, why does .NET use the Username and not directly the column IdUser? – Matteo Gariglio Jul 28 '14 at 16:51

0 Answers0