开发者

Adding FBA User to Sharepoint UserInfo list

We are successfully adding a new user to our Forms Based Authentication Provider using the Membership class in C#. We are able to login some public sites but after trying to search for the new created user in the people picker he doesn't show up.

Seems like we have to add a UserInfo record in the WSS_Content_* Database. So we referenced the people.asmx Web Service running on our Sharepoint. After trying to create the UserInfo using the following method, the method returns a not resolved PrincipalInfo object (UserInfoID is -1, IsResolved is false, etc.).

peopleservice.People service = new peopleservice.People();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
string[] users = new string[] { txtCreateEmail.Text };
var result2 = service.ResolvePrincipals(users, brnextranet.SPPrinci开发者_JAVA百科palType.User, true);

Are there any steps we are missing?


I was able to solve the issue by creating a Web Service running on the Sharepoint Server. The following two methods are required to create a UserInfo record:

    [WebMethod]
    public void CreateUser(string username)
    {
        SPWeb web = new SPSite(this.ExtranetSite).OpenWeb();

        web.AllUsers.Add(this.MembershipProvider + ":" + username, username, username, "");
        web.EnsureUser(this.MembershipProvider + ":" + username);
    }

    [WebMethod]
    public void DeleteUser(string username)
    {
        SPWeb web = new SPSite(this.ExtranetSite).OpenWeb();

        web.SiteUsers.Remove(this.MembershipProvider + ":" + username);
        web.Update();
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜