programmatically Create User Profiles sharepoint 2010

The example shows you how to Create User Profiles and Organization Profiles programmatically in SharePoint 2010.

Creating user Profiles -

SPServiceContext context = SPServiceContext.GetContext(site);

UserProfileManager upm = new UserProfileManager(context);

// create a user profile and set properties
UserProfile profile = upm.CreateUserProfile("domain\\isha");

profile.DisplayName = "Isha Attlee";


Creating organization profile -

SPServiceContext context = SPServiceContext.GetContext(site);

ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);

// choose default organization profile subtype as the subtype
string subtypeName = ProfileSubtypeManager.GetDefaultProfileName(ProfileType.Organization);

ProfileSubtype subType = psm.GetProfileSubtype(subtypeName);

OrganizationProfileManager opm = new OrganizationProfileManager(context);

// choose Root Organization as the parent

OrganizationProfile parentOrg = opm.RootOrganization;

// create an organization profile and set its display name

OrganizationProfile profile = opm.CreateOrganizationProfile(subType, parentOrg);

profile.DisplayName = "Test Org1";

// commit to save changes



Post a Comment


This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at .

Copyright (c) 2010 @ All rights are reserved.Do Not Copy.

@ Learning