HighTechTalks DotNet Forums  

custom sqlmembership provider

ASP.net Security microsoft.public.dotnet.framework.aspnet.security


Discuss custom sqlmembership provider in the ASP.net Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rafia Tapia
 
Posts: n/a

Default custom sqlmembership provider - 05-04-2010 , 12:18 PM






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

Reply With Quote
  #2  
Old   
Zhi-Qiang Ni[MSFT]
 
Posts: n/a

Default RE: custom sqlmembership provider - 05-06-2010 , 02:52 AM






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

Reply With Quote
  #3  
Old   
Rafia Tapia
 
Posts: n/a

Default Re: custom sqlmembership provider - 05-06-2010 , 10:20 PM



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]" <v-zhiqni (AT) online (DOT) microsoft.com> wrote

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

Reply With Quote
  #4  
Old   
Zhi-Qiang Ni[MSFT]
 
Posts: n/a

Default Re: custom sqlmembership provider - 05-12-2010 , 02:07 AM



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

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.