RE: Multiple Membership providers and AddUserToRole



Hi Steven,

I have a question on the same subject if you dont mind?

W have an asp.net 2.0 application. The way we have written this web app is
that many companies can use the same software, differing by sub-domain. So if
we setup companyA.software.com they are company id 123, if we setup another
companyB.software.com they are company id 345. The application identifies the
sub-domain requested and set's the company id accordingly. This works well.

We also have used asp.net 2.0 membership in this application. We needed to
ensure that users are unique within each company, we did this by in
session_start setting the Membership.applicationName and
Roles.ApplicationName, similar to how we set the company id based on the url.
We 've found that this does not work and see from this thread that this is
due to a threading issue - we found that changing this resulted in other
users being 'kicked' out to the login screen. We are now trying to find a
solution to this problem...

We considered prefixing the usernames with the company id as they are added,
so for example '345~BobSmith' so that all users are unique to a company. This
seemed to work until we found that email addresses for users would not be
unique this way.

Your suggestion of having different providers in the web.config I dont think
will work in this scenario as we may have many different companies and we
would need to change the web.config on the fly, restarting the application
every time a new user signs up.

Do you have any other potential suggestions that we could consider for this
problem?

Many Thanks!
Kieran



"Steven Cheng[MSFT]" wrote:

Thanks for your reply MrGrundh,

After your further description, I think you're right. A single role
provider with multiple membership user providers will not work here,
especially when you want to utilize the declarative role based
authorization in the web application.

When we use single RoleProvider, it always use the fixed applicationName
(configured in the provider configuration in web.config) and when we add
user into a role, it always assume the user is also in this applicationName
and will not add additional information to distince users in different
application.

So far I haven't found any perfect means on this. What we can get is as
below:

** if still use single provider to store roles for multiple application,
we'll not be able to handle duplicaetd usernames (in different application)
scenario.

** if use multiple role providers, there won't have user/role collision
issue, however, in such case, we will need to explicitly use the correct
role provider (according to applicationName) programmtically and lose the
declarative role based authroization feature (since ASP.NET role based
authorization only use the default role provider).

Actually this is also due to the limitation of the membership/role
provider, they're originally designed for manipulating users/roles in a
single application only and for your scenario, it is a bit beyond the
built-in ability.

Anyway, please feel free to let me know your consideration or if you have
any other questions on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: Using Generics with System.DirectoryServices
    ... | I'm in the process of updating an ASP.NET v1.1 web app to v2. ... | WinNT provider - I'm in the process of fixing that too, ... can't use the following sample to query group membership in a NT4 domain. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Website Administration Tool not working from published applica
    ... provider, whom most of them can't afford the fancy of dedicated servers - ... SQL Server 2000 instead of SQL Express ... The first mistake was using ... that the Web App Admin Tool shows when it cannot connect to the database. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MySql ado.net connector problem
    ... >> 2) I am trying to connect with asp.net web app. ... > the .NET provider you got from the web? ... That is the connection string that I was given from my host. ... a MySqlCommand object like this MySqlCommand command = new MySqlCommandI ...
    (microsoft.public.dotnet.framework.adonet)
  • Oracle Provider Comparison
    ... I'm creating a web app that needs to provide some simple, ... access to an Oracle database using SELECT statements. ... curious about is which provider ... able to get a paramaterized SqlDataSource to work with the ODP.NET ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Multiple Membership providers and AddUserToRole
    ... Nice to hear from you and sorry for the delay response. ... "Provider" property refer to the default RoleProvider configured for the ... and do not need to explicitly set ApplicationName for the role provider. ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.security)