Custom Authentication, Role and Profile Providers Example
Greetings,
Hi Daniel,
Thank you for using our services.
You can take a look at the following webinar which explains how to create custom membership and role providers. The CMS uses ASP.NET Membership and Role providers and may also find these tutorials useful:
Implementing a Membership Provider
Implementing a Role Provider
When you develop the custom providers and add them to your websites you should set the Login control's ProviderName property to be the one of your custom provider.
Best wishes,
Radoslav Georgiev
the Telerik team
Hello Radoslav,
Hi Daniel,
1. Make sure that your provider is correctly registered.
2. Application has been restarted.
3. You have implemented
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Telerik.Sitefinity.Security.Data;
namespace
TestProvider
public
class
Class3 : RoleDataProvider
public
override
Telerik.Sitefinity.Security.Model.Role CreateRole(
string
roleName)
throw
new
NotImplementedException();
public
override
Telerik.Sitefinity.Security.Model.Role CreateRole(Guid id,
string
roleName)
throw
new
NotImplementedException();
public
override
Telerik.Sitefinity.Security.Model.Role GetRole(Guid id)
throw
new
NotImplementedException();
public
override
IQueryable<Telerik.Sitefinity.Security.Model.Role> GetRoles()
return
(
new
List<Telerik.Sitefinity.Security.Model.Role>()).AsQueryable();
public
override
void
Delete(Telerik.Sitefinity.Security.Model.Role item)
throw
new
NotImplementedException();
public
override
Telerik.Sitefinity.Security.Model.UserLink CreateUserLink()
throw
new
NotImplementedException();
public
override
Telerik.Sitefinity.Security.Model.UserLink CreateUserLink(Guid id)
throw
new
NotImplementedException();
public
override
Telerik.Sitefinity.Security.Model.UserLink GetUserLink(Guid id)
throw
new
NotImplementedException();
public
override
IQueryable<Telerik.Sitefinity.Security.Model.UserLink> GetUserLinks()
return
(
new
List<Telerik.Sitefinity.Security.Model.UserLink>()).AsQueryable();
public
override
void
Delete(Telerik.Sitefinity.Security.Model.UserLink item)
throw
new
NotImplementedException();
Hello Ivan,
Hello Daniel,
Ok let me know if there are any further issues.
Kind regards,
Ivan Dimitrov
the Telerik team
Greetings,
Hello Daniel,
This is a bug.
When you try to delete a role and click "delete" button we call RoleManager class and its GetRole method that gets the role with the specified identity. When you are on "All Roles" tab we use the OpenAccessRoleProvider and clicking "delete" does not do anything, because you pass a role that does not exist in the OpenAccessRoleProvider. The role is removed from your custom provider when you are on the custom role tab, because the provider in this case is correct.
Sincerely yours,
Ivan Dimitrov
the Telerik team
Hello Ivan,
but when I'm implementing the custom membership provider should I implement
public override IQueryable<
Telerik.Sitefinity.Security.Model.Role
> GetRoles()
return (new List<
Telerik.Sitefinity.Security.Model.Role
>()).AsQueryable();
Hello Paolo,
You should return IQueryable of Role objects. I sent a reply to you in the other thread you ask similar question.
www.sitefinity.com/.../simple-example-with-custom-membership-provider.aspx
Best wishes,
Ivan Dimitrov
the Telerik team
Hey Ivan,
I am working on trying to get a Custom Role Provider to work as well and I am confused by the different information floating around the Telerik support site. I have created my Custom Role Provider by extending the base ASP.NET Standard Role Provider, but should I be using the Telerik Role Data Provider class instead as the example shows? Is this example an old one because the Role Provider Wrapper class was not written at the time that this was originally posted? As it is my understanding, the wrapper classes should now provide proper use of a Custom Role Provider based on the ASP.NET one?
Thanks,
Leng
Hi ,
Membership and Role wrapper are now implemented, so if you have a provider based on the ASP.NET SqlMembership provider you should be able to use it with Sitefinity.Check this blog post for samples and more information.
Regards,
Ivan Dimitrov
the Telerik team
Hey Ivan,
Thanks for providing that information.
Leng
It was possible to use a custom role provider on Sitefinity 3.x that was inheriting from System.Web.Security.RoleProvider. The provider was available when added to web.config in
<
roleManager
defaultProvider
=
"CP"
enabled
=
"true"
>
<
providers
>
<
clear
/>
<
add
name
=
"CP"
connectionStringName
=
""
applicationName
=
"/"
type
=
"CP.Providers.CustomRoleProvider, CP.Providers"
/>
</
providers
>
</
roleManager
>
*
Is there any way where we can add Profile providers in web.config?
Hello Aakash,
The Profile providers could be added under:
Administration > Settings > Advanced > UserProfiles > Create new
Regards,
Svetoslav Manchev
Telerik