Question

I created an asp portal for my customers. They all access the same website and pass in a tokenid, which is a guid. This guid tells me what company they belong to and what they have access to.

I have the membership provider set up to not allow duplicate email addresses and everyone under the same application. So, with this in mind, I figured I could do the following to allow them to register with more than one company with the same email account.

  1. Create an membership provider application for each tokens (for each company).
  2. Write a script that finds all of the accounts that are based on this guid and place them under appropriate application

Will this work? Will it allow my customers to create a login for each token/company using the same email address?

Thanks for the help!

Was it helpful?

Solution

If you script out

[dbo].[aspnet_Membership_FindUsersByEmail]

, you'll see (the default implementation) is already "separated by application". (because this procedure takes "ApplicationName" as a parameter.

So if you programmatically set the

MembershipProvider.ApplicationName

http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.applicationname.aspx

Then you should be able to do what you want.

Here is the signature of the procedure mentioned above:

ALTER PROCEDURE [dbo].[aspnet_Membership_FindUsersByEmail]
    @ApplicationName       nvarchar(256),
    @EmailToMatch          nvarchar(256),
    @PageIndex             int,
    @PageSize              int
AS

REMINDER:

You do not deal with the stored procedures directly. You use the API of the MembershipProvider.

But here is the simple test.

MembershipProvider mp1 = Membership.Providers["App1"];
mp1.CreateUser (.................. )


MembershipProvider mp2 = Membership.Providers["App2"];
mp2.CreateUser (.................. )  /* use same email */

Now, I think you'll have to define each MembershipProvider (and its name) in your config file.

But here is an MSDN link:

http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovidercollection.item.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top