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 
43 // $Id: JwaDSRole.pas,v 1.11 2007/09/14 06:48:45 marquardt Exp $
44 {$IFNDEF JWA_OMIT_SECTIONS}
45 unit JwaDSRole;
46 
47 {$WEAKPACKAGEUNIT}
48 {$ENDIF JWA_OMIT_SECTIONS}
49 
50 {$HPPEMIT ''}
51 {$HPPEMIT '#include "dsrole.h"'}
52 {$HPPEMIT ''}
53 
54 {$IFNDEF JWA_OMIT_SECTIONS}
55 {$I jediapilib.inc}
56 
57 interface
58 
59 uses
60   JwaWinType;
61 {$ENDIF JWA_OMIT_SECTIONS}
62 
63 {$IFNDEF JWA_IMPLEMENTATIONSECTION}
64 
65 //
66 // Domain information
67 //
68 
69 type
70   _DSROLE_MACHINE_ROLE = (
71     DsRole_RoleStandaloneWorkstation,
72     DsRole_RoleMemberWorkstation,
73     DsRole_RoleStandaloneServer,
74     DsRole_RoleMemberServer,
75     DsRole_RoleBackupDomainController,
76     DsRole_RolePrimaryDomainController);
77   {$EXTERNALSYM _DSROLE_MACHINE_ROLE}
78   DSROLE_MACHINE_ROLE = _DSROLE_MACHINE_ROLE;
79   {$EXTERNALSYM DSROLE_MACHINE_ROLE}
80   TDsRoleMachineRole = DSROLE_MACHINE_ROLE;
81 
82 //
83 // Previous server state
84 //
85 
86   _DSROLE_SERVER_STATE = (
87     DsRoleServerUnknown,
88     DsRoleServerPrimary,
89     DsRoleServerBackup);
90   {$EXTERNALSYM DSROLE_SERVER_STATE}
91   DSROLE_SERVER_STATE = _DSROLE_SERVER_STATE;
92   {$EXTERNALSYM DSROLE_SERVER_STATE}
93   PDSROLE_SERVER_STATE = ^DSROLE_SERVER_STATE;
94   {$EXTERNALSYM PDSROLE_SERVER_STATE}
95   TDsRoleServerState = DSROLE_SERVER_STATE;
96 
97   _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL = (
98     DsRoleFiller0,
99     DsRolePrimaryDomainInfoBasic,
100     DsRoleUpgradeStatus,
101     DsRoleOperationState);
102   {$EXTERNALSYM _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL}
103   DSROLE_PRIMARY_DOMAIN_INFO_LEVEL = _DSROLE_PRIMARY_DOMAIN_INFO_LEVEL;
104   {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_INFO_LEVEL}
105   TDsRolePrimaryDomainInfoLevel = DSROLE_PRIMARY_DOMAIN_INFO_LEVEL;
106 
107 //
108 // Flags to be used with the PRIMARY_DOMAIN_INFO_LEVEL structures below
109 //
110 
111 const
112   DSROLE_PRIMARY_DS_RUNNING          = $00000001;
113   {$EXTERNALSYM DSROLE_PRIMARY_DS_RUNNING}
114   DSROLE_PRIMARY_DS_MIXED_MODE       = $00000002;
115   {$EXTERNALSYM DSROLE_PRIMARY_DS_MIXED_MODE}
116   DSROLE_UPGRADE_IN_PROGRESS         = $00000004;
117   {$EXTERNALSYM DSROLE_UPGRADE_IN_PROGRESS}
118   DSROLE_PRIMARY_DOMAIN_GUID_PRESENT = $01000000;
119   {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_GUID_PRESENT}
120 
121 //
122 // Structure that correspond to the DSROLE_PRIMARY_DOMAIN_INFO_LEVEL
123 //
124 
125 type
126   PDSROLE_PRIMARY_DOMAIN_INFO_BASIC = ^DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
127   {$EXTERNALSYM PDSROLE_PRIMARY_DOMAIN_INFO_BASIC}
128   _DSROLE_PRIMARY_DOMAIN_INFO_BASIC = record
129     MachineRole: DSROLE_MACHINE_ROLE;
130     Flags: ULONG;
131     DomainNameFlat: LPWSTR;
132     DomainNameDns: LPWSTR;
133     DomainForestName: LPWSTR;
134     DomainGuid: GUID;
135   end;
136   {$EXTERNALSYM _DSROLE_PRIMARY_DOMAIN_INFO_BASIC}
137   DSROLE_PRIMARY_DOMAIN_INFO_BASIC = _DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
138   {$EXTERNALSYM DSROLE_PRIMARY_DOMAIN_INFO_BASIC}
139   TDsRolePrimaryDomainInfoBasic = DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
140   PDsRolePrimaryDomainInfoBasic = PDSROLE_PRIMARY_DOMAIN_INFO_BASIC;
141 
142   PDSROLE_UPGRADE_STATUS_INFO = ^DSROLE_UPGRADE_STATUS_INFO;
143   {$EXTERNALSYM PDSROLE_UPGRADE_STATUS_INFO}
144   _DSROLE_UPGRADE_STATUS_INFO = record
145     OperationState: ULONG;
146     PreviousServerState: DSROLE_SERVER_STATE;
147   end;
148   {$EXTERNALSYM _DSROLE_UPGRADE_STATUS_INFO}
149   DSROLE_UPGRADE_STATUS_INFO = _DSROLE_UPGRADE_STATUS_INFO;
150   {$EXTERNALSYM DSROLE_UPGRADE_STATUS_INFO}
151   TDsRoleUpgradeStatusInfo = DSROLE_UPGRADE_STATUS_INFO;
152   PDsRoleUpgradeStatusInfo = PDSROLE_UPGRADE_STATUS_INFO;
153 
154   _DSROLE_OPERATION_STATE = (
155     DsRoleOperationIdle,
156     DsRoleOperationActive,
157     DsRoleOperationNeedReboot);
158   {$EXTERNALSYM _DSROLE_OPERATION_STATE}
159   DSROLE_OPERATION_STATE = _DSROLE_OPERATION_STATE;
160   {$EXTERNALSYM DSROLE_OPERATION_STATE}
161   TDsRoleOperationState = DSROLE_OPERATION_STATE;
162 
163   PDSROLE_OPERATION_STATE_INFO = ^DSROLE_OPERATION_STATE_INFO;
164   {$EXTERNALSYM PDSROLE_OPERATION_STATE_INFO}
165   _DSROLE_OPERATION_STATE_INFO = record
166     OperationState: DSROLE_OPERATION_STATE;
167   end;
168   {$EXTERNALSYM _DSROLE_OPERATION_STATE_INFO}
169   DSROLE_OPERATION_STATE_INFO = _DSROLE_OPERATION_STATE_INFO;
170   {$EXTERNALSYM DSROLE_OPERATION_STATE_INFO}
171   TDsRoleOperationStateInfo = DSROLE_OPERATION_STATE_INFO;
172   PDsRoleOperationStateInfo = PDSROLE_OPERATION_STATE_INFO;
173 
DsRoleGetPrimaryDomainInformationnull174 function DsRoleGetPrimaryDomainInformation(lpServer: LPCWSTR;
175   InfoLevel: DSROLE_PRIMARY_DOMAIN_INFO_LEVEL; var Buffer: PVOID): DWORD; stdcall;
176 {$EXTERNALSYM DsRoleGetPrimaryDomainInformation}
177 
178 procedure DsRoleFreeMemory(Buffer: PVOID); stdcall;
179 {$EXTERNALSYM DsRoleFreeMemory}
180 
181 {$ENDIF JWA_IMPLEMENTATIONSECTION}
182 
183 {$IFNDEF JWA_OMIT_SECTIONS}
184 implementation
185 //uses ...
186 {$ENDIF JWA_OMIT_SECTIONS}
187 
188 {$IFNDEF JWA_INTERFACESECTION}
189 
190 {$IFNDEF JWA_INCLUDEMODE}
191 const
192   netapi32 = 'netapi32.dll';
193 {$ENDIF JWA_INCLUDEMODE}
194 
195 {$IFDEF DYNAMIC_LINK}
196 
197 var
198   _DsRoleGetPrimaryDomainInfo: Pointer;
199 
DsRoleGetPrimaryDomainInformationnull200 function DsRoleGetPrimaryDomainInformation;
201 begin
202   GetProcedureAddress(_DsRoleGetPrimaryDomainInfo, netapi32, 'DsRoleGetPrimaryDomainInformation');
203   asm
204         MOV     ESP, EBP
205         POP     EBP
206         JMP     [_DsRoleGetPrimaryDomainInfo]
207   end;
208 end;
209 
210 var
211   _DsRoleFreeMemory: Pointer;
212 
213 procedure DsRoleFreeMemory;
214 begin
215   GetProcedureAddress(_DsRoleFreeMemory, netapi32, 'DsRoleFreeMemory');
216   asm
217         MOV     ESP, EBP
218         POP     EBP
219         JMP     [_DsRoleFreeMemory]
220   end;
221 end;
222 
223 {$ELSE}
224 
DsRoleGetPrimaryDomainInformationnull225 function DsRoleGetPrimaryDomainInformation; external netapi32 name 'DsRoleGetPrimaryDomainInformation';
226 procedure DsRoleFreeMemory; external netapi32 name 'DsRoleFreeMemory';
227 
228 {$ENDIF DYNAMIC_LINK}
229 
230 {$ENDIF JWA_INTERFACESECTION}
231 
232 {$IFNDEF JWA_OMIT_SECTIONS}
233 end.
234 {$ENDIF JWA_OMIT_SECTIONS}
235