user957479
user957479

Reputation: 501

Adding roles dynamically to the asp.net role provider

I'm using the Asp.Net Role Provider that contains some roles. I would like to add some other roles that are coming from another database. Is there a way to do some kind of "union" between roles coming from the role provider and roles coming from my other database ?

To be more precise, I'm using forms authentication, I retrieve roles from my other database and store them in the FormsAuthenticationTicket. Then in AuthenticateRequest from Global.Asax, I generate the principal with the list of roles. But later when using User.IsInRole, it does not work for the list of roles I have assigned in AuthenticateRequest. What's the right direction to go ?

Christian

Upvotes: -1

Views: 237

Answers (1)

tezzo
tezzo

Reputation: 11115

You can create roles at runtime:

Dim strNewRole as String = "NEW"

If Not Roles.RoleExists(strNewRole) Then
    Roles.CreateRole(strNewRole)
End If

So you can still use your code to retrieve roles from another database and then use the code above for every role.

Upvotes: 1

Related Questions