Welcome to Comunidade Bloggers |create|it| Sign in | Join | Help

André Vala

SharePoint
Office
FAST Search Server
.Net

News

  • European SharePoint Community Awards 2012 Winner
    Locations of visitors to this page

    Comunidade Portuguesa de SharePoint

    View André Vala's profile on LinkedIn

    © André Vala and Create IT, 2006-2011. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to André Vala and Create IT with appropriate and specific direction to the original content.

SharePoint Tip #22: Create a User Profile

The best way to create SharePoint User Profiles is to import them from somewhere (Active Directory for instance). This is specially true if you want to create a lot of them at once. However, if you really want to do it manually, one at a time, you can. Just do it like in the snippet below.

// open a site collection
using (SPSite site = new SPSite("http://myportal"))
{
    // get the server context
    ServerContext context = ServerContext.GetContext(site);

    // create the profile manager object
    UserProfileManager upm = new UserProfileManager(context);

    // create the user profile
    UserProfile profile = upm.CreateUserProfile("domain\\username");
}

Just like getting a User Profile from the User Profile Store, to create one you need a UserProfileManager object. After that, you just need to call the CreateUserProfile method and pass it the user account name (including the domain).

Attention: User Profiles are a MOSS only feature. You cannot use them with WSS.

Posted: Thursday, October 16, 2008 5:41 AM by andrevala

Comments

No Comments

Anonymous comments are disabled