custom sqlmembership provider

Discussion in 'ASP .Net Security' started by Rafia Tapia, May 4, 2010.

  1. Rafia Tapia

    Rafia Tapia Guest

    Hi,
    I have added couple of fields in the membership table. I want to expose
    those additional fields through membership user. I understand that I need to
    provide my own implementation of membershipprovider and membershipuser
    class. Since the sqlmembership provider provides most of the functionality I
    need, I thought of using a sqlmembership provider internally within my
    custom provider to provide lot of the implementation. So my code is

    class MyMemberShipProvider : MembershipProvider
    {
    private SqlMembershipProvider _DefaultSqlProvider;

    // I then implement the abstract methods of MembershipProvider by simply
    calling sqlmembershipprovider function so for instance my implementation of
    change password is

    public override bool ChangePassword(string username, string oldPwd,
    string newPwd)
    {
    return SqlProvider.ChangePassword(username, oldPwd, newPwd);
    }

    //I have also implemented the initialize method as
    if (config == null)
    throw new ArgumentNullException("config");

    if (name == null || name.Length == 0)
    name = "MyMembershipProvider";

    if (String.IsNullOrEmpty(config["description"]))
    {
    config.Remove("description");
    config.Add("description", "Custom Membership provider");
    }

    // Initialize the abstract base class.
    base.Initialize(name, config);

    SqlProvider = new SqlMembershipProvider();
    SqlProvider.Initialize(name, config);

    }

    but now I get an error that the provider name cannot be null or empty. Can
    anyone please tell me what I am doing wrong. Also is my approach the correct
    way of exposing some couple of additional fields in the database membership
    table
    Rafia Tapia, May 4, 2010
    #1
    1. Advertising

  2. Hi Rafia Tapia,

    To configure the application to use the custom Membership Service, we need
    to add a section named membership under the system.web node to the
    web.config file. The Membership section can have multiple providers listed
    within the providers subsection, using the add element once for each
    provider.

    Here is a simple demo.

    <system.web>
    <membership>
    <providers>
    <add name="MembershipSqlProvider"
    type="System.Web.Security.SqlMembershipProvider"
    connectionStringName="AspNetMembershipDatabase" />
    </providers>
    </membership>
    </system.web>

    Please have a check with the setting in the web.config file of your
    application to see whether the error is caused by missing this part.

    For more information about how to build custom Providers, you can refer to
    this link: http://msdn.microsoft.com/en-us/library/aa479048.aspx

    If I have misunderstood you, please feel free to tell me.

    --
    Sincerely,
    Zhi-Qiang Ni
    Microsoft Online Support
    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    Zhi-Qiang Ni[MSFT], May 6, 2010
    #2
    1. Advertising

  3. Rafia Tapia

    Rafia Tapia Guest

    I have made all the appropriate changes in the config file. My question is
    more on the implementation rather than the configuration of custom provider

    "Zhi-Qiang Ni[MSFT]" <> wrote in message
    news:...
    > Hi Rafia Tapia,
    >
    > To configure the application to use the custom Membership Service, we need
    > to add a section named membership under the system.web node to the
    > web.config file. The Membership section can have multiple providers listed
    > within the providers subsection, using the add element once for each
    > provider.
    >
    > Here is a simple demo.
    >
    > <system.web>
    > <membership>
    > <providers>
    > <add name="MembershipSqlProvider"
    > type="System.Web.Security.SqlMembershipProvider"
    > connectionStringName="AspNetMembershipDatabase" />
    > </providers>
    > </membership>
    > </system.web>
    >
    > Please have a check with the setting in the web.config file of your
    > application to see whether the error is caused by missing this part.
    >
    > For more information about how to build custom Providers, you can refer to
    > this link: http://msdn.microsoft.com/en-us/library/aa479048.aspx
    >
    > If I have misunderstood you, please feel free to tell me.
    >
    > --
    > Sincerely,
    > Zhi-Qiang Ni
    > Microsoft Online Support
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
    >
    > MSDN Managed Newsgroup support offering is for non-urgent issues where an
    > initial response from the community or a Microsoft Support Engineer within
    > 2 business day is acceptable. Please note that each follow up response may
    > take approximately 2 business days as the support professional working
    > with
    > you may need further investigation to reach the most efficient resolution.
    > The offering is not appropriate for situations that require urgent,
    > real-time or phone-based interactions. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    > ==================================================
    >
    Rafia Tapia, May 7, 2010
    #3
  4. Hi Rafia Tapia,

    Sorry for the late reply.

    So based on my understanding, you need to add some own fields into the
    membership data table to extend the original feature.

    If so, I would like to strongly recommend this article talking about the
    way to extend Membership API to accommodate custom member records with a
    solution working upon it.

    Microsoft ASP.NET 2.0 Membership API Extended:
    http://www.devx.com/codemag/Article/34492/1954

    I believe this can help us make the goal.

    --
    Sincerely,
    Zhi-Qiang Ni
    Microsoft Online Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    MSDN Managed Newsgroup support offering is for non-urgent issues where an
    initial response from the community or a Microsoft Support Engineer within
    2 business day is acceptable. Please note that each follow up response may
    take approximately 2 business days as the support professional working with
    you may need further investigation to reach the most efficient resolution.
    The offering is not appropriate for situations that require urgent,
    real-time or phone-based interactions. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    Zhi-Qiang Ni[MSFT], May 12, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BS
    Replies:
    3
    Views:
    2,055
    Alvin Bruney [MVP]
    Jun 17, 2004
  2. sloan
    Replies:
    5
    Views:
    1,506
    sloan
    Jun 4, 2006
  3. sloan
    Replies:
    1
    Views:
    507
    Chad Scharf
    Jul 3, 2007
  4. Mike Endys

    SqlMembership Provider without dbo owner

    Mike Endys, Feb 4, 2009, in forum: ASP .Net
    Replies:
    6
    Views:
    945
    kallsbo
    Jun 22, 2009
  5. Rafia Tapia

    custom sqlmembership provider

    Rafia Tapia, May 4, 2010, in forum: ASP .Net
    Replies:
    0
    Views:
    660
    Rafia Tapia
    May 4, 2010
Loading...

Share This Page