#ifndef _DSGETDC_H
#define _DSGETDC_H

/* DsGetDcName API definitions */

#if !defined(_DSGETDCAPI_)
#define DSGETDCAPI  DECLSPEC_IMPORT
#else
#define DSGETDCAPI
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define DS_FORCE_REDISCOVERY  0x00000001
#define DS_DIRECTORY_SERVICE_REQUIRED  0x00000010
#define DS_DIRECTORY_SERVICE_PREFERRED  0x00000020
#define DS_GC_SERVER_REQUIRED  0x00000040
#define DS_PDC_REQUIRED  0x00000080
#define DS_BACKGROUND_ONLY  0x00000100
#define DS_IP_REQUIRED  0x00000200
#define DS_KDC_REQUIRED  0x00000400
#define DS_TIMESERV_REQUIRED  0x00000800
#define DS_WRITABLE_REQUIRED  0x00001000
#define DS_GOOD_TIMESERV_PREFERRED  0x00002000
#define DS_AVOID_SELF  0x00004000
#define DS_ONLY_LDAP_NEEDED  0x00008000
#define DS_IS_FLAT_NAME  0x00010000
#define DS_IS_DNS_NAME  0x00020000
#define DS_RETURN_DNS_NAME  0x40000000
#define DS_RETURN_FLAT_NAME  0x80000000
#define DSGETDC_VALID_FLAGS  (DS_FORCE_REDISCOVERY|DS_DIRECTORY_SERVICE_REQUIRED|DS_DIRECTORY_SERVICE_PREFERRED|DS_GC_SERVER_REQUIRED|DS_PDC_REQUIRED|DS_BACKGROUND_ONLY|DS_IP_REQUIRED|DS_KDC_REQUIRED|DS_TIMESERV_REQUIRED|DS_WRITABLE_REQUIRED|DS_GOOD_TIMESERV_PREFERRED|DS_AVOID_SELF|DS_ONLY_LDAP_NEEDED|DS_IS_FLAT_NAME|DS_IS_DNS_NAME|DS_RETURN_FLAT_NAME|DS_RETURN_DNS_NAME)

#define DS_INET_ADDRESS  1
#define DS_NETBIOS_ADDRESS 2

#define DS_PDC_FLAG  0x00000001
#define DS_GC_FLAG  0x00000004
#define DS_LDAP_FLAG  0x00000008
#define DS_DS_FLAG  0x00000010
#define DS_KDC_FLAG  0x00000020
#define DS_TIMESERV_FLAG  0x00000040
#define DS_CLOSEST_FLAG  0x00000080
#define DS_WRITABLE_FLAG  0x00000100
#define DS_GOOD_TIMESERV_FLAG  0x00000200
#define DS_PING_FLAGS  0x0000FFFF

#define DS_DNS_CONTROLLER_FLAG 0x20000000
#define DS_DNS_DOMAIN_FLAG  0x40000000
#define DS_DNS_FOREST_FLAG  0x80000000

#define DS_DOMAIN_IN_FOREST  0x0001
#define DS_DOMAIN_DIRECT_OUTBOUND  0x0002
#define DS_DOMAIN_TREE_ROOT  0x0004
#define DS_DOMAIN_PRIMARY  0x0008
#define DS_DOMAIN_NATIVE_MODE  0x0010
#define DS_DOMAIN_DIRECT_INBOUND  0x0020
#define DS_DOMAIN_VALID_FLAGS  (DS_DOMAIN_IN_FOREST|DS_DOMAIN_DIRECT_OUTBOUND|DS_DOMAIN_TREE_ROOT|DS_DOMAIN_PRIMARY|DS_DOMAIN_NATIVE_MODE|DS_DOMAIN_DIRECT_INBOUND)

typedef struct _DOMAIN_CONTROLLER_INFOA {
    LPSTR DomainControllerName;
    LPSTR DomainControllerAddress;
    ULONG DomainControllerAddressType;
    GUID DomainGuid;
    LPSTR DomainName;
    LPSTR DnsForestName;
    ULONG Flags;
    LPSTR DcSiteName;
    LPSTR ClientSiteName;
} DOMAIN_CONTROLLER_INFOA, *PDOMAIN_CONTROLLER_INFOA;

typedef struct _DOMAIN_CONTROLLER_INFOW {
    LPWSTR DomainControllerName;
    LPWSTR DomainControllerAddress;
    ULONG DomainControllerAddressType;
    GUID DomainGuid;
    LPWSTR DomainName;
    LPWSTR DnsForestName;
    ULONG Flags;
    LPWSTR DcSiteName;
    LPWSTR ClientSiteName;
} DOMAIN_CONTROLLER_INFOW, *PDOMAIN_CONTROLLER_INFOW;

typedef struct _DS_DOMAIN_TRUSTSW {
    LPWSTR NetbiosDomainName;
    LPWSTR DnsDomainName;
    ULONG Flags;
    ULONG ParentIndex;
    ULONG TrustType;
    ULONG TrustAttributes;
    PSID DomainSid;
    GUID DomainGuid;
} DS_DOMAIN_TRUSTSW, *PDS_DOMAIN_TRUSTSW;

typedef struct _DS_DOMAIN_TRUSTSA {
    LPSTR NetbiosDomainName;
    LPSTR DnsDomainName;
    ULONG Flags;
    ULONG ParentIndex;
    ULONG TrustType;
    ULONG TrustAttributes;
    PSID DomainSid;
    GUID DomainGuid;
} DS_DOMAIN_TRUSTSA, *PDS_DOMAIN_TRUSTSA;

DSGETDCAPI DWORD WINAPI DsGetDcNameA(LPCSTR,LPCSTR,GUID*,LPCSTR,ULONG,PDOMAIN_CONTROLLER_INFOA*);
DSGETDCAPI DWORD WINAPI DsGetDcNameW(LPCWSTR,LPCWSTR,GUID*,LPCWSTR,ULONG,PDOMAIN_CONTROLLER_INFOW*);
DSGETDCAPI DWORD WINAPI DsGetSiteNameA(LPCSTR,LPSTR*);
DSGETDCAPI DWORD WINAPI DsGetSiteNameW(LPCWSTR,LPWSTR*);
DSGETDCAPI DWORD WINAPI DsValidateSubnetNameW(LPCWSTR);
DSGETDCAPI DWORD WINAPI DsValidateSubnetNameA(LPCSTR);
#ifdef _WINSOCK2_H
DSGETDCAPI DWORD WINAPI DsAddressToSiteNamesW(LPCWSTR,DWORD,PSOCKET_ADDRESS,LPWSTR**);
DSGETDCAPI DWORD WINAPI DsAddressToSiteNamesA(LPCSTR,DWORD,PSOCKET_ADDRESS,LPSTR**);
DSGETDCAPI DWORD WINAPI DsAddressToSiteNamesExW(LPCWSTR,DWORD,PSOCKET_ADDRESS,LPWSTR**,LPWSTR**);
DSGETDCAPI DWORD WINAPI DsAddressToSiteNamesExA(LPCSTR,DWORD,PSOCKET_ADDRESS,LPSTR**,LPSTR**);
#endif /* _WINSOCK2_H */
DSGETDCAPI DWORD WINAPI DsEnumerateDomainTrustsW(LPWSTR,ULONG,PDS_DOMAIN_TRUSTSW*,PULONG);
DSGETDCAPI DWORD WINAPI DsEnumerateDomainTrustsA(LPSTR,ULONG,PDS_DOMAIN_TRUSTSA*,PULONG);
DSGETDCAPI DWORD WINAPI DsGetDcSiteCoverageW(LPCWSTR,PULONG,LPWSTR**);
DSGETDCAPI DWORD WINAPI DsGetDcSiteCoverageA(LPCSTR,PULONG,LPSTR**);
DSGETDCAPI DWORD WINAPI DsDeregisterDnsHostRecordsW(LPWSTR,LPWSTR,GUID*,GUID*,LPWSTR);
DSGETDCAPI DWORD WINAPI DsDeregisterDnsHostRecordsA(LPSTR,LPSTR,GUID*,GUID*,LPSTR);

#ifdef UNICODE
#define DOMAIN_CONTROLLER_INFO DOMAIN_CONTROLLER_INFOW
#define PDOMAIN_CONTROLLER_INFO PDOMAIN_CONTROLLER_INFOW
#define DS_DOMAIN_TRUSTS DS_DOMAIN_TRUSTSW
#define PDS_DOMAIN_TRUSTS PDS_DOMAIN_TRUSTSW
#define DsGetDcName DsGetDcNameW
#define DsGetSiteName DsGetSiteNameW
#define DsValidateSubnetName DsValidateSubnetNameW
#define DsAddressToSiteNames DsAddressToSiteNamesW
#define DsAddressToSiteNamesEx DsAddressToSiteNamesExW
#define DsEnumerateDomainTrusts DsEnumerateDomainTrustsW
#define DsGetDcSiteCoverage DsGetDcSiteCoverageW
#define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsW
#else
#define DOMAIN_CONTROLLER_INFO DOMAIN_CONTROLLER_INFOA
#define PDOMAIN_CONTROLLER_INFO PDOMAIN_CONTROLLER_INFOA
#define DS_DOMAIN_TRUSTS DS_DOMAIN_TRUSTSA
#define PDS_DOMAIN_TRUSTS PDS_DOMAIN_TRUSTSA
#define DsGetDcName DsGetDcNameA
#define DsGetSiteName DsGetSiteNameA
#define DsValidateSubnetName DsValidateSubnetNameA
#define DsAddressToSiteNames DsAddressToSiteNamesA
#define DsAddressToSiteNamesEx DsAddressToSiteNamesExA
#define DsEnumerateDomainTrusts DsEnumerateDomainTrustsA
#define DsGetDcSiteCoverage DsGetDcSiteCoverageA
#define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsA
#endif /* UNICODE */

#ifdef __cplusplus
}
#endif

#endif /* _DSGETDC_H */
