SharePoint - Add Users (Code)

private void Button1_Click(object sender, System.EventArgs e)
{
SPWeb web = SPControl.GetContextWeb(Context);
string username = TextBox1.Text;
string displayname = TextBox2.Text;
string email = TextBox3.Text;

SPRole admins = web.Roles["Administrator"];
try
{
admins.AddUser(username,email,displayname,"");
Label4.Text="Successfully added user";
}
catch(Exception ex)
{
Label4.Text=ex.ToString();
}
}

Comments