On the MSDN forums I answered a blog posting about how to update some values of a user profile.  I’ve answered this question more than a few times so I threw up this posting about it.

Here is some basic code to achieve this (its actually from MSDN but I’ve written the same code enough times just couldn’t find it offhand)

using (SPSite site = new SPSite("http://servername"))
{
    ServerContext context = ServerContext.GetContext(site);
    UserProfileManager profileManager = new UserProfileManager(context);
    string sAccount = "domainname\\username";
    UserProfile u = profileManager.GetUserProfile(sAccount);
    u[PropertyConstants.PictureURL].Value = "SOME URL";
    u.Commit();
}

 

 

Be sure to check out MSDN for the members of the PropertyConstants.


Comments


United States Steve
May 13. 2009 09:00
Steve
I think the PropertyConstants reference is obsolete.  Try msdn.microsoft.com/.../...tyconstants_members.aspx

no site

Search Blog

Blog Roll

    OPMLDownload OPML file

    Recent Comments

    Banners

    Theme Grabber
    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2012 Tony Testa's World