Wednesday, September 14, 2011

Create User Profile Programmatically Sharepoint 2010

You can create new user profile using object model as demonstrated below. UserProfileManager class can be used for this purpose. UserProfileManager can be found under namespace Microsoft.Office.Server.UserProfiles.

using (SPSite _site = new SPSite("http://anmol"))
{
       SPServiceContext _context = SPServiceContext.GetContext(_site);

       UserProfileManager _profileManager = new UserProfileManager(_context);

       string _userName = "domain\\AnmolRehan"
       if(_profileManager.UserExists(_userName))

             _profileManager.CreateUserProfile(_userName);}

How to update existing user profile programmatically?

1 comment:

Popular Posts