SharePoint 2010 – Create User Profile Programmatically

To Create User Profile Programmatically, check out the code below.
I will update 3 fields (Manager, Department and Job Title) to SharePoint 2010

Please add 2 references in the Project

using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
SPSite site = new SPSite(UserProfileController.GetConfigEntry(sServer));
SPServiceContext context = SPServiceContext.GetContext(site);
UserProfileManager uprofileManager = new UserProfileManager(context);

if (uprofileManager.UserExists(sAccount))
                UserProfile up = uprofileManager.GetUserProfile(sAccount);
                up[PropertyConstants.Manager].Value = Constants.sDomain + info.Manager;
                up[PropertyConstants.Department].Value = info.Department;
                up[PropertyConstants.JobTitle].Value = info.JobTitle;

Related Posts with Thumbnails

Incoming search terms:


No comments yet.

Leave a Reply

Get Adobe Flash player
%d bloggers like this: