#pragma namespace("\\root")

instance of __NAMESPACE
{
    Name = "MicrosoftADStatus";
};

#pragma namespace("MicrosoftADStatus")

/////////////////////////////////////////////////////////////////////
// Declare an instance of the __Win32Provider

instance of __Win32Provider as $P
{
    Name = "ADReplPrv" ;
    ClsId = "{96FA95C4-0AF3-4EF9-A1EB-C8151322157B}" ;
} ;    

instance of __InstanceProviderRegistration
{
    Provider = $P;
    SupportsPut = FALSE;
    SupportsGet = TRUE;
    SupportsDelete = FALSE;
    SupportsEnumeration = TRUE;
};


/////////////////////////////////////////////////////////////////////
//
// Declare a class whose dynamic instances are provided by the 
// TrustPrv provider.

[dynamic, provider("ADReplPrv")]
class Microsoft_ADReplStatus
{

// CompositeName combines several other elements as follows:
// <SourceSite>\<SourceDsaCN>;<Domain>,["Domain" | "Configuration" | "Schema"]
// CODEWORK I hate to have to do this, but Healthmon
//          does not support multiple keys per HEALTHMON bug 58142

    [key]
    String  CompositeName;


// The following properties are taken directly from the DS_REPL_NEIGHBOR
// structure returned from DsReplicaGetInfo (ntdsapi.h)

    [Description ("X500 path for the naming context "
                  "replicated by this connection.")]
    String  NamingContext;
    [Description ("String-ized GUID for the replicated naming context.")]
    String  NamingContextObjGuid;

    [Description ("X500 path for the DSA representing the source DC.")]
    String  SourceDsaDN;
    [Description ("String-ized GUID for the DSA "
                  "representing the source DC.")]
    String  SourceDsaObjGuid;
    [Description ("DNS address of the source DC.  Note that this is "
                  "not the commonly-used canonical DNS name, instead "
                  "it is a modified GUID.")]
    String  SourceDsaAddress;

    [Description ("X500 path to the IntersiteTransport object active "
                  "for this connection, commonly <null>.")]
    String  AsyncIntersiteTransportDN;
    [Description ("String-ized GUID for the IntersiteTransport object "
                  "active for this connection, commonly "
                  "{00000000-0000-...}.")]
    String  AsyncIntersiteTransportObjGuid;

    [Description ("Bitfield containing DS_REPL_NBR flags "
                  "as defined in ntdsapi.h.")]
    uint32  ReplicaFlags;

// CODEWORK I'm not sure what these really mean
//          or how the caller would use them.
    [Description ("String-ized GUID.")]
    String  SourceDsaInvocationID;
    [Description ("USN")]
    uint64  LastObjChangeSynced;
    [Description ("USN")]
    uint64  AttributeFilter;

    [Description ("Timestamp for the last replication attempt.")]
    datetime LastSyncSuccess;
    [Description ("Timestamp for the last successful replication attempt.")]
    datetime LastSyncAttempt;

    [Description ("HRESULT error code for the last replication attempt.")]
    uint32  LastSyncResult;
    [Description ("Number of consecutive failed replication attempts.")]
    uint32  NumConsecutiveSyncFailures;


// The following properties are derived form the above properties
// for the convenience of the caller or Healthmon.

    [Description ("DNS domain name of the replicated naming context.")]
    String  Domain;
    [Description ("True if a schema NC is being replicated.")]
    boolean IsSchemaNamingContext = FALSE;
    [Description ("True if a configuration NC is being replicated.")]
    boolean IsConfigurationNamingContext = FALSE;
    [Description ("True if this connection represents a source DC which "
                  "has been deleted.  By design, the DS will continue "
                  "to replicate these connections for some time "
                  "after the source DC is deleted.")]
    boolean IsDeletedSourceDsa = FALSE;

// CODEWORK We only need this because Healthmon does not support
//          triggering off a combination of properties.
    [Description ("Number of consecutive failed replication attempts "
                  "excepting connections which are expected to fail "
                  "(i.e. IsDeletedSourceDsa).")]
    uint32  ModifiedNumConsecutiveSyncFailures;

// Bit values extracted from dwReplicaFlags
// #define DS_REPL_NBR_WRITEABLE                       (0x10)
// #define DS_REPL_NBR_SYNC_ON_STARTUP                 (0x20)
// #define DS_REPL_NBR_DO_SCHEDULED_SYNCS              (0x40)
// #define DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT   (0x80)
// #define DS_REPL_NBR_TWO_WAY_SYNC                    (0x200)
// #define DS_REPL_NBR_FULL_SYNC_IN_PROGRESS           (0x10000)
// #define DS_REPL_NBR_FULL_SYNC_NEXT_PACKET           (0x20000)
// #define DS_REPL_NBR_NEVER_SYNCED                    (0x200000)
// #define DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS     (0x4000000)
// #define DS_REPL_NBR_DISABLE_SCHEDULED_SYNC          (0x8000000)
// #define DS_REPL_NBR_COMPRESS_CHANGES                (0x10000000)
// #define DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS         (0x20000000)
    boolean Writeable = FALSE;
    boolean SyncOnStartup = FALSE;
    boolean DoScheduledSyncs = FALSE;
    boolean UseAsyncIntersiteTransport = FALSE;
    boolean TwoWaySync = FALSE;
    boolean FullSyncInProgress = FALSE;
    boolean FullSyncNextPacket = FALSE;
    boolean NeverSynced = FALSE;
    boolean IgnoreChangeNotifications = FALSE;
    boolean DisableScheduledSync = FALSE;
    boolean CompressChanges = FALSE;
    boolean NoChangeNotifications = FALSE;

    [Description ("Site containing the source DC.")]
    String  SourceDsaSite;
    [Description ("Object path component for the DSA representing "
                  "the source DC.  This is often similar to the "
                  "computername but is not always identical.")]
    String  SourceDsaCN;

};



[dynamic, provider("ADReplPrv")]
class Microsoft_ADReplDomainController
{
    [key]
    String DistinguishedName;
    [key]
    String CommonName;
    [key]
    String SiteName;
    String ObjectGUID;
};