简体   繁体   English

在SharePoint 2010中以编程方式添加新用户

[英]Adding New User programmatically in SharePoint 2010

I've built a new SharePoint 2010 Web Site. 我建立了一个新的SharePoint 2010网站。 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. 我的意思是我想为Register.aspx和Login.aspx添加新页面。 I've done Login.aspx with a code: 我用代码完成了Login.aspx:

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. 在此页面中,用户具有2 x文本框和一个按钮。 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? 我的问题是如何使.aspx页面可用于新成员身份?

This is bad: Response.Redirect(Context.Request.QueryString["Source"].ToString() . What if the user enters www.mysite.com/mysite?Source= http://www.myrealbadvirus.com ? 这很糟糕: Response.Redirect(Context.Request.QueryString["Source"].ToString() 。如果用户输入www.mysite.com/mysite?Source= http://www.myrealbadvirus.com怎么办?
Don't redirect directly to a query string. 不要直接重定向到查询字符串。

Here some links to get you started: 这里有一些链接可以帮助您入门:

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). 您必须将用户添加为具有完全权限的管理员(“管理员”菜单),并为用户授予对连接权限的“完全访问权限”(“权限”菜单)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM