问题描述
我有在一个网站上处理多个会员供给者的麻烦。
我有一个创建用户,并将它们添加到AD域的注册页面。之前,我有一个成员提供,并在页面上我打电话
Membership.CreateUser(txtUsername.Text,txtPassword.Text)
这基础上创建的页面上的用户输入的用户名。
不过,我添加了另一个成员提供到web.config使登录页面可以用来从另一个AD登录。现在,我的注册页面将无法正常工作,因为(我假设)有两个隶属供应商?
我该如何解决这个问题?如何指定当我打电话Membership.CreateUser使用哪个提供商?
感谢。
编辑:
要做到这一点,如下所述正确的方法是:
MembershipCreateStatus NEWSTATUS =新MembershipCreateStatus();
。Membership.Providers [的ProviderName] CREATEUSER(txtUserName.Text,txtPassword.Text,NULL,NULL,NULL,真实,空出NEWSTATUS);
感谢您!
Membership.Providers [的providerName] CREATEUSER(....)。
需要注意的是在这种情况下只有一个CREATEUSER方法,但你可以通过空时不需要其他参数。
编辑:
这是调用有明确供应商,方法的唯一途径。我还没有尝试在公元所以不知道有关解决该错误,但这里是另一种方式创建用户。
作出CREATEUSER提供商为您defaultprovider,所以你可以回到老CREATEUSER电话。但现在你调整你的登录调用使用其他供应商例如
Membership.Providers [的providerName]。的ValidateUser()
I am having trouble with handling multiple Membership Providers on one site.
I have a registration page that creates user and adds them to an AD domain. Before I had one membership provider and on the page I called
Membership.CreateUser(txtUsername.Text, txtPassword.Text)
which created the username based on the user inputs on the page.
However, I added another membership provider to the web.config so that the log in page can be used to log in from another AD. Now, my registration page will not work because (I assume) there is two membership providers?
How can I fix this? How do I specify which provider to use when I call Membership.CreateUser?
Thanks.
Edit:
The correct way to do this, as mentioned below is :
MembershipCreateStatus newStatus = new MembershipCreateStatus();
Membership.Providers["ProviderName"].CreateUser(txtUserName.Text, txtPassword.Text, null, null, null, true,null, out newStatus);
Thank you!
Membership.Providers["providername"].CreateUser(....);
Note that there is only one CreateUser method in this case but you can pass null of other parameters that are not needed.
Edit:
That is the only way to call that method with explicit provider. I haven't tried creating user in AD so not sure about resolving that error but here is another way.Make the provider for CreateUser as your defaultprovider and so you can go back to the old CreateUser call. But now you adjust your login call to use another provider e.g.
Membership.Providers["providername"].ValidateUser()
这篇关于Membership.CreateUser多个会员供给者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!