Quick Start (MTOM): Programmatically synchronizing users using the web service API

The following C# code example synchronizes users by using the User Management APIs. (See Programmatically Synchronizing Users.)

???/** 
    * Ensure that you create a .NET project that uses  
    * MS Visual Studio 2008 and version 3.5 of the .NET 
    * framework. This is required to invoke a  
    * LiveCycle service using MTOM. 
    *      
    * For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle   
    */ 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.IO; 
 
//A reference to the UserManagerUtilServiceClient object 
using SynchDomain.ServiceReference1; 
 
namespace SynchDomain 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a UserManagerUtilServiceClient object 
                   UserManagerUtilServiceClient umUtilClient = new UserManagerUtilServiceClient(); 
                   umUtilClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/UserManagerUtilService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)umUtilClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   umUtilClient.ClientCredentials.UserName.UserName = "administrator"; 
                   umUtilClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
                   b.MaxReceivedMessageSize = 2000000; 
                   b.MaxBufferSize = 2000000; 
                   b.ReaderQuotas.MaxArrayLength = 2000000; 
 
                   //Create an array instance to store domain names to sync with 
                   MyArrayOf_xsd_anyType domainNames = new MyArrayOf_xsd_anyType(); 
                   domainNames.Add("DirManager"); 
 
                   //Perform the synchronization operation on the array of enterprise domains specified above 
                   umUtilClient.scheduleSynchronization(domainNames); 
 
                   //In case the synchronization needs to be performed on all the registered enterprise domains use this method umUtilClient.scheduleSynchronization(); 
     
                   //Check the status of the sync operation 
                   SynchDomain.ServiceReference1.Map synchStatus = umUtilClient.getDirectorySyncStatus(domainNames); 
 
                   //Get the value of the 1st element 
                   DirectorySyncInfo di = (DirectorySyncInfo)synchStatus[0].value; 
 
                   int status = di.syncStatus; 
                   if (status == 2) 
                     Console.WriteLine("Directory synch for the domain is complete"); 
                   else 
                     Console.WriteLine("Directory synch for the domain is not complete");   
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
}