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.
我为我的客户创建了一个asp门户。他们都访问同一个网站并传入一个令牌,这是一个guid。这个guid告诉我他们属于哪家公司以及他们有什么权限。
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.
我将成员资格提供程序设置为不允许重复的电子邮件地址和同一应用程序下的所有人。因此,考虑到这一点,我认为我可以执行以下操作,以允许他们使用相同的电子邮件帐户注册多个公司。
- Create an membership provider application for each tokens (for each company).
- 为每个令牌(针对每个公司)创建成员资格提供程序应用程序。
- Write a script that finds all of the accounts that are based on this guid and place them under appropriate application
- 编写一个脚本,找到所有基于此guid的帐户,并将它们放在适当的应用程序下
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!
谢谢您的帮助!
1 个解决方案
#1
1
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.
,你会看到(默认实现)已经“由应用程序分隔”。 (因为此过程将“ApplicationName”作为参数。
So if you programmatically set the
所以,如果你以编程方式设置
MembershipProvider.ApplicationName
MembershipProvider.ApplicationName
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.applicationname.aspx
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.
您不直接处理存储过程。您使用MembershipProvider的API。
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.
现在,我认为您必须在配置文件中定义每个MembershipProvider(及其名称)。
But here is an MSDN link:
但这是一个MSDN链接:
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovidercollection.item.aspx
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovidercollection.item.aspx
#1
1
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.
,你会看到(默认实现)已经“由应用程序分隔”。 (因为此过程将“ApplicationName”作为参数。
So if you programmatically set the
所以,如果你以编程方式设置
MembershipProvider.ApplicationName
MembershipProvider.ApplicationName
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.applicationname.aspx
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.
您不直接处理存储过程。您使用MembershipProvider的API。
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.
现在,我认为您必须在配置文件中定义每个MembershipProvider(及其名称)。
But here is an MSDN link:
但这是一个MSDN链接:
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovidercollection.item.aspx
http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovidercollection.item.aspx