#ifndef _NTDSAPI_H
#define _NTDSAPI_H

/* Windows NT Directory Service API definitions */

#include <schedule.h>

#if !defined(_NTDSAPI_)
#define NTDSAPI DECLSPEC_IMPORT
#else
#define NTDSAPI
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define DS_DEFAULT_LOCALE  (MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT))
#define DS_DEFAULT_LOCALE_COMPARE_FLAGS  (NORM_IGNORECASE|NORM_IGNOREKANATYPE|NORM_IGNORENONSPACE|NORM_IGNOREWIDTH)

#define DS_SYNCED_EVENT_NAME  "NTDSInitialSyncsCompleted"
#define DS_SYNCED_EVENT_NAME_W  L"NTDSInitialSyncsCompleted"

#ifndef _DS_CONTROL_BITS_DEFINED_
#define _DS_CONTROL_BITS_DEFINED_
#define ACTRL_DS_OPEN  0x00000000
#define ACTRL_DS_CREATE_CHILD  0x00000001
#define ACTRL_DS_DELETE_CHILD  0x00000002
#define ACTRL_DS_LIST  0x00000004
#define ACTRL_DS_SELF  0x00000008
#define ACTRL_DS_READ_PROP  0x00000010
#define ACTRL_DS_WRITE_PROP  0x00000020
#define ACTRL_DS_DELETE_TREE  0x00000040
#define ACTRL_DS_LIST_OBJECT  0x00000080
#define ACTRL_DS_CONTROL_ACCESS  0x00000100
#define DS_GENERIC_READ  ((STANDARD_RIGHTS_READ)|(ACTRL_DS_LIST)|(ACTRL_DS_READ_PROP)|(ACTRL_DS_LIST_OBJECT))
#define DS_GENERIC_EXECUTE  ((STANDARD_RIGHTS_EXECUTE)|(ACTRL_DS_LIST))
#define DS_GENERIC_WRITE  ((STANDARD_RIGHTS_WRITE)|(ACTRL_DS_SELF)|(ACTRL_DS_WRITE_PROP))
#define DS_GENERIC_ALL  ((STANDARD_RIGHTS_REQUIRED)|(ACTRL_DS_CREATE_CHILD)|(ACTRL_DS_DELETE_CHILD)|(ACTRL_DS_DELETE_TREE)|(ACTRL_DS_READ_PROP)|(ACTRL_DS_WRITE_PROP)|(ACTRL_DS_LIST)|(ACTRL_DS_LIST_OBJECT)|(ACTRL_DS_CONTROL_ACCESS)|(ACTRL_DS_SELF))
#endif /* _DS_CONTROL_BITS_DEFINED_ */

#define DS_DOMAIN_SIMPLE_NAME  DS_USER_PRINCIPAL_NAME
#define DS_ENTERPRISE_SIMPLE_NAME  DS_USER_PRINCIPAL_NAME

#define DS_NAME_LEGAL_FLAGS  (DS_NAME_FLAG_SYNTACTICAL_ONLY)

#define DS_REPSYNC_ASYNCHRONOUS_OPERATION 0x00000001
#define DS_REPSYNC_WRITEABLE  0x00000002
#define DS_REPSYNC_PERIODIC  0x00000004
#define DS_REPSYNC_INTERSITE_MESSAGING  0x00000008
#define DS_REPSYNC_ALL_SOURCES  0x00000010
#define DS_REPSYNC_FULL  0x00000020
#define DS_REPSYNC_URGENT  0x00000040
#define DS_REPSYNC_NO_DISCARD  0x00000080
#define DS_REPSYNC_FORCE  0x00000100
#define DS_REPSYNC_ADD_REFERENCE  0x00000200
#define DS_REPSYNC_NEVER_COMPLETED  0x00000400
#define DS_REPSYNC_TWO_WAY  0x00000800

#define DS_REPADD_ASYNCHRONOUS_OPERATION  0x00000001
#define DS_REPADD_WRITEABLE  0x00000002
#define DS_REPADD_INITIAL  0x00000004
#define DS_REPADD_PERIODIC  0x00000008
#define DS_REPADD_INTERSITE_MESSAGING  0x00000010
#define DS_REPADD_ASYNCHRONOUS_REPLICA  0x00000020
#define DS_REPADD_DISABLE_NOTIFICATION  0x00000040
#define DS_REPADD_DISABLE_PERIODIC  0x00000080
#define DS_REPADD_USE_COMPRESSION  0x00000100
#define DS_REPADD_NEVER_NOTIFY  0x00000200

#define DS_REPDEL_ASYNCHRONOUS_OPERATION 0x00000001
#define DS_REPDEL_WRITEABLE  0x00000002
#define DS_REPDEL_INTERSITE_MESSAGING  0x00000004
#define DS_REPDEL_IGNORE_ERRORS  0x00000008
#define DS_REPDEL_LOCAL_ONLY  0x00000010
#define DS_REPDEL_NO_SOURCE  0x00000020
#define DS_REPDEL_REF_OK  0x00000040

#define DS_REPMOD_ASYNCHRONOUS_OPERATION  0x00000001
#define DS_REPMOD_WRITEABLE  0x00000002
#define DS_REPMOD_UPDATE_FLAGS  0x00000001
#define DS_REPMOD_UPDATE_ADDRESS  0x00000002
#define DS_REPMOD_UPDATE_SCHEDULE  0x00000004
#define DS_REPMOD_UPDATE_RESULT  0x00000008
#define DS_REPMOD_UPDATE_TRANSPORT  0x00000010

#define DS_REPUPD_ASYNCHRONOUS_OPERATION  0x00000001
#define DS_REPUPD_WRITEABLE  0x00000002
#define DS_REPUPD_ADD_REFERENCE  0x00000004
#define DS_REPUPD_DELETE_REFERENCE  0x00000008

#define GUID_USERS_CONTAINER_A  "a9d1ca15768811d1aded00c04fd8d5cd"
#define GUID_COMPUTRS_CONTAINER_A  "aa312825768811d1aded00c04fd8d5cd"
#define GUID_SYSTEMS_CONTAINER_A  "ab1d30f3768811d1aded00c04fd8d5cd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_A "a361b2ffffd211d1aa4b00c04fd7d83a"
#define GUID_INFRASTRUCTURE_CONTAINER_A  "2fbac1870ade11d297c400c04fd8d5cd"
#define GUID_DELETED_OBJECTS_CONTAINER_A  "18e2ea80684f11d2b9aa00c04f79f805"
#define GUID_LOSTANDFOUND_CONTAINER_A  "ab8153b7768811d1aded00c04fd8d5cd"

#define GUID_USERS_CONTAINER_W  L"a9d1ca15768811d1aded00c04fd8d5cd"
#define GUID_COMPUTRS_CONTAINER_W  L"aa312825768811d1aded00c04fd8d5cd"
#define GUID_SYSTEMS_CONTAINER_W  L"ab1d30f3768811d1aded00c04fd8d5cd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_W L"a361b2ffffd211d1aa4b00c04fd7d83a"
#define GUID_INFRASTRUCTURE_CONTAINER_W  L"2fbac1870ade11d297c400c04fd8d5cd"
#define GUID_DELETED_OBJECTS_CONTAINER_W  L"18e2ea80684f11d2b9aa00c04f79f805"
#define GUID_LOSTANDFOUND_CONTAINER_W  L"ab8153b7768811d1aded00c04fd8d5cd"

#define GUID_USERS_CONTAINER_BYTE  "\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_COMPUTRS_CONTAINER_BYTE  "\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_SYSTEMS_CONTAINER_BYTE  "\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE "\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a"
#define GUID_INFRASTRUCTURE_CONTAINER_BYTE  "\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_DELETED_OBJECTS_CONTAINER_BYTE  "\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05"
#define GUID_LOSTANDFOUND_CONTAINER_BYTE  "\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"

#define DS_REPSYNCALL_NO_OPTIONS  0x00000000
#define DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE  0x00000001
#define DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY  0x00000002
#define DS_REPSYNCALL_ID_SERVERS_BY_DN  0x00000004
#define DS_REPSYNCALL_DO_NOT_SYNC  0x00000008
#define DS_REPSYNCALL_SKIP_INITIAL_CHECK  0x00000010
#define DS_REPSYNCALL_PUSH_CHANGES_OUTWARD  0x00000020
#define DS_REPSYNCALL_CROSS_SITE_BOUNDARIES  0x00000040

#define DS_LIST_DSA_OBJECT_FOR_SERVER  0
#define DS_LIST_DNS_HOST_NAME_FOR_SERVER  1
#define DS_LIST_ACCOUNT_OBJECT_FOR_SERVER  2

#define DS_ROLE_SCHEMA_OWNER  0
#define DS_ROLE_DOMAIN_OWNER  1
#define DS_ROLE_PDC_OWNER  2
#define DS_ROLE_RID_OWNER  3
#define DS_ROLE_INFRASTRUCTURE_OWNER  4

#define DS_SCHEMA_GUID_NOT_FOUND  0
#define DS_SCHEMA_GUID_ATTR  1
#define DS_SCHEMA_GUID_ATTR_SET  2
#define DS_SCHEMA_GUID_CLASS  3
#define DS_SCHEMA_GUID_CONTROL_RIGHT  4

#define DS_KCC_FLAG_ASYNC_OP  (1)

#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)

#define NTDSDSA_OPT_IS_GC  (1<<0)
#define NTDSDSA_OPT_DISABLE_INBOUND_REPL  (1<<1)
#define NTDSDSA_OPT_DISABLE_OUTBOUND_REPL  (1<<2)
#define NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE  (1<<3)
#define NTDSCONN_OPT_IS_GENERATED  (1<<0)
#define NTDSCONN_OPT_TWOWAY_SYNC  (1<<1)
#define NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT (1<<2)
#define NTDSCONN_OPT_USE_NOTIFY  (1<<3)
#define NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED  (1<<0)
#define NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED  (1<<1)
#define NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED  (1<<2)
#define NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED (1<<3)
#define NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED (1<<4)
#define NTDSTRANSPORT_OPT_IGNORE_SCHEDULES (1<<0)
#define NTDSTRANSPORT_OPT_BRIDGES_REQUIRED (1<<1)
#define NTDSSITECONN_OPT_USE_NOTIFY (1<<0)
#define NTDSSITECONN_OPT_TWOWAY_SYNC  (1<<1)
#define NTDSSITELINK_OPT_USE_NOTIFY (1<<0)
#define NTDSSITELINK_OPT_TWOWAY_SYNC  (1<<1)

typedef enum {
    DS_UNKNOWN_NAME = 0,
    DS_FQDN_1779_NAME = 1,
    DS_NT4_ACCOUNT_NAME = 2,
    DS_DISPLAY_NAME = 3,
    DS_UNIQUE_ID_NAME = 6,
    DS_CANONICAL_NAME = 7,
    DS_USER_PRINCIPAL_NAME = 8,
    DS_CANONICAL_NAME_EX = 9,
    DS_SERVICE_PRINCIPAL_NAME = 10,
    DS_SID_OR_SID_HISTORY_NAME = 11
} DS_NAME_FORMAT;

typedef enum {
    DS_NAME_NO_FLAGS = 0x0,
    DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1,
    DS_NAME_FLAG_EVAL_AT_DC = 0x2
} DS_NAME_FLAGS;

typedef enum {
    DS_NAME_NO_ERROR = 0,
    DS_NAME_ERROR_RESOLVING = 1,
    DS_NAME_ERROR_NOT_FOUND = 2,
    DS_NAME_ERROR_NOT_UNIQUE = 3,
    DS_NAME_ERROR_NO_MAPPING = 4,
    DS_NAME_ERROR_DOMAIN_ONLY = 5,
    DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6
} DS_NAME_ERROR;

typedef enum {
    DS_SPN_DNS_HOST = 0,
    DS_SPN_DN_HOST = 1,
    DS_SPN_NB_HOST = 2,
    DS_SPN_DOMAIN = 3,
    DS_SPN_NB_DOMAIN = 4,
    DS_SPN_SERVICE = 5
} DS_SPN_NAME_TYPE;

typedef enum {
    DS_SPN_ADD_SPN_OP = 0,
    DS_SPN_REPLACE_SPN_OP = 1,
    DS_SPN_DELETE_SPN_OP = 2
} DS_SPN_WRITE_OP;

typedef struct {
    DWORD status;
    LPSTR pDomain;
    LPSTR pName;
} DS_NAME_RESULT_ITEMA, *PDS_NAME_RESULT_ITEMA;

typedef struct {
    DWORD cItems;
    PDS_NAME_RESULT_ITEMA rItems;
} DS_NAME_RESULTA, *PDS_NAME_RESULTA;

typedef struct {
    DWORD status;
    LPWSTR pDomain;
    LPWSTR pName;
} DS_NAME_RESULT_ITEMW, *PDS_NAME_RESULT_ITEMW;

typedef struct {
    DWORD cItems;
    PDS_NAME_RESULT_ITEMW rItems;
} DS_NAME_RESULTW, *PDS_NAME_RESULTW;

typedef enum {
    DS_REPSYNCALL_WIN32_ERROR_CONTACTING_SERVER = 0,
    DS_REPSYNCALL_WIN32_ERROR_REPLICATING = 1,
    DS_REPSYNCALL_SERVER_UNREACHABLE = 2
} DS_REPSYNCALL_ERROR;

typedef enum {
    DS_REPSYNCALL_EVENT_ERROR = 0,
    DS_REPSYNCALL_EVENT_SYNC_STARTED = 1,
    DS_REPSYNCALL_EVENT_SYNC_COMPLETED = 2,
    DS_REPSYNCALL_EVENT_FINISHED = 3
} DS_REPSYNCALL_EVENT;

typedef struct {
    LPSTR pszSrcId;
    LPSTR pszDstId;
    LPSTR pszNC;
    GUID *pguidSrc;
    GUID *pguidDst;
} DS_REPSYNCALL_SYNCA, *PDS_REPSYNCALL_SYNCA;

typedef struct {
    LPWSTR pszSrcId;
    LPWSTR pszDstId;
    LPWSTR pszNC;
    GUID *pguidSrc;
    GUID *pguidDst;
} DS_REPSYNCALL_SYNCW, *PDS_REPSYNCALL_SYNCW;

typedef struct {
    LPSTR pszSvrId;
    DS_REPSYNCALL_ERROR error;
    DWORD dwWin32Err;
    LPSTR pszSrcId;
} DS_REPSYNCALL_ERRINFOA, *PDS_REPSYNCALL_ERRINFOA;

typedef struct {
    LPWSTR pszSvrId;
    DS_REPSYNCALL_ERROR error;
    DWORD dwWin32Err;
    LPWSTR pszSrcId;
} DS_REPSYNCALL_ERRINFOW, *PDS_REPSYNCALL_ERRINFOW;

typedef struct {
    DS_REPSYNCALL_EVENT event;
    DS_REPSYNCALL_ERRINFOA *pErrInfo;
    DS_REPSYNCALL_SYNCA *pSync;
} DS_REPSYNCALL_UPDATEA, *PDS_REPSYNCALL_UPDATEA;

typedef struct {
    DS_REPSYNCALL_EVENT event;
    DS_REPSYNCALL_ERRINFOW *pErrInfo;
    DS_REPSYNCALL_SYNCW *pSync;
} DS_REPSYNCALL_UPDATEW, *PDS_REPSYNCALL_UPDATEW;

typedef struct {
    GUID guid;
    DWORD guidType;
    LPSTR pName;
} DS_SCHEMA_GUID_MAPA, *PDS_SCHEMA_GUID_MAPA;

typedef struct {
    GUID guid;
    DWORD guidType;
    LPWSTR pName;
} DS_SCHEMA_GUID_MAPW, *PDS_SCHEMA_GUID_MAPW;

typedef struct {
    LPSTR NetbiosName;
    LPSTR DnsHostName;
    LPSTR SiteName;
    LPSTR ComputerObjectName;
    LPSTR ServerObjectName;
    BOOL fIsPdc;
    BOOL fDsEnabled;

} DS_DOMAIN_CONTROLLER_INFO_1A, *PDS_DOMAIN_CONTROLLER_INFO_1A;

typedef struct {
    LPWSTR NetbiosName;
    LPWSTR DnsHostName;
    LPWSTR SiteName;
    LPWSTR ComputerObjectName;
    LPWSTR ServerObjectName;
    BOOL fIsPdc;
    BOOL fDsEnabled;

} DS_DOMAIN_CONTROLLER_INFO_1W, *PDS_DOMAIN_CONTROLLER_INFO_1W;

typedef struct {
    LPSTR NetbiosName;
    LPSTR DnsHostName;
    LPSTR SiteName;
    LPSTR SiteObjectName;
    LPSTR ComputerObjectName;
    LPSTR ServerObjectName;
    LPSTR NtdsDsaObjectName;
    BOOL fIsPdc;
    BOOL fDsEnabled;
    BOOL fIsGc;
    GUID SiteObjectGuid;
    GUID ComputerObjectGuid;
    GUID ServerObjectGuid;
    GUID NtdsDsaObjectGuid;
} DS_DOMAIN_CONTROLLER_INFO_2A, *PDS_DOMAIN_CONTROLLER_INFO_2A;

typedef struct {
    LPWSTR NetbiosName;
    LPWSTR DnsHostName;
    LPWSTR SiteName;
    LPWSTR SiteObjectName;
    LPWSTR ComputerObjectName;
    LPWSTR ServerObjectName;
    LPWSTR NtdsDsaObjectName;
    BOOL fIsPdc;
    BOOL fDsEnabled;
    BOOL fIsGc;
    GUID SiteObjectGuid;
    GUID ComputerObjectGuid;
    GUID ServerObjectGuid;
    GUID NtdsDsaObjectGuid;
} DS_DOMAIN_CONTROLLER_INFO_2W, *PDS_DOMAIN_CONTROLLER_INFO_2W;

typedef enum {
    DS_KCC_TASKID_UPDATE_TOPOLOGY = 0
} DS_KCC_TASKID;

typedef enum _DS_REPL_INFO_TYPE {
    DS_REPL_INFO_NEIGHBORS = 0,
    DS_REPL_INFO_CURSORS_FOR_NC = 1,
    DS_REPL_INFO_METADATA_FOR_OBJ = 2,
    DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES = 3,
    DS_REPL_INFO_KCC_DSA_LINK_FAILURES = 4,
    DS_REPL_INFO_PENDING_OPS = 5,
    DS_REPL_INFO_TYPE_MAX
} DS_REPL_INFO_TYPE;

typedef struct _DS_REPL_NEIGHBORW {
    LPWSTR pszNamingContext;
    LPWSTR pszSourceDsaDN;
    LPWSTR pszSourceDsaAddress;
    LPWSTR pszAsyncIntersiteTransportDN;
    DWORD dwReplicaFlags;
    DWORD dwReserved;
    UUID uuidNamingContextObjGuid;
    UUID uuidSourceDsaObjGuid;
    UUID uuidSourceDsaInvocationID;
    UUID uuidAsyncIntersiteTransportObjGuid;
    USN usnLastObjChangeSynced;
    USN usnAttributeFilter;
    FILETIME ftimeLastSyncSuccess;
    FILETIME ftimeLastSyncAttempt;
    DWORD dwLastSyncResult;
    DWORD cNumConsecutiveSyncFailures;
} DS_REPL_NEIGHBORW;

typedef struct _DS_REPL_NEIGHBORSW {
    DWORD cNumNeighbors;
    DWORD dwReserved;
    DS_REPL_NEIGHBORW rgNeighbor[1];
} DS_REPL_NEIGHBORSW;

typedef struct _DS_REPL_CURSOR {
    UUID uuidSourceDsaInvocationID;
    USN usnAttributeFilter;
} DS_REPL_CURSOR;

typedef struct _DS_REPL_CURSORS {
    DWORD cNumCursors;
    DWORD dwReserved;
    DS_REPL_CURSOR rgCursor[1];
} DS_REPL_CURSORS;

typedef struct _DS_REPL_ATTR_META_DATA {
    LPWSTR pszAttributeName;
    DWORD dwVersion;
    FILETIME ftimeLastOriginatingChange;
    UUID uuidLastOriginatingDsaInvocationID;
    USN usnOriginatingChange;
    USN usnLocalChange;
} DS_REPL_ATTR_META_DATA;

typedef struct _DS_REPL_OBJ_META_DATA {
    DWORD cNumEntries;
    DWORD dwReserved;
    DS_REPL_ATTR_META_DATA rgMetaData[1];
} DS_REPL_OBJ_META_DATA;

typedef struct _DS_REPL_KCC_DSA_FAILUREW {
    LPWSTR pszDsaDN;
    UUID uuidDsaObjGuid;
    FILETIME ftimeFirstFailure;
    DWORD cNumFailures;
    DWORD dwLastResult;
} DS_REPL_KCC_DSA_FAILUREW;

typedef struct _DS_REPL_KCC_DSA_FAILURESW {
    DWORD cNumEntries;
    DWORD dwReserved;
    DS_REPL_KCC_DSA_FAILUREW rgDsaFailure[1];
} DS_REPL_KCC_DSA_FAILURESW;

typedef enum _DS_REPL_OP_TYPE {
    DS_REPL_OP_TYPE_SYNC = 0,
    DS_REPL_OP_TYPE_ADD,
    DS_REPL_OP_TYPE_DELETE,
    DS_REPL_OP_TYPE_MODIFY,
    DS_REPL_OP_TYPE_UPDATE_REFS
} DS_REPL_OP_TYPE;

typedef struct _DS_REPL_OPW {
    FILETIME ftimeEnqueued;
    ULONG ulSerialNumber;
    ULONG ulPriority;
    DS_REPL_OP_TYPE OpType;
    ULONG ulOptions;
    LPWSTR pszNamingContext;
    LPWSTR pszDsaDN;
    LPWSTR pszDsaAddress;
    UUID uuidNamingContextObjGuid;
    UUID uuidDsaObjGuid;
} DS_REPL_OPW;

typedef struct _DS_REPL_PENDING_OPSW {
    FILETIME ftimeCurrentOpStarted;
    DWORD cNumPendingOps;
    DS_REPL_OPW rgPendingOp[1];
} DS_REPL_PENDING_OPSW;

NTDSAPI DWORD WINAPI DsBindW(LPCWSTR,LPCWSTR,HANDLE*);
NTDSAPI DWORD WINAPI DsBindA(LPCSTR,LPCSTR,HANDLE*);
NTDSAPI DWORD WINAPI DsBindWithCredW(LPCWSTR,LPCWSTR,RPC_AUTH_IDENTITY_HANDLE,HANDLE*);
NTDSAPI DWORD WINAPI DsBindWithCredA(LPCSTR,LPCSTR,RPC_AUTH_IDENTITY_HANDLE,HANDLE*);
NTDSAPI DWORD WINAPI DsBindWithSpnW(LPCWSTR,LPCWSTR,RPC_AUTH_IDENTITY_HANDLE,LPCWSTR,HANDLE*);
NTDSAPI DWORD WINAPI DsBindWithSpnA(LPCSTR,LPCSTR,RPC_AUTH_IDENTITY_HANDLE,LPCSTR,HANDLE*);
NTDSAPI DWORD WINAPI DsUnBindW(HANDLE*);
NTDSAPI DWORD WINAPI DsUnBindA(HANDLE*);
NTDSAPI DWORD WINAPI DsMakePasswordCredentialsW(LPCWSTR,LPCWSTR,LPCWSTR,RPC_AUTH_IDENTITY_HANDLE*);
NTDSAPI DWORD WINAPI DsMakePasswordCredentialsA(LPCSTR,LPCSTR,LPCSTR,RPC_AUTH_IDENTITY_HANDLE*);
NTDSAPI VOID WINAPI DsFreePasswordCredentials(RPC_AUTH_IDENTITY_HANDLE);
NTDSAPI DWORD WINAPI DsCrackNamesW(HANDLE,DS_NAME_FLAGS,DS_NAME_FORMAT,DS_NAME_FORMAT,DWORD,const LPCWSTR*,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsCrackNamesA(HANDLE,DS_NAME_FLAGS,DS_NAME_FORMAT,DS_NAME_FORMAT,DWORD,const LPCSTR*,PDS_NAME_RESULTA*);
NTDSAPI void WINAPI DsFreeNameResultW(DS_NAME_RESULTW*);
NTDSAPI void WINAPI DsFreeNameResultA(DS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsMakeSpnW(LPCWSTR,LPCWSTR,LPCWSTR,USHORT,LPCWSTR,DWORD*,LPWSTR);
NTDSAPI DWORD WINAPI DsMakeSpnA(LPCSTR,LPCSTR,LPCSTR,USHORT,LPCSTR,DWORD*,LPSTR);
NTDSAPI DWORD WINAPI DsGetSpnA(DS_SPN_NAME_TYPE,LPCSTR,LPCSTR,USHORT,USHORT,LPCSTR*,const USHORT*,DWORD*,LPSTR**);
NTDSAPI DWORD WINAPI DsGetSpnW(DS_SPN_NAME_TYPE,LPCWSTR,LPCWSTR,USHORT,USHORT,LPCWSTR*,const USHORT*,DWORD*,LPWSTR**);
NTDSAPI void WINAPI DsFreeSpnArrayA(DWORD,LPSTR*);
NTDSAPI void WINAPI DsFreeSpnArrayW(DWORD,LPWSTR*);
NTDSAPI DWORD WINAPI DsCrackSpnA(LPCSTR,LPDWORD,LPSTR,LPDWORD,LPSTR,LPDWORD,LPSTR,USHORT*);
NTDSAPI DWORD WINAPI DsCrackSpnW(LPCWSTR,DWORD*,LPWSTR,DWORD*,LPWSTR,DWORD*,LPWSTR,USHORT*);
NTDSAPI DWORD WINAPI DsWriteAccountSpnA(HANDLE,DS_SPN_WRITE_OP,LPCSTR,DWORD,LPCSTR*);
NTDSAPI DWORD WINAPI DsWriteAccountSpnW(HANDLE,DS_SPN_WRITE_OP,LPCWSTR,DWORD,LPCWSTR*);
NTDSAPI DWORD WINAPI DsClientMakeSpnForTargetServerW(LPCWSTR,LPCWSTR,DWORD*,LPWSTR);
NTDSAPI DWORD WINAPI DsClientMakeSpnForTargetServerA(LPCSTR,LPCSTR,DWORD*,LPSTR);
NTDSAPI DWORD WINAPI DsServerRegisterSpnA(DS_SPN_WRITE_OP,LPCSTR,LPCSTR);
NTDSAPI DWORD WINAPI DsServerRegisterSpnW(DS_SPN_WRITE_OP,LPCWSTR,LPCWSTR);
NTDSAPI DWORD WINAPI DsReplicaSyncA(HANDLE,LPCSTR,const UUID*,ULONG);
NTDSAPI DWORD WINAPI DsReplicaSyncW(HANDLE,LPCWSTR,const UUID*,ULONG);
NTDSAPI DWORD WINAPI DsReplicaAddA(HANDLE,LPCSTR,LPCSTR,LPCSTR,LPCSTR,const PSCHEDULE,DWORD);
NTDSAPI DWORD WINAPI DsReplicaAddW(HANDLE,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,const PSCHEDULE,DWORD);
NTDSAPI DWORD WINAPI DsReplicaDelA(HANDLE,LPCSTR,LPCSTR,ULONG);
NTDSAPI DWORD WINAPI DsReplicaDelW(HANDLE,LPCWSTR,LPCWSTR,ULONG);
NTDSAPI DWORD WINAPI DsReplicaModifyA(HANDLE,LPCSTR,const UUID*,LPCSTR,LPCSTR,const PSCHEDULE,DWORD,DWORD,DWORD);
NTDSAPI DWORD WINAPI DsReplicaModifyW(HANDLE,LPCWSTR,const UUID*,LPCWSTR,LPCWSTR,const PSCHEDULE,DWORD,DWORD,DWORD);
NTDSAPI DWORD WINAPI DsReplicaUpdateRefsA(HANDLE,LPCSTR,LPCSTR,const UUID*,ULONG);
NTDSAPI DWORD WINAPI DsReplicaUpdateRefsW(HANDLE,LPCWSTR,LPCWSTR,const UUID*,ULONG);
NTDSAPI DWORD WINAPI DsReplicaSyncAllA(HANDLE,LPCSTR,ULONG,BOOL(__stdcall *)(LPVOID,PDS_REPSYNCALL_UPDATEA),LPVOID,PDS_REPSYNCALL_ERRINFOA**);
NTDSAPI DWORD WINAPI DsReplicaSyncAllW(HANDLE,LPCWSTR,ULONG,BOOL(__stdcall *)(LPVOID,PDS_REPSYNCALL_UPDATEW),LPVOID,PDS_REPSYNCALL_ERRINFOW**);
NTDSAPI DWORD WINAPI DsRemoveDsServerW(HANDLE,LPWSTR,LPWSTR,BOOL*,BOOL);
NTDSAPI DWORD WINAPI DsRemoveDsServerA(HANDLE,LPSTR,LPSTR,BOOL*,BOOL);
NTDSAPI DWORD WINAPI DsRemoveDsDomainW(HANDLE,LPWSTR);
NTDSAPI DWORD WINAPI DsRemoveDsDomainA(HANDLE,LPSTR);
NTDSAPI DWORD WINAPI DsListSitesA(HANDLE,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListSitesW(HANDLE,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsListServersInSiteA(HANDLE,LPCSTR,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListServersInSiteW(HANDLE,LPCWSTR,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsListDomainsInSiteA(HANDLE,LPCSTR,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListDomainsInSiteW(HANDLE,LPCWSTR,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsListServersForDomainInSiteA(HANDLE,LPCSTR,LPCSTR,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListServersForDomainInSiteW(HANDLE,LPCWSTR,LPCWSTR,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsListInfoForServerA(HANDLE,LPCSTR,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListInfoForServerW(HANDLE,LPCWSTR,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsListRolesA(HANDLE,PDS_NAME_RESULTA*);
NTDSAPI DWORD WINAPI DsListRolesW(HANDLE,PDS_NAME_RESULTW*);
NTDSAPI DWORD WINAPI DsMapSchemaGuidsA(HANDLE,DWORD,GUID*,DS_SCHEMA_GUID_MAPA**);
NTDSAPI VOID WINAPI DsFreeSchemaGuidMapA(PDS_SCHEMA_GUID_MAPA);
NTDSAPI DWORD WINAPI DsMapSchemaGuidsW(HANDLE,DWORD,GUID*,DS_SCHEMA_GUID_MAPW**);
NTDSAPI VOID WINAPI DsFreeSchemaGuidMapW(PDS_SCHEMA_GUID_MAPW);
NTDSAPI DWORD WINAPI DsGetDomainControllerInfoA(HANDLE,LPCSTR,DWORD,DWORD*,VOID**);
NTDSAPI DWORD WINAPI DsGetDomainControllerInfoW(HANDLE,LPCWSTR,DWORD,DWORD*,VOID**);
NTDSAPI VOID WINAPI DsFreeDomainControllerInfoA(DWORD,DWORD,VOID*);
NTDSAPI VOID WINAPI DsFreeDomainControllerInfoW(DWORD,DWORD,VOID*);
NTDSAPI DWORD WINAPI DsReplicaConsistencyCheck(HANDLE,DS_KCC_TASKID,DWORD);
NTDSAPI DWORD WINAPI DsReplicaGetInfoW(HANDLE,DS_REPL_INFO_TYPE,LPCWSTR,UUID*,VOID**);
NTDSAPI void WINAPI DsReplicaFreeInfo(DS_REPL_INFO_TYPE,VOID*);
NTDSAPI DWORD WINAPI DsAddSidHistoryW(HANDLE,DWORD,LPCWSTR,LPCWSTR,LPCWSTR,RPC_AUTH_IDENTITY_HANDLE,LPCWSTR,LPCWSTR);
NTDSAPI DWORD WINAPI DsAddSidHistoryA(HANDLE,DWORD,LPCSTR,LPCSTR,LPCSTR,RPC_AUTH_IDENTITY_HANDLE,LPCSTR,LPCSTR);
NTDSAPI DWORD WINAPI DsInheritSecurityIdentityW(HANDLE,DWORD,LPCWSTR,LPCWSTR);
NTDSAPI DWORD WINAPI DsInheritSecurityIdentityA(HANDLE,DWORD,LPCSTR,LPCSTR);
NTDSAPI DWORD WINAPI DsQuoteRdnValueW(DWORD,LPCWCH,DWORD*,LPWCH);
NTDSAPI DWORD WINAPI DsQuoteRdnValueA(DWORD,LPCCH,DWORD*,LPCH);
NTDSAPI DWORD WINAPI DsUnquoteRdnValueW(DWORD,LPCWCH,DWORD*,LPWCH);
NTDSAPI DWORD WINAPI DsUnquoteRdnValueA(DWORD,LPCCH,DWORD*,LPCH);
#define DsFreePasswordCredentialsW DsFreePasswordCredentials
#define DsFreePasswordCredentialsA DsFreePasswordCredentials

#ifdef UNICODE
#define DS_NAME_RESULT DS_NAME_RESULTW
#define PDS_NAME_RESULT PDS_NAME_RESULTW
#define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMW
#define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMW
#define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCW
#define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOW
#define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEW
#define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCW
#define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOW
#define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEW
#define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPW
#define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPW
#define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1W
#define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2W
#define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1W
#define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2W
#define DS_REPL_NEIGHBOR  DS_REPL_NEIGHBORW
#define DS_REPL_NEIGHBORS  DS_REPL_NEIGHBORSW
#define DS_REPL_KCC_DSA_FAILURES  DS_REPL_KCC_DSA_FAILURESW
#define DS_REPL_KCC_DSA_FAILURE  DS_REPL_KCC_DSA_FAILUREW
#define DS_REPL_OP  DS_REPL_OPW
#define DS_REPL_PENDING_OPS  DS_REPL_PENDING_OPSW
#define DsGetDomainControllerInfo DsGetDomainControllerInfoW
#define DsFreeDomainControllerInfo DsFreeDomainControllerInfoW
#define DsMapSchemaGuids DsMapSchemaGuidsW
#define DsFreeSchemaGuidMap DsFreeSchemaGuidMapW
#define DsBind DsBindW
#define DsBindWithCred DsBindWithCredW
#define DsBindWithSpn DsBindWithSpnW
#define DsUnBind DsUnBindW
#define DsMakePasswordCredentials DsMakePasswordCredentialsW
#define DsCrackNames DsCrackNamesW
#define DsFreeNameResult DsFreeNameResultW
#define DsMakeSpn DsMakeSpnW
#define DsGetSpn DsGetSpnW
#define DsFreeSpnArray DsFreeSpnArrayW
#define DsCrackSpn DsCrackSpnW
#define DsWriteAccountSpn DsWriteAccountSpnW
#define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerW
#define DsServerRegisterSpn DsServerRegisterSpnW
#define DsReplicaSync DsReplicaSyncW
#define DsReplicaAdd DsReplicaAddW
#define DsReplicaDel DsReplicaDelW
#define DsReplicaModify DsReplicaModifyW
#define DsReplicaUpdateRefs DsReplicaUpdateRefsW
#define DsReplicaSyncAll DsReplicaSyncAllW
#define DsRemoveDsServer DsRemoveDsServerW
#define DsRemoveDsDomain DsRemoveDsDomainW
#define DsListSites DsListSitesW
#define DsListServersInSite DsListServersInSiteW
#define DsListDomainsInSite DsListDomainsInSiteW
#define DsListServersForDomainInSite DsListServersForDomainInSiteW
#define DsListInfoForServer DsListInfoForServerW
#define DsListRoles DsListRolesW
#define DsReplicaGetInfo  DsReplicaGetInfoW
#define DsAddSidHistory DsAddSidHistoryW
#define DsInheritSecurityIdentity DsInheritSecurityIdentityW
#define DsQuoteRdnValue DsQuoteRdnValueW
#define DsUnquoteRdnValue DsUnquoteRdnValueW
#else
#define DS_NAME_RESULT DS_NAME_RESULTA
#define PDS_NAME_RESULT PDS_NAME_RESULTA
#define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMA
#define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMA
#define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCA
#define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOA
#define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEA
#define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCA
#define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOA
#define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEA
#define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPA
#define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPA
#define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1A
#define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2A
#define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1A
#define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2A
#define DsGetDomainControllerInfo DsGetDomainControllerInfoA
#define DsFreeDomainControllerInfo DsFreeDomainControllerInfoA
#define DsMapSchemaGuids DsMapSchemaGuidsA
#define DsFreeSchemaGuidMap DsFreeSchemaGuidMapA
#define DsBind DsBindA
#define DsBindWithCred DsBindWithCredA
#define DsBindWithSpn DsBindWithSpnA
#define DsUnBind DsUnBindA
#define DsMakePasswordCredentials DsMakePasswordCredentialsA
#define DsCrackNames DsCrackNamesA
#define DsFreeNameResult DsFreeNameResultA
#define DsMakeSpn DsMakeSpnA
#define DsGetSpn DsGetSpnA
#define DsFreeSpnArray DsFreeSpnArrayA
#define DsCrackSpn DsCrackSpnA
#define DsWriteAccountSpn DsWriteAccountSpnA
#define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerA
#define DsServerRegisterSpn DsServerRegisterSpnA
#define DsReplicaSync DsReplicaSyncA
#define DsReplicaAdd DsReplicaAddA
#define DsReplicaDel DsReplicaDelA
#define DsReplicaModify DsReplicaModifyA
#define DsReplicaUpdateRefs DsReplicaUpdateRefsA
#define DsReplicaSyncAll DsReplicaSyncAllA
#define DsRemoveDsServer DsRemoveDsServerA
#define DsRemoveDsDomain DsRemoveDsDomainA
#define DsListSites DsListSitesA
#define DsListServersInSite DsListServersInSiteA
#define DsListDomainsInSite DsListDomainsInSiteA
#define DsListServersForDomainInSite DsListServersForDomainInSiteA
#define DsListInfoForServer DsListInfoForServerA
#define DsListRoles DsListRolesA
#define DsAddSidHistory DsAddSidHistoryA
#define DsInheritSecurityIdentity DsInheritSecurityIdentityA
#define DsQuoteRdnValue DsQuoteRdnValueA
#define DsUnquoteRdnValue DsUnquoteRdnValueA
#endif /* UNICODE */

#ifdef __cplusplus
}
#endif

#endif /* _NTDSAPI_H */
