+1-888-365-2779
Try Now
More in this section

Forums / Security / Use Custom Memberhip and RoleProvider type in sitefinity

Use Custom Memberhip and RoleProvider type in sitefinity

6 posts, 0 answered
  1. wajimam
    wajimam avatar
    3 posts
    Registered:
    05 Feb 2007
    24 Jan 2010
    Link to this post
    Hello,
    I had created 2 class ApplicationProvider extends TelerikMembershipProvider and RoleProvider extends TelerikRoleProvider for override the ApplicationName property and I set in web.config


      <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="Sitefinity">
          <providers>
            <clear />
            <add connectionStringName="DefaultConnection"
              name="Sitefinity" type="RoleProvider,TelerikProviders" />
          </providers>
        </roleManager>
        <membership defaultProvider="Sitefinity" userIsOnlineTimeWindow="15" hashAlgorithmType="">
          <providers>
            <clear />

            <add name="Sitefinity" connectionStringName="DefaultConnection" type="ApplicationProvider,TelerikProviders" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false"  requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" />
            
          </providers>
        </membership>


    but when I use only Membership provider class its work fine but when I use RoleProvider class it give me the error

    can you give me the suggestion I use my custom provider type .
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Jan 2010
    Link to this post
    Hi wajimam,

    Try overriding Initialize method of TelerikRoleProvider and call DataConnection.Initialize(false, this.GetType().Assembly);

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. wajimam
    wajimam avatar
    3 posts
    Registered:
    05 Feb 2007
    25 Jan 2010
    Link to this post
    Hello I use the code as you suggest me but still it give me the same error

    My code :

     public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            DataConnection.Initialize(false, this.GetType().Assembly);
            base.Initialize(name, config);
        }


  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2010
    Link to this post
    Hi wajimam,

    Try calling only base.Initialize() without any other code. If the problem persists you can send the log file so we could see whether there will be any useful information there.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. wajimam
    wajimam avatar
    3 posts
    Registered:
    05 Feb 2007
    26 Jan 2010
    Link to this post
    i had tried your suggestion but still same error as you suggest me that use only base.Initiallize() but there is no base.Initiallize() method for override
    I same sending you my code file please check it

    thanks
    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    using Nolics.ORMapper.Base; 
    using Telerik.DataAccess.AspnetProviders; 
     
    /// <summary> 
    /// Summary description for RoleProvider 
    /// </summary> 
    public class RoleProvider : TelerikRoleProvider 
        public override string ApplicationName 
        { 
            get 
            { 
                string appNameFromContext = 
                (string)HttpContext.Current.Items["ApplicationName"]; 
                if (appNameFromContext != "NOTSET"
                    return appNameFromContext; 
                else 
                    return base.ApplicationName; 
            } 
        } 
     
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) 
        { 
            DataConnection.Initialize(falsethis.GetType().Assembly); 
            base.Initialize(name, config); 
        } 

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Jan 2010
    Link to this post
    Hi wajimam,

    Try using this code in a custom dll

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using Nolics.ORMapper.Base;
    using Telerik.DataAccess.AspnetProviders;
     
    /// <summary>
    /// Summary description for RoleProvider
    /// </summary>
    ///
    namespace Telerik.Samples
    {
        public class RoleProvider : TelerikRoleProvider
        {
            public override string ApplicationName
            {
                get
                {
                    string appNameFromContext =
                    (string)HttpContext.Current.Items["applicationName"];
                    if (appNameFromContext != "/")
                        return appNameFromContext;
                    else
                        return base.ApplicationName;
                }
            }
     
            public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
            {
                DataConnection.Initialize(false, typeof(TelerikRoleProvider).Assembly);
                base.Initialize(name, config);
     
            }
     
        }
    }


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 0 answered