开发者

Adding New User programmatically in SharePoint 2010

I've built a new SharePoint 2010 Web Site. My authantication type is Claims Based Auth. As you know, we use groups,members to manage or add users/permissions in Site Settings. I want to know that if I can make it with programmaticly. I mean I want to add new page for ex Register.aspx and Login.aspx. I've done Login.aspx with a code:

bool status = SPClaimsUtility.AuthenticateFor开发者_C百科msUser(Context.Request.UrlReferrer,
    TextBox1.Text, TextBox2.Text);

if (!status)
{
    Label1.Text = "Wrong Userid or Password";
}
else
{
    if (Context.Request.QueryString.Keys.Count > 1)
    {
        Response.Redirect(Context.Request.QueryString["Source"].ToString());
    } 
    else
    {
        Response.Redirect(Context.Request.QueryString["ReturnUrl"].ToString());
    }
}

In this page, user have 2 x TextBoxes and a button. He/She can enter username and password and then login. At this point, I need a page to make new registration. I googled it a bit, but cant find enough information. My question is How can I make .aspx page which can be use for new membership?


This is bad: Response.Redirect(Context.Request.QueryString["Source"].ToString(). What if the user enters www.mysite.com/mysite?Source=**http://www.myrealbadvirus.com**?
Don't redirect directly to a query string.

Here some links to get you started:

  • Programmatically granting permissions to claims
  • SharePoint : Add group of users to the user collection programmatically
  • Create Forms Based Authentication (FBA) programmatically users in SharePoint 2010
  • Programmatically create user groups Sharepoint 2010


To access the user profile service you need to have permissions set up in advance. You have to add the user as Administrator with full permissions (Administrators menu) as well as give the user Full access to connection permission (Permission menu).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜