473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Membership Provider

Hello everyone,

I am wondering, can the membership provider be changed at runtime?
Perhaps the connectionStrin gName?

I would like to use a different database based on the server the site
is on.

I suppose that a custom provider could be used to accomplish this, is
there another way?

It would be great to do the following:
Select Case strEnvironment
Case "PRD"

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for production"
Case Else

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for development"
End Select

Thanks for your input,
Ryan

Aug 21 '06 #1
3 3281
Hi Ryan,

Put your default and alternate membership providers (and their connection
strings) in the web.config file, like this:

<membership defaultProvider ="Mydefaultprov ider">
<providers >
<clear/>
<add connectionStrin gName="ASPNETDB ConnectionStrin g1"
name="MyAlterna teprovider"
type="System.We b.Security.SqlM embershipProvid er"/>

<add connectionStrin gName="ASPNETDB ConnectionStrin g2"
name="Mydefault provider" type="System.We b.Security.SqlM embershipProvid er"/>

</providers>
</membership>

Then in your code, reference the one you want to use:

Dim mbr As MembershipProvi der
mbr = Membership.Prov iders.Item("MyA lternateprovide r")
' mbr.CreateUser( ....
Response.Write( mbr.GetType)

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<ry*********@gm ail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hello everyone,

I am wondering, can the membership provider be changed at runtime?
Perhaps the connectionStrin gName?

I would like to use a different database based on the server the site
is on.

I suppose that a custom provider could be used to accomplish this, is
there another way?

It would be great to do the following:
Select Case strEnvironment
Case "PRD"

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for production"
Case Else

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for development"
End Select

Thanks for your input,
Ryan

Aug 22 '06 #2
Thanks for responding so quickly Ken. That did help greatly.

Have a great day,
Ryan
Ken Cox [Microsoft MVP] wrote:
Hi Ryan,

Put your default and alternate membership providers (and their connection
strings) in the web.config file, like this:

<membership defaultProvider ="Mydefaultprov ider">
<providers >
<clear/>
<add connectionStrin gName="ASPNETDB ConnectionStrin g1"
name="MyAlterna teprovider"
type="System.We b.Security.SqlM embershipProvid er"/>

<add connectionStrin gName="ASPNETDB ConnectionStrin g2"
name="Mydefault provider" type="System.We b.Security.SqlM embershipProvid er"/>

</providers>
</membership>

Then in your code, reference the one you want to use:

Dim mbr As MembershipProvi der
mbr = Membership.Prov iders.Item("MyA lternateprovide r")
' mbr.CreateUser( ....
Response.Write( mbr.GetType)

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<ry*********@gm ail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hello everyone,

I am wondering, can the membership provider be changed at runtime?
Perhaps the connectionStrin gName?

I would like to use a different database based on the server the site
is on.

I suppose that a custom provider could be used to accomplish this, is
there another way?

It would be great to do the following:
Select Case strEnvironment
Case "PRD"

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for production"
Case Else

ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for development"
End Select

Thanks for your input,
Ryan
Aug 24 '06 #3

Hello,

this is a great solution. I was looking around quite a while for something
like this.
But I have one big problem:

All the membership methods now need all parameters :-(
The Default Membership-Provider accepts a variety of overloaded methods.

example:

' this is the normal way with the defaultprovider - and it works fine:
newUser = Membership.Crea teUser(UserName , Password)

Now with a dynamic provider,you must provide all Parameters:

Dim mbr As MembershipProvi der = Membership.Prov iders.Item("Tes tProvider")

mbr.CreateUser( UserName, Password, "","","",Tr ue, ProviderUserKey , Status)

Is there any solution for this Problem ?

Thanks in advance !

Kind Regards,
Michael

"ry*********@gm ail.com" wrote:
Thanks for responding so quickly Ken. That did help greatly.

Have a great day,
Ryan
Ken Cox [Microsoft MVP] wrote:
Hi Ryan,

Put your default and alternate membership providers (and their connection
strings) in the web.config file, like this:

<membership defaultProvider ="Mydefaultprov ider">
<providers >
<clear/>
<add connectionStrin gName="ASPNETDB ConnectionStrin g1"
name="MyAlterna teprovider"
type="System.We b.Security.SqlM embershipProvid er"/>

<add connectionStrin gName="ASPNETDB ConnectionStrin g2"
name="Mydefault provider" type="System.We b.Security.SqlM embershipProvid er"/>

</providers>
</membership>

Then in your code, reference the one you want to use:

Dim mbr As MembershipProvi der
mbr = Membership.Prov iders.Item("MyA lternateprovide r")
' mbr.CreateUser( ....
Response.Write( mbr.GetType)

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<ry*********@gm ail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hello everyone,
>
I am wondering, can the membership provider be changed at runtime?
Perhaps the connectionStrin gName?
>
I would like to use a different database based on the server the site
is on.
>
I suppose that a custom provider could be used to accomplish this, is
there another way?
>
It would be great to do the following:
Select Case strEnvironment
Case "PRD"
>
ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for production"
Case Else
>
ConfigurationMa nager.Connectio nStrings("SQLCo nnectionString" ).ConnectionStr ing
= "super-secret connection string for development"
End Select
>
Thanks for your input,
Ryan
>

Aug 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2447
by: Morgan | last post by:
Sorry for cross post, forgot to include aspnet in orinal... Thanks in advance for any assistance. I'm in the process of implementing custom RoleProvider & Membership Provider objects and have run into a snag with the Membership Provider. It seems many of the MembershipUser properties are read-only. This seems, well stupid, IMO.
2
3560
by: John | last post by:
Hi I was working fine with create user wizard and the default membership provider. I have now customised the membership provider as per attached web.config. The create user wizard picks up the custom membership provider fine and removes the security question/answer fields as designated in the custom provider. The problem is that when I try to create a new user in the create user wizard by entering the info and pressing the 'create...
3
7134
by: ad | last post by:
I have create a custom membership provider. The common usage of custom membership is set it as default Membership Provider win web.config, and use login controls with it. How can I use custom membership provider without Login Controls? For example, the name of my custom membership provider MyMembershipProvider. Is the codes below right? MyMembershipProvider myProvider=new MyMembershipProvider();
9
2175
by: Paul Keegstra | last post by:
Hi, I am currently working on an asp.net 2.0 web site that is a replacement of a classic asp web site. The current web site uses a Commerce Server 2002 database for storing user information. It does not currently use any of the Commerce Server 2002 functionality with the exception of the user authentication features. I have written my replacement application to use a custom login form and custom connection string so that I can use...
2
14156
by: Balaji | last post by:
Hi All, Can I use more than one membership provider for a given website? I understand only one of them could be default one. If yes, then how to programmatically access the other membership provider? For e.g. lets say I have a SQLMembership provider and OracleMembership provider. SQL would be my default provider. During authentication, based on the value of an additional parameter in the login screen, I need to validate against SQL or...
4
7236
by: thomas | last post by:
Hello All, How to change the default Membership Provider during the runtime? I know I can reference any provider I want, e.g.: provider = Membership.Providers but the question is how to change the default one, so all those new, cool controls can start using the one I want. I can specify the provider for each of those controls, e.g.:
4
4733
by: =?Utf-8?B?Q2hyaXMgQ2Fw?= | last post by:
I have been having some trouble with implementing a custom Membership Provider. We have a custom data store and business logic that pulls user information. I need some level of functionality above and beyond what the prodiver currently allows. I need the ability to access a user id and the user's permission id. With Forms authentication in 1.1, I would just create a custom identiy and principal and store the information in the identity....
1
14316
by: Ben | last post by:
Hi, When an anonymous user has created an new account (with the CreateUserWizard control), i want to let asp.net generate a password and to send it to the address of the email provided by the new membershipuser in the CreateUserWizard control. i think i need to define a custom provider for membership and i tried this: web.config:
6
2932
by: Jonathan Wood | last post by:
Although this will be a challenge at my level of ASP.NET knowledge, I'm thinking I should implement my own membership provider class. Looking over the methods I must implement, a number of questions come to mind. 1. How would one implement GetNumberOfUsersOnline? I'm not sure where there is any indication of this? And it this affected by the "Remember me next time" checkbox, which doesn't seem to work like it does on any other site...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.