Custom Roles

Posted by Community Admin on 03-Aug-2018 17:13

Custom Roles

All Replies

Posted by Community Admin on 21-Apr-2011 00:00

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.

Thanks,
KR

 

Posted by Community Admin on 22-Apr-2011 00:00

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 >
<clear/>
<add applicationName="/" name="CompanyNameWebsiteRole" type="CompanyName.Website.Security.CompanyNameRoleProvider, CompanyName.Website.Security" />
</providers >
</roleManager>

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

Posted by Community Admin on 26-Apr-2011 00:00

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

Posted by Community Admin on 23-Dec-2012 00:00

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?

Posted by Community Admin on 26-Dec-2012 00:00

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();

  Regards,
Ivan
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

This thread is closed