开发者

Adding a user from a SharePoint 2010 web part

I am using a custom membership provider (forms auth) for SharePoint 2010. I am trying to build a web part that will allow an administrator to create a new account via my custom provider. I have code for this that runs perfectly in an ASP.NET application (external to SharePoint). Now, When I try to add a user from the web part:

        MembershipProvider mp = Membership.Providers["MyProvider"];
        MembershipCreateStatus status;
        mp.CreateUser(<USER INFO HERE>, out status);

It gives me a status of "Provider Error."

When I call "GetAllUsers," it throws the good old: {"Object reference not set to an instance of an object."}

Does an开发者_高级运维yone have any ideas or any experience using a custom membership provider from a web part?


I don't know if this will change anything, but it's worth a try:

Did you specify your membership provider as the default provider in the web.config ? There should be a node <membership defaultProvider="i">...</membership>. In a default configuration i is the SPClaimsAuthMembershipProvider. Change the i to whatever name you've given your custom membership provider.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜