0

I want to overwrite the existing user profile that are in sp with my own one.

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 Page_Load(object sender, EventArgs e)
        {
        }

        public void Create()
        {

            string socialDataStatsSite = SPContext.Current.Site.Url;

            using (SPSite siteColl = new SPSite(socialDataStatsSite))
            {

                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();

            }
        }

i have put this code in visual studio and deployed it.

Were do i find it in sharepoint to activate it?

3
  • What did you deploy this as? a feature? a web part? Commented Mar 12, 2013 at 21:59
  • @Ryan Erickson hi, in a webpart?
    – Batistuta
    Commented Mar 13, 2013 at 8:04
  • 1
    If it's in a webpart, then add the web part to a page..
    – Fox
    Commented Mar 13, 2013 at 8:10

1 Answer 1

0

Create a Console Application & run the same or deploy as a feature & activate on the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.