Reputation: 5341
So I have a very basic flag (and thats all I need or want) That when a users logs in to identify if that user is an administrator.
Ive never use Role(Role manager) before, so want it really simple.
Im my config I have
<roleManager enabled="true" cacheRolesInCookie="true">
</roleManager>
on my login controller, (I want to do something very simple like)
var usertoken = new UserToken(user.Id, user.AccountId, user.UserName, user.IsAdmin);
if(user.IsAdmin)
Roles.AddUserToRole(usertoken.UserName,"Admin");
but I just get an error saying "Unable to connect to SQL Server database." Solution?
Upvotes: 1
Views: 199
Reputation: 4152
Have you created the asp.net Role Management tables
in your database?? Have you set your ConnectionString
against the Role Manager??
Please have a look at these links
http://msdn.microsoft.com/en-us/library/vstudio/ms164660(v=vs.100).aspx Asp.net User Roles Management: Where to Begin
Once you have set these, you can use Authorize
attribute or you could use User.Identity in everywhere
Upvotes: 1