' ########################################################################################
' Microsoft Windows
' File: DSRole.inc
' Contents: Public interfaces to query the network roles of workstations, servers, and DCs
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_DSRole_PBI)
#DEFINE PBX_DSRole_PBI
%EQUATE `DSROLE_INC = 1
'//
'// Domain information
'//
' enum DSROLE_MACHINE_ROLE
%EQUATE `DsRole_RoleStandaloneWorkstation = 0
%EQUATE `DsRole_RoleMemberWorkstation = 1
%EQUATE `DsRole_RoleStandaloneServer = 2
%EQUATE `DsRole_RoleMemberServer = 3
%EQUATE `DsRole_RoleBackupDomainController = 4
%EQUATE `DsRole_RolePrimaryDomainController = 5
'//
'// Previous server state
'//
' enum DSROLE_SERVER_STATE {
%EQUATE `DsRoleServerUnknown = 0
%EQUATE `DsRoleServerPrimary = 1
%EQUATE `DsRoleServerBackup = 2
' enum DSROLE_PRIMARY_DOMAIN_INFO_LEVEL {
%EQUATE `DsRolePrimaryDomainInfoBasic = 1
%EQUATE `DsRoleUpgradeStatus = 2
%EQUATE `DsRoleOperationState = 3
'//
'// Flags to be used with the PRIMARY_DOMAIN_INFO_LEVEL structures below
'//
%EQUATE `DSROLE_PRIMARY_DS_RUNNING = &H00000001
%EQUATE `DSROLE_PRIMARY_DS_MIXED_MODE = &H00000002
%EQUATE `DSROLE_UPGRADE_IN_PROGRESS = &H00000004
%EQUATE `DSROLE_PRIMARY_DOMAIN_GUID_PRESENT = &H01000000
'//
'// Structure that correspond to the DSROLE_PRIMARY_DOMAIN_INFO_LEVEL
'//
' // Size = 36 bytes
TYPE DSROLE_PRIMARY_DOMAIN_INFO_BASIC DWORD
 MachineRole AS LONG ' DSROLE_MACHINE_ROLE enum
 Flags AS DWORD ' ULONG
 DomainNameFlat AS WSTRINGZ PTR
 DomainNameDns AS WSTRINGZ PTR
 DomainForestName AS WSTRINGZ PTR
 DomainGuid AS GUID ' GUID
END TYPE
' // Size = 8 bytes
TYPE DSROLE_UPGRADE_STATUS_INFO DWORD
 OperationState AS DWORD ' ULONG
 PreviousServerState AS LONG ' DSROLE_SERVER_STATE enum
END TYPE
' enum DSROLE_OPERATION_STATE {
%EQUATE `DsRoleOperationIdle = 0
%EQUATE `DsRoleOperationActive = 1
%EQUATE `DsRoleOperationNeedReboot = 2
' // Size = 4 bytes
TYPE DSROLE_OPERATION_STATE_INFO DWORD
 OperationState AS LONG ' DSROLE_OPERATION_STATE enum
END TYPE
DECLARE FUNCTION DsRoleGetPrimaryDomainInformation LIB "netapi32.dll" ALIAS "DsRoleGetPrimaryDomainInformation" ( BYREF lpServer AS WSTRINGZ , BYVAL InfoLevel AS LONG , BYREF Buffer AS ANY ) AS QUAD
DECLARE SUB DsRoleFreeMemory LIB "netapi32.dll" ALIAS "DsRoleFreeMemory" ( BYVAL Buffer AS QUAD
 ) ' void
#ENDIF
