Serkan Hekimoglu
Serkan Hekimoglu

Reputation: 4284

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.AuthenticateFormsUser(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?

Upvotes: 0

Views: 8059

Answers (2)

Dennis G
Dennis G

Reputation: 21788

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:

Upvotes: 1

user1228735
user1228735

Reputation: 11

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).

Upvotes: 0

Related Questions