1
{******************************************************************************}
3
{ Active Directory Helper Functions API interface Unit for Object Pascal }
5
{ Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
6
{ Corporation. All Rights Reserved. }
8
{ The original file is: adshlp.h, released June 2000. The original Pascal }
9
{ code is: AdsHlp.pas, released December 2000. The initial developer of the }
10
{ Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
12
{ Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
13
{ Marcel van Brakel. All Rights Reserved. }
15
{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
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 }
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 }
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. }
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. }
39
{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
41
{******************************************************************************}
43
// $Id: jwaadshlp.pas,v 1.1 2005/04/04 07:56:10 marco Exp $
50
{$HPPEMIT '#include "adshlp.h"'}
58
ActiveX {TODO}, JwaAdsTLB, JwaWinType, JwaWinNT;
60
function ADsGetObject(lpszPathName: LPCWSTR; const riid: TGUID; out ppObject: Pointer): HRESULT; stdcall;
61
{$EXTERNALSYM ADsGetObject}
63
function ADsBuildEnumerator(pADsContainer: IADsContainer; out ppEnumVariant: IEnumVARIANT): HRESULT; stdcall;
64
{$EXTERNALSYM ADsBuildEnumerator}
66
function ADsFreeEnumerator(pEnumVariant: IEnumVARIANT): HRESULT; stdcall;
67
{$EXTERNALSYM ADsFreeEnumerator}
69
function ADsEnumerateNext(pEnumVariant: IEnumVARIANT; cElements: ULONG;
70
var pvar: OleVariant; var pcElementsFetched: ULONG): HRESULT; stdcall;
71
{$EXTERNALSYM ADsEnumerateNext}
73
function ADsBuildVarArrayStr(lppPathNames: LPWSTR; dwPathNames: DWORD;
74
var pVar: OleVariant): HRESULT; stdcall;
75
{$EXTERNALSYM ADsBuildVarArrayStr}
77
function ADsBuildVarArrayInt(lpdwObjectTypes: LPDWORD; dwObjectTypes: DWORD;
78
var pVar: OleVariant): HRESULT; stdcall;
79
{$EXTERNALSYM ADsBuildVarArrayInt}
81
function ADsOpenObject(lpszPathName, lpszUserName, lpszPassword: LPCWSTR;
82
dwReserved: DWORD; const riid: TGUID; out ppObject: Pointer): HRESULT; stdcall;
83
{$EXTERNALSYM ADsOpenObject}
86
// Helper functions for extended error support
89
function ADsGetLastError(var lpError: DWORD; lpErrorBuf: LPWSTR;
90
dwErrorBufLen: DWORD; lpNameBuf: LPWSTR; dwNameBufLen: DWORD): HRESULT; stdcall;
91
{$EXTERNALSYM ADsGetLastError}
93
procedure ADsSetLastError(dwErr: DWORD; pszError, pszProvider: LPCWSTR); stdcall;
94
{$EXTERNALSYM ADsSetLastError}
96
//procedure ADsFreeAllErrorRecords; stdcall;
97
//{$EXTERNALSYM ADsFreeAllErrorRecords}
99
function AllocADsMem(cb: DWORD): LPVOID; stdcall;
100
{$EXTERNALSYM AllocADsMem}
102
function FreeADsMem(pMem: LPVOID): BOOL; stdcall;
103
{$EXTERNALSYM FreeADsMem}
105
function ReallocADsMem(pOldMem: LPVOID; cbOld, cbNew: DWORD): LPVOID; stdcall;
106
{$EXTERNALSYM ReallocADsMem}
108
function AllocADsStr(pStr: LPCWSTR): LPWSTR; stdcall;
109
{$EXTERNALSYM AllocADsStr}
111
function FreeADsStr(pStr: LPWSTR): BOOL; stdcall;
112
{$EXTERNALSYM FreeADsStr}
114
function ReallocADsStr(var ppStr: LPWSTR; pStr: LPWSTR): BOOL; stdcall;
115
{$EXTERNALSYM ReallocADsStr}
117
function ADsEncodeBinaryData(pbSrcData: PBYTE; dwSrcLen: DWORD;
118
var ppszDestData: LPWSTR): HRESULT; stdcall;
119
{$EXTERNALSYM ADsEncodeBinaryData}
121
function ADsDecodeBinaryData(szSrcData: LPCWSTR; var ppbDestData: PBYTE;
122
var pdwDestLen: ULONG): HRESULT; stdcall;
123
{$EXTERNALSYM ADsDecodeBinaryData}
126
// imports of a type library sometimes are missing a few decls, these are just
127
// a few of them to make this file compile at all. I really should do all of
130
PADSVALUE = ^_adsvalue;
131
{$EXTERNALSYM PADSVALUE}
132
PADS_ATTR_INFO = ^_ads_attr_info;
133
{$EXTERNALSYM PADS_ATTR_INFO}
135
function PropVariantToAdsType(var pVariant: OleVariant; dwNumVariant: DWORD;
136
var ppAdsValues: PADSVALUE; pdwNumValues: PDWORD): HRESULT; stdcall;
137
{$EXTERNALSYM PropVariantToAdsType}
139
function AdsTypeToPropVariant(pAdsValues: PADSVALUE; dwNumValues: DWORD;
140
var pVariant: OleVariant): HRESULT; stdcall;
141
{$EXTERNALSYM AdsTypeToPropVariant}
143
procedure AdsFreeAdsValues(pAdsValues: PADSVALUE; dwNumValues: DWORD); stdcall;
144
{$EXTERNALSYM AdsFreeAdsValues}
147
// Helper routines to convert IADsSecurityDescriptor to a binary
148
// security descriptor and also to convert a binary SD to
149
// IADsSecurityDescriptor.
154
function BinarySDToSecurityDescriptor(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
155
var pVarsec: VARIANT; pszServerName, userName, passWord: LPCWSTR; dwFlags: DWORD): HRESULT; stdcall;
156
{$EXTERNALSYM BinarySDToSecurityDescriptor}
158
function SecurityDescriptorToBinarySD(vVarSecDes: VARIANT;
159
var ppSecurityDescriptor: PSECURITY_DESCRIPTOR; pdwSDLength: PDWORD;
160
pszServerName, userName, passWord: LPCWSTR; dwFlags: DWORD): HRESULT; stdcall;
161
{$EXTERNALSYM SecurityDescriptorToBinarySD}
166
adslib = 'activeds.dll';
168
//procedure ADsFreeAllErrorRecords
170
{$IFDEF DYNAMIC_LINK}
173
_ADsGetObject: Pointer;
175
function ADsGetObject;
177
GetProcedureAddress(_ADsGetObject, adslib, 'ADsGetObject');
186
_ADsBuildEnumerator: Pointer;
188
function ADsBuildEnumerator;
190
GetProcedureAddress(_ADsBuildEnumerator, adslib, 'ADsBuildEnumerator');
194
JMP [_ADsBuildEnumerator]
199
_ADsFreeEnumerator: Pointer;
201
function ADsFreeEnumerator;
203
GetProcedureAddress(_ADsFreeEnumerator, adslib, 'ADsFreeEnumerator');
207
JMP [_ADsFreeEnumerator]
212
_ADsEnumerateNext: Pointer;
214
function ADsEnumerateNext;
216
GetProcedureAddress(_ADsEnumerateNext, adslib, 'ADsEnumerateNext');
220
JMP [_ADsEnumerateNext]
225
_ADsBuildVarArrayStr: Pointer;
227
function ADsBuildVarArrayStr;
229
GetProcedureAddress(_ADsBuildVarArrayStr, adslib, 'ADsBuildVarArrayStr');
233
JMP [_ADsBuildVarArrayStr]
238
_ADsBuildVarArrayInt: Pointer;
240
function ADsBuildVarArrayInt;
242
GetProcedureAddress(_ADsBuildVarArrayInt, adslib, 'ADsBuildVarArrayInt');
246
JMP [_ADsBuildVarArrayInt]
251
_ADsOpenObject: Pointer;
253
function ADsOpenObject;
255
GetProcedureAddress(_ADsOpenObject, adslib, 'ADsOpenObject');
264
_ADsGetLastError: Pointer;
266
function ADsGetLastError;
268
GetProcedureAddress(_ADsGetLastError, adslib, 'ADsGetLastError');
272
JMP [_ADsGetLastError]
277
_ADsSetLastError: Pointer;
279
procedure ADsSetLastError;
281
GetProcedureAddress(_ADsSetLastError, adslib, 'ADsSetLastError');
285
JMP [_ADsSetLastError]
290
_AllocADsMem: Pointer;
292
function AllocADsMem;
294
GetProcedureAddress(_AllocADsMem, adslib, 'AllocADsMem');
303
_FreeADsMem: Pointer;
307
GetProcedureAddress(_FreeADsMem, adslib, 'FreeADsMem');
316
_ReallocADsMem: Pointer;
318
function ReallocADsMem;
320
GetProcedureAddress(_ReallocADsMem, adslib, 'ReallocADsMem');
329
_AllocADsStr: Pointer;
331
function AllocADsStr;
333
GetProcedureAddress(_AllocADsStr, adslib, 'AllocADsStr');
342
_FreeADsStr: Pointer;
346
GetProcedureAddress(_FreeADsStr, adslib, 'FreeADsStr');
355
_ReallocADsStr: Pointer;
357
function ReallocADsStr;
359
GetProcedureAddress(_ReallocADsStr, adslib, 'ReallocADsStr');
368
_ADsEncodeBinaryData: Pointer;
370
function ADsEncodeBinaryData;
372
GetProcedureAddress(_ADsEncodeBinaryData, adslib, 'ADsEncodeBinaryData');
376
JMP [_ADsEncodeBinaryData]
381
_ADsDecodeBinaryData: Pointer;
383
function ADsDecodeBinaryData;
385
GetProcedureAddress(_ADsDecodeBinaryData, adslib, 'ADsDecodeBinaryData');
389
JMP [_ADsDecodeBinaryData]
394
_PropVariantToAdsType: Pointer;
396
function PropVariantToAdsType;
398
GetProcedureAddress(_PropVariantToAdsType, adslib, 'PropVariantToAdsType');
402
JMP [_PropVariantToAdsType]
407
_AdsTypeToPropVariant: Pointer;
409
function AdsTypeToPropVariant;
411
GetProcedureAddress(_AdsTypeToPropVariant, adslib, 'AdsTypeToPropVariant');
415
JMP [_AdsTypeToPropVariant]
420
_AdsFreeAdsValues: Pointer;
422
procedure AdsFreeAdsValues;
424
GetProcedureAddress(_AdsFreeAdsValues, adslib, 'AdsFreeAdsValues');
428
JMP [_AdsFreeAdsValues]
433
_BinarySDToSecurityDescriptor: Pointer;
435
function BinarySDToSecurityDescriptor;
437
GetProcedureAddress(_BinarySDToSecurityDescriptor, adslib, 'BinarySDToSecurityDescriptor');
441
JMP [_BinarySDToSecurityDescriptor]
446
_SecurityDescriptorToBinarySD: Pointer;
448
function SecurityDescriptorToBinarySD;
450
GetProcedureAddress(_SecurityDescriptorToBinarySD, adslib, 'SecurityDescriptorToBinarySD');
454
JMP [_SecurityDescriptorToBinarySD]
460
function ADsGetObject; external adslib name 'ADsGetObject';
461
function ADsBuildEnumerator; external adslib name 'ADsBuildEnumerator';
462
function ADsFreeEnumerator; external adslib name 'ADsFreeEnumerator';
463
function ADsEnumerateNext; external adslib name 'ADsEnumerateNext';
464
function ADsBuildVarArrayStr; external adslib name 'ADsBuildVarArrayStr';
465
function ADsBuildVarArrayInt; external adslib name 'ADsBuildVarArrayInt';
466
function ADsOpenObject; external adslib name 'ADsOpenObject';
467
function ADsGetLastError; external adslib name 'ADsGetLastError';
468
procedure ADsSetLastError; external adslib name 'ADsSetLastError';
469
function AllocADsMem; external adslib name 'AllocADsMem';
470
function FreeADsMem; external adslib name 'FreeADsMem';
471
function ReallocADsMem; external adslib name 'ReallocADsMem';
472
function AllocADsStr; external adslib name 'AllocADsStr';
473
function FreeADsStr; external adslib name 'FreeADsStr';
474
function ReallocADsStr; external adslib name 'ReallocADsStr';
475
function ADsEncodeBinaryData; external adslib name 'ADsEncodeBinaryData';
476
function ADsDecodeBinaryData; external adslib name 'ADsDecodeBinaryData';
477
function PropVariantToAdsType; external adslib name 'PropVariantToAdsType';
478
function AdsTypeToPropVariant; external adslib name 'AdsTypeToPropVariant';
479
procedure AdsFreeAdsValues; external adslib name 'AdsFreeAdsValues';
480
function BinarySDToSecurityDescriptor; external adslib name 'BinarySDToSecurityDescriptor';
481
function SecurityDescriptorToBinarySD; external adslib name 'SecurityDescriptorToBinarySD';
483
{$ENDIF DYNAMIC_LINK}