views:

91

answers:

2

I want to be able to prevent users from registering using specific usernames such as "Admin", "Administrator" etc. Does the MVC MembershipService have a way of doing this or will I have to implement my own method to check each time a user registers?

Thanks TheLorax

+1  A: 

If it's only a handful of names, register them yourself. That will prevent anyone else from registering them.

Robert Harvey
+1  A: 

Robert's answer is pretty expedient if inelegant. A more elegant way would be to put some logic into the AccountController's Register method to check names against a "blacklist" then add appropriate ModelErrors if the name is blacklisted. You could also fold in other logical checks--such as verifying the user name isn't a collection of symbols, isn't profane, etc.

One could make an argument that this should really be implemented in the MembershipProvider rather than a controller and one would be pretty spot on but that is beyond the scope of this answer.

Wyatt Barnett
You are right, all I was really asking was whether or not the MembershipProvder already had something to do it and I suppose it doesn't. However, your answer did give an easily implementable solution.Thanks
The_Lorax