Custom Roles - General Discussions - General Discussions - Progress Community
 General Discussions

Custom Roles

  • Custom Roles
  • Hi,

    I’m developing a public facing site using Sitefinity, with 2 kinds of users.

    1. CMS Users - allowed to Edit content etc.
    2. Public Users - non-CMS user

    Public users, who are members of the website, gets access to certain pages with appropriate roles. These roles are in an existing Database name 'CustomerDatabase' . Ofcourse the public users are currently in 'CustomerDatabase'  too (existing database).
    I know the part to write a Custom Mebership  extending System.Web.Security.MembershipProvider  class    for authentication. But how do I retrieve the Roles that reside in the 'CustomerDatabase' and put them as Page properties to provide access to the Public user who are a member of the website.

    If I write  a custom RoleProvider extending System.Web.Security.RoleProvider  class and once I configure it in web.config,  will the roles be displayed in the backend of sitefinity? Will the roles in 'CustomerDatabase' be displaed in Page Properties to set permissions?



    If someone could give me a nudge in the right direction, I would appreciate it. Also an example/video/links would be helpful.



  • Since I have my users and roles in a different existing database , I tried to extend my custom RoleProvider, something like...

    public class CompanyNameRoleProvider : System.Web.Security.RoleProvider

    and implemented
    GetAllRoles() method.
    I added an entry in the web.config as below...

    <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="CompanyNameWebsiteRole" >
    <providers >
    <add applicationName="/" name="CompanyNameWebsiteRole" type="CompanyName.Website.Security.CompanyNameRoleProvider, CompanyName.Website.Security" />
    </providers >

    This resulted in the error below. I could not extend the RoleDataProvider and the GetUserLinks() return a type Telerik.Sitefinity.Security.Model.UserLink and in my case I am using my own database with existing users and roles.

    Also I cannot user SitefinityRoleProvider as its an XML storage.

    Please can somebody shed some light here. I am not sure if I am going in the right direction with the requirement I have.


    The method or operation is not implemented.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NotImplementedException: The method or operation is not implemented.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:

    [NotImplementedException: The method or operation is not implemented.]
       Telerik.Sitefinity.Security.RoleProviderWrapper.GetUserLinks() +36
       Telerik.Sitefinity.Security.Data.RoleDataProvider.GetRolesForUser(Guid userId) +72
       Telerik.Sitefinity.Security.SitefinityPrincipal.Initialize() +1035
       Telerik.Sitefinity.Configuration.RolePolicyHandler.GetPolicyNames(ConfigProvider configProvider, ConfigSection section) +59
       Telerik.Sitefinity.Configuration.ConfigElement.GetValueFromPolicy(ConfigPolicyHandler handler, ConfigProperty prop, Object& value) +159
       Telerik.Sitefinity.Configuration.ConfigElement.GetPolicyValue(ConfigProperty prop, Object& value) +102
       Telerik.Sitefinity.Configuration.ConfigElement.get_Item(ConfigProperty prop, ConfigPolicyHandler policyHandler, String policyName) +42
       Telerik.Sitefinity.Configuration.ConfigElement.get_Item(String propertyName) +56
       Telerik.Sitefinity.Security.Configuration.SecurityConfig.get_ApplicationRoles() +28
       Telerik.Sitefinity.Security.SitefinityPrincipal.get_IsBackendUser() +86
       Telerik.Sitefinity.Security.SecurityManager.AuthenticateRequest(HttpContextBase context) +940
       Telerik.Sitefinity.Web.SitefinityHttpModule.Context_AuthenticateRequest(Object sender, EventArgs e) +104
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266

  • Hello KR,

    The GetUserLinks() method of RoleProviderWrapper was throwing an exception prior to version 4.1 of Sitefinity. In 4.1 this method is already implemented. I suppose you are not using the right assemblies. Please check their versions.

    All the best,
    Lubomir Velkov
    the Telerik team

  • I am struggling with a similar problem of accessing roles from a custom database.  Can someone post some samples on how to implement GetuserLinks() when accessing a custom data source?
  • Hi Tony,

    Here is a discussion about custom membership and role provider. 
    You can see that the implementation of GetUserLinks() is as follows:

    public override IQueryable<Telerik.Sitefinity.Security.Model.UserLink> GetUserLinks()
    return (new List<Telerik.Sitefinity.Security.Model.UserLink>()).AsQueryable();

    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items