423,822 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,822 IT Pros & Developers. It's quick & easy.

How to Change Membership provider during runtime

P: n/a
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 Oracle db.
Is this feasible?

I found this on MSDN

“You can also configure multiple membership providers, which allows you to
select a membership provider at run time based on application requirements.
For example, for business reasons your membership information might be in
separate regional databases. By configuring multiple membership providers
that each interact with a different regional database, you can direct
membership calls to the appropriate provider for different users.”

http://msdn2.microsoft.com/en-us/library/sx3h274z.aspx
Any idea on how to switch Membership provider during runtime?

Thanks for tip,
-Balaji NJL
Jul 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Balaji,

You need to make sure all the membership providers are listed in the
web.config file, like this:

<membership defaultProvider="Mydefaultprovider">
<providers >
<clear/>
<add connectionStringName="ASPNETDBConnectionString1"
name="MyOracleprovider"
type="System.Web.Security.OracleMembershipProvider "/>
<add connectionStringName="ASPNETDBConnectionString2"
name="Mydefaultprovider" type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>

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

Dim mbr As MembershipProvider
mbr = Membership.Providers.Item("MyOracleprovider")
' mbr.CreateUser(....
Response.Write(mbr.GetType)

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
"Balaji" <Ba****@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
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 Oracle
db.
Is this feasible?

I found this on MSDN

"You can also configure multiple membership providers, which allows you to
select a membership provider at run time based on application
requirements.
For example, for business reasons your membership information might be in
separate regional databases. By configuring multiple membership providers
that each interact with a different regional database, you can direct
membership calls to the appropriate provider for different users."

http://msdn2.microsoft.com/en-us/library/sx3h274z.aspx
Any idea on how to switch Membership provider during runtime?

Thanks for tip,
-Balaji NJL


Jul 6 '06 #2

P: n/a
That helps, Thanks a lot.

"Ken Cox [Microsoft MVP]" wrote:
Hi Balaji,

You need to make sure all the membership providers are listed in the
web.config file, like this:

<membership defaultProvider="Mydefaultprovider">
<providers >
<clear/>
<add connectionStringName="ASPNETDBConnectionString1"
name="MyOracleprovider"
type="System.Web.Security.OracleMembershipProvider "/>
<add connectionStringName="ASPNETDBConnectionString2"
name="Mydefaultprovider" type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>

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

Dim mbr As MembershipProvider
mbr = Membership.Providers.Item("MyOracleprovider")
' mbr.CreateUser(....
Response.Write(mbr.GetType)

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
"Balaji" <Ba****@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
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 Oracle
db.
Is this feasible?

I found this on MSDN

"You can also configure multiple membership providers, which allows you to
select a membership provider at run time based on application
requirements.
For example, for business reasons your membership information might be in
separate regional databases. By configuring multiple membership providers
that each interact with a different regional database, you can direct
membership calls to the appropriate provider for different users."

http://msdn2.microsoft.com/en-us/library/sx3h274z.aspx
Any idea on how to switch Membership provider during runtime?

Thanks for tip,
-Balaji NJL


Jul 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.