2

I have a web application that is kind of a hub for different companies. Each one of these companies will be allowed to manage (create/delete) its own user.

If there are thousands of companies using the application, they're bound to create users with the same Username as other companies. Now, currently 'company a' cannot have the same username as 'company b' even though neither company knows the other even exists.

Is it possible with SqlMembershipProvider to allow for multiple usernames based on an application specific criteria (in the example above it would be the company name or company id)? And if so, is there an example available online on how I can accomplish this?

Any help would be appreciated. Thanks!

Shaz
  • 2,676
  • 1
  • 22
  • 22
  • So after thinking about it for a couple of minutes I realized the impossibility of this scenario. With a single log-in page, how can the application possibly distinguish between 'jsmith' from Company A and 'jsmith' from Company B unless the person specifies the company to which he belongs. – Shaz May 12 '11 at 22:04
  • 1
    No, it's not impossible. You could do something like companyA.portal.com, companyB.portal.com. Both could point to the same site and you could just parse the sub-domain to know which company you're dealing with. – Esteban Araya May 12 '11 at 22:11

2 Answers2

1

I believe this works if you use the other "username" parameter -- the application name. Set each company up with their own application name for users and you should be able to make usernames unique within each company.

Wyatt Barnett
  • 15,573
  • 3
  • 34
  • 53
1

Two thoughts:

  1. Require username to be an email address; you're guranteed uniqueness even across companies.
  2. Set the MembershipProvider's ApplicationName base on the company; you can do this on SessionStart or some other such event.
Esteban Araya
  • 29,284
  • 24
  • 107
  • 141
  • I agree the email one but how can the application name be changed unless there is something from the user side to be determined that a user belongs to "A" or "B" company. Unless there are two sites as you suggested earlier – Mitul May 13 '11 at 01:24