1

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?

D-W
  • 5,201
  • 14
  • 47
  • 74

1 Answers1

1

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

Community
  • 1
  • 1
Has AlTaiar
  • 4,052
  • 2
  • 36
  • 37