Export (0) Print
Expand All
0 out of 4 rated this helpful - Rate this topic

DirectorySynchronization Class

Specifies how to synchronize a directory within a domain.

Namespace: System.DirectoryServices
Assembly: System.DirectoryServices (in system.directoryservices.dll)

public class DirectorySynchronization
public class DirectorySynchronization
public class DirectorySynchronization
Not applicable.

The following C# example shows how to synchronize a directory.

DirectorySearcher src = new DirectorySearcher("…"); 
src.DirectorySynchornization= new DirectorySynchronization(); // Initiate dirsync, 
                                                              // this means a full synch

foreach(SearchResult res in src.FindAll() )
{
    Console.WriteLine(…");
}

// Restart the dirsync 
foreach(SearchResult res in src.FindAll() )
{
    Console.WriteLine(…");
}

The following C# example shows how to synchronize a directory by persisting it to a file.

DirectorySearcher src = new DirectorySearcher("…"); 
src.DirectorySynchornization= new DirectorySynchronization(); // Initiate dirsync, 
                                                              // this means a full synch

foreach(SearchResult res in src.FindAll() )
{
    Console.WriteLine(…");
}

// Now they should be able to persist the dirSync cookie, by serializing to a file. 
FileStream myStream = File.Create("dirsync.data");
BinaryFormatter fmt = new BinaryFormatter();
fmt.Serialize(myStream, src.DirectorySynchronization);
myStream.Close();
… …. 



// At some point in time, we wake up and read by de-serializing the dirSync cookie, 
// and resume the  dirSync 
FileStream myStream = FileCreate("dirsync.data");
BinaryFormatter fmt = new BinaryFormatter();
DirectorySynchronization dirSync = fmt.Deserialize(myStream);

DirectorySearcher src = new DirectorySearcher(…);
src.DirectorySynchronization = dirSync;

foreach(SearchResult res in src.FindAll() )
{
    Console.WriteLine(…");
}

System.Object
  System.DirectoryServices.DirectorySynchronization
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.