custom sqlmembership provider

R

Rafia Tapia

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
 
Z

Zhi-Qiang Ni[MSFT]

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
==================================================
 
R

Rafia Tapia

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
 
Z

Zhi-Qiang Ni[MSFT]

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
==================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,446
Members
47,097
Latest member
MarionMajo

Latest Threads

Top