Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.