top of page
Writer's pictureNakkeeran Natarajan

How to Start Full Synchronization using C# in SharePoint 2010

In this article we will be seeing how to Start Full Synchronization to import the user profile in SharePoint 2010.

Once you have Configured Synchronization connections in the User Profile Service Application you need to run the "Start Full Synchronization" to import the user profiles. This can be done through UI, programmatically and using powershell commands. Here we will be starting the Full Synchronization using c# code.

C# code:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; using Microsoft.Office.Server; using Microsoft.Office.Server.UserProfiles; using System.Web;

namespace ImportUP { class Program     { static void Main(string[] args)         { using (SPSite site = new SPSite("http://servername:4695/"))             { // get the server context ServerContext context = ServerContext.GetContext(site);

// create the profile configuration manager object UserProfileConfigManager upcm = new UserProfileConfigManager(context);

// check if there is already an import in progress if (!upcm.IsSynchronizationRunning())                 {                                 upcm.StartSynchronization(true); Console.WriteLine("full import started");                 }             }         }     } }

Build the solution and run the code.

Go the SharePoint Central Administration => Application Management => Manage Service Applications =>User Profile Service.

You could see the Profile Synchronization Status has been changed to Synchronizing.


0 comments

Comments


bottom of page