jwadsrole.pas 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. {******************************************************************************}
  2. { }
  3. { Directory Services API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: dsrole.h, released June 2000. The original Pascal }
  9. { code is: DsRole.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaDSRole.pas,v 1.8 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaDSRole;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "dsrole.h"'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows;
  52. //
  53. // Domain information
  54. //
  55. type
  56. _DSROLE_MACHINE_ROLE = (
  57. DsRole_RoleStandaloneWorkstation,
  58. DsRole_RoleMemberWorkstation,
  59. DsRole_RoleStandaloneServer,
  60. DsRole_RoleMemberServer,
  61. DsRole_RoleBackupDomainController,
  62. DsRole_RolePrimaryDomainController);
  63. {$EXTERNALSYM _DSROLE_MACHINE_ROLE}
  64. DSROLE_MACHINE_ROLE = _DSROLE_MACHINE_ROLE;
  65. {$EXTERNALSYM DSROLE_MACHINE_ROLE}
  66. TDsRoleMachineRole = DSROLE_MACHINE_ROLE;
  67. //
  68. // Previous server state
  69. //
  70. _DSROLE_SERVER_STATE = (
  71. DsRoleServerUnknown,
  72. DsRoleServerPrimary,
  73. DsRoleServerBackup);
  74. {$EXTERNALSYM DSROLE_SERVER_STATE}
  75. DSROLE_SERVER_STATE = _DSROLE_SERVER_STATE;
  76. {$EXTERNALSYM DSROLE_SERVER_STATE}
  77. PDSROLE_SERVER_STATE = ^DSROLE_SERVER_STATE;
  78. {$EXTERNALSYM PDSROLE_SERVER_STATE}
  79. TDsRoleServerState = DSROLE_SERVER_STATE;
  80. _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL = (
  81. DsRoleFiller0,
  82. DsRolePrimaryDomainInfoBasic,
  83. DsRoleUpgradeStatus,
  84. DsRoleOperationState);
  85. {$EXTERNALSYM _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL}
  86. DSROLE_PRIMARY_DOMAIN_INFO_LEVEL = _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL;
  87. {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_INFO_LEVEL}
  88. TDsRolePrimaryDomainInfoLevel = DSROLE_PRIMARY_DOMAIN_INFO_LEVEL;
  89. //
  90. // Flags to be used with the PRIMARY_DOMAIN_INFO_LEVEL structures below
  91. //
  92. const
  93. DSROLE_PRIMARY_DS_RUNNING = $00000001;
  94. {$EXTERNALSYM DSROLE_PRIMARY_DS_RUNNING}
  95. DSROLE_PRIMARY_DS_MIXED_MODE = $00000002;
  96. {$EXTERNALSYM DSROLE_PRIMARY_DS_MIXED_MODE}
  97. DSROLE_UPGRADE_IN_PROGRESS = $00000004;
  98. {$EXTERNALSYM DSROLE_UPGRADE_IN_PROGRESS}
  99. DSROLE_PRIMARY_DOMAIN_GUID_PRESENT = $01000000;
  100. {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_GUID_PRESENT}
  101. //
  102. // Structure that correspond to the DSROLE_PRIMARY_DOMAIN_INFO_LEVEL
  103. //
  104. type
  105. PDSROLE_PRIMARY_DOMAIN_INFO_BASIC = ^DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
  106. {$EXTERNALSYM PDSROLE_PRIMARY_DOMAIN_INFO_BASIC}
  107. _DSROLE_PRIMARY_DOMAIN_INFO_BASIC = record
  108. MachineRole: DSROLE_MACHINE_ROLE;
  109. Flags: ULONG;
  110. DomainNameFlat: LPWSTR;
  111. DomainNameDns: LPWSTR;
  112. DomainForestName: LPWSTR;
  113. DomainGuid: GUID;
  114. end;
  115. {$EXTERNALSYM _DSROLE_PRIMARY_DOMAIN_INFO_BASIC}
  116. DSROLE_PRIMARY_DOMAIN_INFO_BASIC = _DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
  117. {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_INFO_BASIC}
  118. TDsRolePrimaryDomainInfoBasic = DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
  119. PDsRolePrimaryDomainInfoBasic = PDSROLE_PRIMARY_DOMAIN_INFO_BASIC;
  120. PDSROLE_UPGRADE_STATUS_INFO = ^DSROLE_UPGRADE_STATUS_INFO;
  121. {$EXTERNALSYM PDSROLE_UPGRADE_STATUS_INFO}
  122. _DSROLE_UPGRADE_STATUS_INFO = record
  123. OperationState: ULONG;
  124. PreviousServerState: DSROLE_SERVER_STATE;
  125. end;
  126. {$EXTERNALSYM _DSROLE_UPGRADE_STATUS_INFO}
  127. DSROLE_UPGRADE_STATUS_INFO = _DSROLE_UPGRADE_STATUS_INFO;
  128. {$EXTERNALSYM DSROLE_UPGRADE_STATUS_INFO}
  129. TDsRoleUpgradeStatusInfo = DSROLE_UPGRADE_STATUS_INFO;
  130. PDsRoleUpgradeStatusInfo = PDSROLE_UPGRADE_STATUS_INFO;
  131. _DSROLE_OPERATION_STATE = (
  132. DsRoleOperationIdle,
  133. DsRoleOperationActive,
  134. DsRoleOperationNeedReboot);
  135. {$EXTERNALSYM _DSROLE_OPERATION_STATE}
  136. DSROLE_OPERATION_STATE = _DSROLE_OPERATION_STATE;
  137. {$EXTERNALSYM DSROLE_OPERATION_STATE}
  138. TDsRoleOperationState = DSROLE_OPERATION_STATE;
  139. PDSROLE_OPERATION_STATE_INFO = ^DSROLE_OPERATION_STATE_INFO;
  140. {$EXTERNALSYM PDSROLE_OPERATION_STATE_INFO}
  141. _DSROLE_OPERATION_STATE_INFO = record
  142. OperationState: DSROLE_OPERATION_STATE;
  143. end;
  144. {$EXTERNALSYM _DSROLE_OPERATION_STATE_INFO}
  145. DSROLE_OPERATION_STATE_INFO = _DSROLE_OPERATION_STATE_INFO;
  146. {$EXTERNALSYM DSROLE_OPERATION_STATE_INFO}
  147. TDsRoleOperationStateInfo = DSROLE_OPERATION_STATE_INFO;
  148. PDsRoleOperationStateInfo = PDSROLE_OPERATION_STATE_INFO;
  149. function DsRoleGetPrimaryDomainInformation(lpServer: LPCWSTR;
  150. InfoLevel: DSROLE_PRIMARY_DOMAIN_INFO_LEVEL; var Buffer: PVOID): DWORD; stdcall;
  151. {$EXTERNALSYM DsRoleGetPrimaryDomainInformation}
  152. procedure DsRoleFreeMemory(Buffer: PVOID); stdcall;
  153. {$EXTERNALSYM DsRoleFreeMemory}
  154. implementation
  155. uses
  156. JwaWinDLLNames;
  157. {$IFDEF DYNAMIC_LINK}
  158. var
  159. _DsRoleGetPrimaryDomainInfo: Pointer;
  160. function DsRoleGetPrimaryDomainInformation;
  161. begin
  162. GetProcedureAddress(_DsRoleGetPrimaryDomainInfo, netapi32, 'DsRoleGetPrimaryDomainInformation');
  163. asm
  164. MOV ESP, EBP
  165. POP EBP
  166. JMP [_DsRoleGetPrimaryDomainInfo]
  167. end;
  168. end;
  169. var
  170. _DsRoleFreeMemory: Pointer;
  171. procedure DsRoleFreeMemory;
  172. begin
  173. GetProcedureAddress(_DsRoleFreeMemory, netapi32, 'DsRoleFreeMemory');
  174. asm
  175. MOV ESP, EBP
  176. POP EBP
  177. JMP [_DsRoleFreeMemory]
  178. end;
  179. end;
  180. {$ELSE}
  181. function DsRoleGetPrimaryDomainInformation; external netapi32 name 'DsRoleGetPrimaryDomainInformation';
  182. procedure DsRoleFreeMemory; external netapi32 name 'DsRoleFreeMemory';
  183. {$ENDIF DYNAMIC_LINK}
  184. end.