Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Multiple virtual roles


Does anyone know if it possible to do a VirtualRoleProvider (or the likes) which creates more than a single virtual role? Say, I wanted to create a number of roles based on a table in SQL server?

I believe it must be a pretty common scenario.

May 16, 2011 12:58

I think you need to create one for each role, but you could make your own RoleProvider and add roles there

May 16, 2011 13:51

Thank you for the answer.

You're right - It is possible to extend the membership- and role provider to obtain the same functionaliy. But I'm just puzzled by the fact that this is not possible with the VirtualRoleProvider, it being based on the Provider model!?! Anyways, shouln't it at least be possible to plug in at the same place?

May 16, 2011 15:14

The Virtual Role only gets its name through configuration. Each configuration element can only support one role name, but you can certainly add the same type reference multiple times with different names. If in your role you implement the Initialize method you'll get the name-value pairs of the config so you can find out what role name has been configured for the instance. Or add your own extra configuration (decompile the EPiServer.Security.UserMappedRole for inspiration).

Edited, May 16, 2011 16:05
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.