If you need a specific provider, Scott answer is right on. Sorry for
the confusion ...

My answer was more appropriate if you need to select a group of
related providers. For example, we have a single DB store for role
management for a specific application, but membership information is
coming from different independent systems connecting to this
application. So for the administration of that application, we have a
central interface where you can assign role(s) to the groups obtained
from various providers. To get these providers, we loop and select
only those we need.

I am actually completing the work on this interface, so I missed the
"obvious" answer.

After working on this, two questions remain for me:

- why there is no concept of "group" in the available provider base classes?

- why are the base providers and ActiveDirectory* in
System.Web.Security instead of System.Security?

It would have been nice to have something like GetAllGroups(),
GetGroupsForUser(string username), GetRolesForGroup(string groupName),
etc.

Sébastien

On 11/29/06, Scott Guthrie <[EMAIL PROTECTED]> wrote:
In a nutshell, you can control which provider is the "default" provider by setting the 
"defaultProvider" property that is on the <membership>, <roles>, <profile> elements in 
web.config.  When you do this, then calls to:

        Membership.ValidateUser(username, password)

And other methods on the Membership class will go to the default provider.  You can 
programmatically call another provider by accessing it via the "Providers" 
collection on the Membership/Roles API.  For example:

        Membership.Providers["otherprovider"].ValidateUser(username,password)

Note that the "otherprovider" name is determined by the <add/> element in your 
web.config file (where you give each provider a name).

Hope this helps,

Scott

-----Original Message-----
From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf 
Of Sébastien Lorion
Sent: Wednesday, November 29, 2006 6:06 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Multiple Membership Providers

You need to loop over System.Web.Security.Membership.Providers and
somehow find the provider you want, e.g. by checking its type and/or
some properties.

Sébastien

On 11/29/06, Angel Java Lopez <[EMAIL PROTECTED]> wrote:
> Hi people!
>
> At MSDN article:
>
> Membership Providers
> http://msdn2.microsoft.com/en-us/library/sx3h274z.aspx
>
> I read
>
> 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.
>
> But I can't found any sample code or explanation on how to specify the 
membership provider to use at runtime.
>
> Any info, welcome!
>
> Angel "Java" Lopez
> http://www.ajlopez.com/en
> http://ajlopez.wordpress.com/
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to