using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
using System.Web;
using Microsoft.SharePoint.WebControls;
using System.Web.Profile;
using Microsoft.SharePoint.Portal.WebControls;
namespace add_user.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
public string AccountName { get; set; }
public string WorkPhone { get; set; }
public string Department { get; set; }
public string Title { get; set; }
public string DistinguishedName { get; set; }
public string WorkEmail { get; set; }
public string Office { get; set; }
protected void Button1_Click(object sender, EventArgs e)
{
Create();
}
public void Create()
{
string socialDataStatsSite = SPContext.Current.Site.Url;
using (SPSite siteColl = new SPSite(socialDataStatsSite))
{
AccountName = "alok";
WorkPhone="9886178862";
Title="Mr";
DistinguishedName="alok";
WorkEmail="alok@pointcross.com";
Office = "Pointcorss";
SPServiceContext serviceContext = SPServiceContext.GetContext(siteColl);
UserProfileManager userProfileManager = new UserProfileManager(serviceContext);
UserProfile newProfile = userProfileManager.CreateUserProfile(AccountName, AccountName);
newProfile[PropertyConstants.WorkPhone].Add(WorkPhone);
newProfile[PropertyConstants.Department].Add(Department);
newProfile[PropertyConstants.Title].Add(Title);
newProfile[PropertyConstants.DistinguishedName].Add(AccountName);
newProfile[PropertyConstants.Office].Add(Office);
newProfile.Commit();
}
}
}
}
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......