jwawinldap.pas 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764
  1. {******************************************************************************}
  2. { }
  3. { LDAP Client 32 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: winldap.h, released August 1999. The original Pascal }
  9. { code is: WinLDAP.pas, released December 1998. The initial developer of the }
  10. { Pascal code is Luk Vermeulen (lvermeulen att seria dott com). }
  11. { }
  12. { Portions created by Luk Vermeulen are Copyright (C) 1998 Luk Vermeulen. }
  13. { Portions created by Rudy Velthuis are Copyright (C) 2000 Rudy Velthuis. }
  14. { Portions created by M. van Brakel are Copyright (C) 2001 Marcel van Brakel. }
  15. { }
  16. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  17. { }
  18. { You may retrieve the latest version of this file at the Project JEDI }
  19. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  20. { }
  21. { The contents of this file are used with permission, subject to the Mozilla }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html }
  25. { }
  26. { Software distributed under the License is distributed on an "AS IS" basis, }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License. }
  29. { }
  30. {******************************************************************************}
  31. // $Id: JwaWinLDAP.pas,v 1.6 2005/09/06 16:36:50 marquardt Exp $
  32. unit JwaWinLDAP;
  33. {$WEAKPACKAGEUNIT}
  34. {$I jediapilib.inc}
  35. interface
  36. uses
  37. Windows;
  38. {$HPPEMIT '#ifndef LDAP_CLIENT_DEFINED'}
  39. {$HPPEMIT '#pragma option push -b -a8 -pc -A- /*P_O_Push_S*/'}
  40. {$HPPEMIT '#define LDAP_CLIENT_DEFINED'}
  41. {$HPPEMIT '#ifndef BASETYPES'}
  42. {$HPPEMIT '#include <windef.h>'}
  43. {$HPPEMIT '#endif'}
  44. (*
  45. Copyright (c) 1996-1999 Microsoft Corporation
  46. Module Name:
  47. winldap.h LDAP client 32 API header file
  48. Abstract:
  49. This module is the header file for the 32 bit LDAP client API for
  50. Windows NT and Windows 95. This API is based on RFC 1823 with some
  51. enhancements for LDAP v3.
  52. Notes about Unicode support :
  53. If you have UNICODE defined at compile time, you'll pull in the unicode
  54. versions of the calls. Note that your executable may then not work with
  55. other implementations of the LDAP API that don't support Unicode. If
  56. UNICODE is not defined, then we define the LDAP calls without the trailing
  57. 'A'(as in ldap_bind rather than ldap_bindA)so that your app may work
  58. with other implementations that don't support Unicode.
  59. The import library has all three forms of the call present... ldap_bindW,
  60. ldap_bindA, and ldap_bind. ldap_bindA simply calls ldap_bind. ldap_bind
  61. simply converts the arguments to unicode and calls ldap_bindW. The
  62. reason this is done is because we have to put UTF-8 on the wire, so if
  63. we converted from Unicode to single byte, we'd loose information. Since
  64. all core processing is done in Unicode, nothing is lost.
  65. Updates :
  66. 11/01/96 Modified for new API RFC draft.
  67. Environments :
  68. Win32 user mode
  69. *)
  70. // Extra defines to keep compiler happy.
  71. type
  72. PPCharA = ^PAnsiChar;
  73. {$NODEFINE PPCharA}
  74. PPCharW = ^PWideChar;
  75. {$NODEFINE PPCharW}
  76. PPChar = PPCharA;
  77. PPPCharA = ^PPCharA;
  78. {$NODEFINE PPPCharA}
  79. PPPCharW = ^PPCharW;
  80. {$NODEFINE PPPCharW}
  81. PPPChar = PPPCharA;
  82. //
  83. // The #define LDAP_UNICODE controls if we map the undecorated calls to
  84. // their unicode counterparts or just leave them defined as the normal
  85. // single byte entry points.
  86. //
  87. // If you want to write a UNICODE enabled application, you'd normally
  88. // just have UNICODE defined and then we'll default to using all LDAP
  89. // Unicode calls.
  90. //
  91. const
  92. //
  93. // Global constants
  94. //
  95. {$EXTERNALSYM LDAP_PORT}
  96. LDAP_PORT = 389;
  97. {$EXTERNALSYM LDAP_SSL_PORT}
  98. LDAP_SSL_PORT = 636;
  99. {$EXTERNALSYM LDAP_GC_PORT}
  100. LDAP_GC_PORT = 3268;
  101. {$EXTERNALSYM LDAP_SSL_GC_PORT}
  102. LDAP_SSL_GC_PORT = 3269;
  103. //
  104. // We currently support going to either v2 or v3 servers, though the API
  105. // is only a V2 API. We'll add support for result sets, server side
  106. // sorting, extended operations, etc as soon as they stabilize.
  107. //
  108. {$EXTERNALSYM LDAP_VERSION1}
  109. LDAP_VERSION1 = 1;
  110. {$EXTERNALSYM LDAP_VERSION2}
  111. LDAP_VERSION2 = 2;
  112. {$EXTERNALSYM LDAP_VERSION3}
  113. LDAP_VERSION3 = 3;
  114. {$EXTERNALSYM LDAP_VERSION}
  115. LDAP_VERSION = LDAP_VERSION2;
  116. //
  117. // All tags are CCFTTTTT.
  118. // CC Tag Class 00 = universal
  119. // 01 = application wide
  120. // 10 = context specific
  121. // 11 = private use
  122. //
  123. // F Form 0 primitive
  124. // 1 constructed
  125. //
  126. // TTTTT Tag Number
  127. //
  128. //
  129. // LDAP v2 & v3 commands.
  130. //
  131. {$EXTERNALSYM LDAP_BIND_CMD}
  132. LDAP_BIND_CMD = $60; // application + constructed
  133. {$EXTERNALSYM LDAP_UNBIND_CMD}
  134. LDAP_UNBIND_CMD = $42; // application + primitive
  135. {$EXTERNALSYM LDAP_SEARCH_CMD}
  136. LDAP_SEARCH_CMD = $63; // application + constructed
  137. {$EXTERNALSYM LDAP_MODIFY_CMD}
  138. LDAP_MODIFY_CMD = $66; // application + constructed
  139. {$EXTERNALSYM LDAP_ADD_CMD}
  140. LDAP_ADD_CMD = $68; // application + constructed
  141. {$EXTERNALSYM LDAP_DELETE_CMD}
  142. LDAP_DELETE_CMD = $4a; // application + primitive
  143. {$EXTERNALSYM LDAP_MODRDN_CMD}
  144. LDAP_MODRDN_CMD = $6c; // application + constructed
  145. {$EXTERNALSYM LDAP_COMPARE_CMD}
  146. LDAP_COMPARE_CMD = $6e; // application + constructed
  147. {$EXTERNALSYM LDAP_ABANDON_CMD}
  148. LDAP_ABANDON_CMD = $50; // application + primitive
  149. {$EXTERNALSYM LDAP_SESSION_CMD}
  150. LDAP_SESSION_CMD = $71; // application + constructed
  151. {$EXTERNALSYM LDAP_EXTENDED_CMD}
  152. LDAP_EXTENDED_CMD = $77; // application + constructed
  153. //
  154. // Responses/Results for LDAP v2 & v3
  155. //
  156. {$EXTERNALSYM LDAP_RES_BIND}
  157. LDAP_RES_BIND = $61; // application + constructed
  158. {$EXTERNALSYM LDAP_RES_SEARCH_ENTRY}
  159. LDAP_RES_SEARCH_ENTRY = $64; // application + constructed
  160. {$EXTERNALSYM LDAP_RES_SEARCH_RESULT}
  161. LDAP_RES_SEARCH_RESULT = $65; // application + constructed
  162. {$EXTERNALSYM LDAP_RES_MODIFY}
  163. LDAP_RES_MODIFY = $67; // application + constructed
  164. {$EXTERNALSYM LDAP_RES_ADD}
  165. LDAP_RES_ADD = $69; // application + constructed
  166. {$EXTERNALSYM LDAP_RES_DELETE}
  167. LDAP_RES_DELETE = $6b; // application + constructed
  168. {$EXTERNALSYM LDAP_RES_MODRDN}
  169. LDAP_RES_MODRDN = $6d; // application + constructed
  170. {$EXTERNALSYM LDAP_RES_COMPARE}
  171. LDAP_RES_COMPARE = $6f; // application + constructed
  172. {$EXTERNALSYM LDAP_RES_SESSION}
  173. LDAP_RES_SESSION = $72; // application + constructed
  174. {$EXTERNALSYM LDAP_RES_REFERRAL}
  175. LDAP_RES_REFERRAL = $73; // application + constructed
  176. {$EXTERNALSYM LDAP_RES_EXTENDED}
  177. LDAP_RES_EXTENDED = $78; // application + constructed
  178. {$EXTERNALSYM LDAP_RES_ANY}
  179. LDAP_RES_ANY = -1;
  180. {$EXTERNALSYM LDAP_INVALID_CMD}
  181. LDAP_INVALID_CMD = $FF;
  182. {$EXTERNALSYM LDAP_INVALID_RES}
  183. LDAP_INVALID_RES = $FF;
  184. //
  185. // We'll make the error codes compatible with reference implementation
  186. //
  187. type
  188. {$EXTERNALSYM LDAP_RETCODE}
  189. LDAP_RETCODE = ULONG;
  190. const
  191. {$EXTERNALSYM LDAP_SUCCESS}
  192. LDAP_SUCCESS = $00;
  193. {$EXTERNALSYM LDAP_OPERATIONS_ERROR}
  194. LDAP_OPERATIONS_ERROR = $01;
  195. {$EXTERNALSYM LDAP_PROTOCOL_ERROR}
  196. LDAP_PROTOCOL_ERROR = $02;
  197. {$EXTERNALSYM LDAP_TIMELIMIT_EXCEEDED}
  198. LDAP_TIMELIMIT_EXCEEDED = $03;
  199. {$EXTERNALSYM LDAP_SIZELIMIT_EXCEEDED}
  200. LDAP_SIZELIMIT_EXCEEDED = $04;
  201. {$EXTERNALSYM LDAP_COMPARE_FALSE}
  202. LDAP_COMPARE_FALSE = $05;
  203. {$EXTERNALSYM LDAP_COMPARE_TRUE}
  204. LDAP_COMPARE_TRUE = $06;
  205. {$EXTERNALSYM LDAP_AUTH_METHOD_NOT_SUPPORTED}
  206. LDAP_AUTH_METHOD_NOT_SUPPORTED = $07;
  207. {$EXTERNALSYM LDAP_STRONG_AUTH_REQUIRED}
  208. LDAP_STRONG_AUTH_REQUIRED = $08;
  209. {$EXTERNALSYM LDAP_REFERRAL_V2}
  210. LDAP_REFERRAL_V2 = $09;
  211. {$EXTERNALSYM LDAP_PARTIAL_RESULTS}
  212. LDAP_PARTIAL_RESULTS = $09;
  213. {$EXTERNALSYM LDAP_REFERRAL}
  214. LDAP_REFERRAL = $0a;
  215. {$EXTERNALSYM LDAP_ADMIN_LIMIT_EXCEEDED}
  216. LDAP_ADMIN_LIMIT_EXCEEDED = $0b;
  217. {$EXTERNALSYM LDAP_UNAVAILABLE_CRIT_EXTENSION}
  218. LDAP_UNAVAILABLE_CRIT_EXTENSION = $0c;
  219. {$EXTERNALSYM LDAP_CONFIDENTIALITY_REQUIRED}
  220. LDAP_CONFIDENTIALITY_REQUIRED = $0d;
  221. {$EXTERNALSYM LDAP_SASL_BIND_IN_PROGRESS}
  222. LDAP_SASL_BIND_IN_PROGRESS = $0e;
  223. {$EXTERNALSYM LDAP_NO_SUCH_ATTRIBUTE}
  224. LDAP_NO_SUCH_ATTRIBUTE = $10;
  225. {$EXTERNALSYM LDAP_UNDEFINED_TYPE}
  226. LDAP_UNDEFINED_TYPE = $11;
  227. {$EXTERNALSYM LDAP_INAPPROPRIATE_MATCHING}
  228. LDAP_INAPPROPRIATE_MATCHING = $12;
  229. {$EXTERNALSYM LDAP_CONSTRAINT_VIOLATION}
  230. LDAP_CONSTRAINT_VIOLATION = $13;
  231. {$EXTERNALSYM LDAP_ATTRIBUTE_OR_VALUE_EXISTS}
  232. LDAP_ATTRIBUTE_OR_VALUE_EXISTS = $14;
  233. {$EXTERNALSYM LDAP_INVALID_SYNTAX}
  234. LDAP_INVALID_SYNTAX = $15;
  235. {$EXTERNALSYM LDAP_NO_SUCH_OBJECT}
  236. LDAP_NO_SUCH_OBJECT = $20;
  237. {$EXTERNALSYM LDAP_ALIAS_PROBLEM}
  238. LDAP_ALIAS_PROBLEM = $21;
  239. {$EXTERNALSYM LDAP_INVALID_DN_SYNTAX}
  240. LDAP_INVALID_DN_SYNTAX = $22;
  241. {$EXTERNALSYM LDAP_IS_LEAF}
  242. LDAP_IS_LEAF = $23;
  243. {$EXTERNALSYM LDAP_ALIAS_DEREF_PROBLEM}
  244. LDAP_ALIAS_DEREF_PROBLEM = $24;
  245. {$EXTERNALSYM LDAP_INAPPROPRIATE_AUTH}
  246. LDAP_INAPPROPRIATE_AUTH = $30;
  247. {$EXTERNALSYM LDAP_INVALID_CREDENTIALS}
  248. LDAP_INVALID_CREDENTIALS = $31;
  249. {$EXTERNALSYM LDAP_INSUFFICIENT_RIGHTS}
  250. LDAP_INSUFFICIENT_RIGHTS = $32;
  251. {$EXTERNALSYM LDAP_BUSY}
  252. LDAP_BUSY = $33;
  253. {$EXTERNALSYM LDAP_UNAVAILABLE}
  254. LDAP_UNAVAILABLE = $34;
  255. {$EXTERNALSYM LDAP_UNWILLING_TO_PERFORM}
  256. LDAP_UNWILLING_TO_PERFORM = $35;
  257. {$EXTERNALSYM LDAP_LOOP_DETECT}
  258. LDAP_LOOP_DETECT = $36;
  259. {$EXTERNALSYM LDAP_NAMING_VIOLATION}
  260. LDAP_NAMING_VIOLATION = $40;
  261. {$EXTERNALSYM LDAP_OBJECT_CLASS_VIOLATION}
  262. LDAP_OBJECT_CLASS_VIOLATION = $41;
  263. {$EXTERNALSYM LDAP_NOT_ALLOWED_ON_NONLEAF}
  264. LDAP_NOT_ALLOWED_ON_NONLEAF = $42;
  265. {$EXTERNALSYM LDAP_NOT_ALLOWED_ON_RDN}
  266. LDAP_NOT_ALLOWED_ON_RDN = $43;
  267. {$EXTERNALSYM LDAP_ALREADY_EXISTS}
  268. LDAP_ALREADY_EXISTS = $44;
  269. {$EXTERNALSYM LDAP_NO_OBJECT_CLASS_MODS}
  270. LDAP_NO_OBJECT_CLASS_MODS = $45;
  271. {$EXTERNALSYM LDAP_RESULTS_TOO_LARGE}
  272. LDAP_RESULTS_TOO_LARGE = $46;
  273. {$EXTERNALSYM LDAP_AFFECTS_MULTIPLE_DSAS}
  274. LDAP_AFFECTS_MULTIPLE_DSAS = $47;
  275. {$EXTERNALSYM LDAP_OTHER}
  276. LDAP_OTHER = $50;
  277. {$EXTERNALSYM LDAP_SERVER_DOWN}
  278. LDAP_SERVER_DOWN = $51;
  279. {$EXTERNALSYM LDAP_LOCAL_ERROR}
  280. LDAP_LOCAL_ERROR = $52;
  281. {$EXTERNALSYM LDAP_ENCODING_ERROR}
  282. LDAP_ENCODING_ERROR = $53;
  283. {$EXTERNALSYM LDAP_DECODING_ERROR}
  284. LDAP_DECODING_ERROR = $54;
  285. {$EXTERNALSYM LDAP_TIMEOUT}
  286. LDAP_TIMEOUT = $55;
  287. {$EXTERNALSYM LDAP_AUTH_UNKNOWN}
  288. LDAP_AUTH_UNKNOWN = $56;
  289. {$EXTERNALSYM LDAP_FILTER_ERROR}
  290. LDAP_FILTER_ERROR = $57;
  291. {$EXTERNALSYM LDAP_USER_CANCELLED}
  292. LDAP_USER_CANCELLED = $58;
  293. {$EXTERNALSYM LDAP_PARAM_ERROR}
  294. LDAP_PARAM_ERROR = $59;
  295. {$EXTERNALSYM LDAP_NO_MEMORY}
  296. LDAP_NO_MEMORY = $5a;
  297. {$EXTERNALSYM LDAP_CONNECT_ERROR}
  298. LDAP_CONNECT_ERROR = $5b;
  299. {$EXTERNALSYM LDAP_NOT_SUPPORTED}
  300. LDAP_NOT_SUPPORTED = $5c;
  301. {$EXTERNALSYM LDAP_NO_RESULTS_RETURNED}
  302. LDAP_NO_RESULTS_RETURNED = $5e;
  303. {$EXTERNALSYM LDAP_CONTROL_NOT_FOUND}
  304. LDAP_CONTROL_NOT_FOUND = $5d;
  305. {$EXTERNALSYM LDAP_MORE_RESULTS_TO_RETURN}
  306. LDAP_MORE_RESULTS_TO_RETURN = $5f;
  307. {$EXTERNALSYM LDAP_CLIENT_LOOP}
  308. LDAP_CLIENT_LOOP = $60;
  309. {$EXTERNALSYM LDAP_REFERRAL_LIMIT_EXCEEDED}
  310. LDAP_REFERRAL_LIMIT_EXCEEDED = $61;
  311. //
  312. // Bind methods. We support the following methods :
  313. //
  314. // Simple Clear text password... try not to use as it's not secure.
  315. //
  316. // MSN MSN(Microsoft Network)authentication. This package
  317. // may bring up UI to prompt the user for MSN credentials.
  318. //
  319. // DPA Normandy authentication... new MSN authentication. Same
  320. // usage as MSN.
  321. //
  322. // NTLM NT domain authentication. Use NULL credentials and
  323. // we'll try to use default logged in user credentials.
  324. //
  325. // Sicily Negotiate with the server for any of: MSN, DPA, NTLM
  326. //
  327. // SSPI Use GSSAPI Negotiate package to negotiate security
  328. // package of either Kerberos v5 or NTLM(or any other
  329. // package the client and server negotiate). Pass in
  330. // NULL credentials to specify default logged in user or
  331. // you may pass in a SEC_WINNT_AUTH_IDENTITY_W(defined
  332. // in rpcdce.h)to specify alternate credentials.
  333. //
  334. // For all bind methods except for Simple, you may pass in a
  335. // SEC_WINNT_AUTH_IDENTITY_W (defined in rpcdce.h) or the newer
  336. // SEC_WINNT_AUTH_IDENTITY_EXW (defined in secext.h) to specify alternate
  337. // credentials.
  338. //
  339. // All bind methods other than simple are synchronous only calls.
  340. // Calling the asynchronous bind call for any of these messages will
  341. // return LDAP_PARAM_ERROR.
  342. //
  343. // Using any other method besides simple will cause WLDAP32 to pull in
  344. // the SSPI security DLLs(SECURITY.DLL etc).
  345. //
  346. // On NTLM and SSPI, if you specify NULL credentials, we'll attempt to use
  347. // the default logged in user.
  348. //
  349. const
  350. {$EXTERNALSYM LDAP_AUTH_SIMPLE}
  351. LDAP_AUTH_SIMPLE = $80;
  352. {$EXTERNALSYM LDAP_AUTH_SASL}
  353. LDAP_AUTH_SASL = $83;
  354. {$EXTERNALSYM LDAP_AUTH_OTHERKIND}
  355. LDAP_AUTH_OTHERKIND = $86;
  356. // The SICILY type covers package negotiation to MSN servers.
  357. // Each of the supported types can also be specified without
  358. // doing the package negotiation, assuming the caller knows
  359. // what the server supports.
  360. {$EXTERNALSYM LDAP_AUTH_SICILY}
  361. LDAP_AUTH_SICILY = LDAP_AUTH_OTHERKIND or $0200;
  362. {$EXTERNALSYM LDAP_AUTH_MSN}
  363. LDAP_AUTH_MSN = LDAP_AUTH_OTHERKIND or $0800;
  364. {$EXTERNALSYM LDAP_AUTH_NTLM}
  365. LDAP_AUTH_NTLM = LDAP_AUTH_OTHERKIND or $1000;
  366. {$EXTERNALSYM LDAP_AUTH_DPA}
  367. LDAP_AUTH_DPA = LDAP_AUTH_OTHERKIND or $2000;
  368. // This will cause the client to use the GSSAPI negotiation
  369. // package to determine the most appropriate authentication type.
  370. // This type should be used when talking to NT5.
  371. {$EXTERNALSYM LDAP_AUTH_NEGOTIATE}
  372. LDAP_AUTH_NEGOTIATE = LDAP_AUTH_OTHERKIND or $0400;
  373. // backward compatible #define for older constant name.
  374. {$EXTERNALSYM LDAP_AUTH_SSPI}
  375. LDAP_AUTH_SSPI = LDAP_AUTH_NEGOTIATE;
  376. //
  377. // Client applications typically don't have to encode/decode LDAP filters,
  378. // but if they do, we define the operators here.
  379. //
  380. // Filter types.
  381. {$EXTERNALSYM LDAP_FILTER_AND}
  382. LDAP_FILTER_AND = $a0; // context specific + constructed - SET OF Filters.
  383. {$EXTERNALSYM LDAP_FILTER_OR}
  384. LDAP_FILTER_OR = $a1; // context specific + constructed - SET OF Filters.
  385. {$EXTERNALSYM LDAP_FILTER_NOT}
  386. LDAP_FILTER_NOT = $a2; // context specific + constructed - Filter
  387. {$EXTERNALSYM LDAP_FILTER_EQUALITY}
  388. LDAP_FILTER_EQUALITY = $a3; // context specific + constructed - AttributeValueAssertion.
  389. {$EXTERNALSYM LDAP_FILTER_SUBSTRINGS}
  390. LDAP_FILTER_SUBSTRINGS = $a4; // context specific + constructed - SubstringFilter
  391. {$EXTERNALSYM LDAP_FILTER_GE}
  392. LDAP_FILTER_GE = $a5; // context specific + constructed - AttributeValueAssertion.
  393. {$EXTERNALSYM LDAP_FILTER_LE}
  394. LDAP_FILTER_LE = $a6; // context specific + constructed - AttributeValueAssertion.
  395. {$EXTERNALSYM LDAP_FILTER_PRESENT}
  396. LDAP_FILTER_PRESENT = $87; // context specific + primitive - AttributeType.
  397. {$EXTERNALSYM LDAP_FILTER_APPROX}
  398. LDAP_FILTER_APPROX = $a8; // context specific + constructed - AttributeValueAssertion.
  399. {$EXTERNALSYM LDAP_FILTER_EXTENSIBLE}
  400. LDAP_FILTER_EXTENSIBLE = $a9; // context specific + constructed - MatchingRuleAssertion.
  401. // Substring filter types
  402. {$EXTERNALSYM LDAP_SUBSTRING_INITIAL}
  403. LDAP_SUBSTRING_INITIAL = $80; // class context specific
  404. {$EXTERNALSYM LDAP_SUBSTRING_ANY}
  405. LDAP_SUBSTRING_ANY = $81; // class context specific
  406. {$EXTERNALSYM LDAP_SUBSTRING_FINAL}
  407. LDAP_SUBSTRING_FINAL = $82; // class context specific
  408. //
  409. // Possible values for ld_deref field.
  410. // "Never" - never deref aliases. return only the alias.
  411. // "Searching" - only deref aliases when searching, not when locating
  412. // the base object of a search.
  413. // "Finding" - dereference the alias when locating the base object but
  414. // not during a search.
  415. // "Always" - always dereference aliases.
  416. //
  417. {$EXTERNALSYM LDAP_DEREF_NEVER}
  418. LDAP_DEREF_NEVER = 0;
  419. {$EXTERNALSYM LDAP_DEREF_SEARCHING}
  420. LDAP_DEREF_SEARCHING = 1;
  421. {$EXTERNALSYM LDAP_DEREF_FINDING}
  422. LDAP_DEREF_FINDING = 2;
  423. {$EXTERNALSYM LDAP_DEREF_ALWAYS}
  424. LDAP_DEREF_ALWAYS = 3;
  425. // Special values for ld_sizelimit :
  426. {$EXTERNALSYM LDAP_NO_LIMIT}
  427. LDAP_NO_LIMIT = 0;
  428. // Flags for ld_options field :
  429. {$EXTERNALSYM LDAP_OPT_DNS}
  430. LDAP_OPT_DNS = $00000001; // utilize DN & DNS
  431. {$EXTERNALSYM LDAP_OPT_CHASE_REFERRALS}
  432. LDAP_OPT_CHASE_REFERRALS = $00000002; // chase referrals
  433. {$EXTERNALSYM LDAP_OPT_RETURN_REFS}
  434. LDAP_OPT_RETURN_REFS = $00000004; // return referrals to calling app
  435. //
  436. // LDAP structure per connection
  437. //
  438. {$HPPEMIT '#pragma pack(push, 4)'}
  439. {$ALIGN ON}
  440. type
  441. {$EXTERNALSYM PLDAP}
  442. PLDAP = ^LDAP;
  443. {$EXTERNALSYM LDAP}
  444. LDAP = record
  445. ld_sb: record
  446. sb_sd: ULONG;
  447. Reserved1: array [0..10*SizeOf(ULONG)] of Byte;
  448. sb_naddr: ULONG; // notzero implies CLDAP available
  449. Reserved2: array [0..6*SizeOf(ULONG)-1] of Byte;
  450. end;
  451. //
  452. // Following parameters MAY match up to reference implementation of LDAP
  453. //
  454. ld_host: PChar;
  455. ld_version: ULONG;
  456. ld_lberoptions: Byte;
  457. //
  458. // Safe to assume that these parameters are in same location as
  459. // reference implementation of LDAP API.
  460. //
  461. ld_deref: ULONG;
  462. ld_timelimit: ULONG;
  463. ld_sizelimit: ULONG;
  464. ld_errno: ULONG;
  465. ld_matched: PChar;
  466. ld_error: PChar;
  467. ld_msgid: ULONG;
  468. Reserved3: array [0..6*SizeOf(ULONG)] of Byte;
  469. //
  470. // Following parameters may match up to reference implementation of LDAP API.
  471. //
  472. ld_cldaptries: ULONG;
  473. ld_cldaptimeout: ULONG;
  474. ld_refhoplimit: ULONG;
  475. ld_options: ULONG;
  476. end;
  477. //
  478. // Our timeval structure is a bit different from the reference implementation
  479. // since Win32 defines a _timeval structure that is different from the LDAP
  480. // one.
  481. //
  482. PLDAPTimeVal = ^TLDAPTimeVal;
  483. {$EXTERNALSYM l_timeval}
  484. l_timeval = packed record
  485. tv_sec: Longint;
  486. tv_usec: Longint;
  487. end;
  488. {$EXTERNALSYM LDAP_TIMEVAL}
  489. LDAP_TIMEVAL = l_timeval;
  490. {$EXTERNALSYM PLDAP_TIMEVAL}
  491. PLDAP_TIMEVAL = ^LDAP_TIMEVAL;
  492. TLDAPTimeVal = l_timeval;
  493. //
  494. // The berval structure is used to pass in any arbitrary octet string. It
  495. // is useful for attributes that cannot be represented using a null
  496. // terminated string.
  497. //
  498. PLDAPBerVal = ^TLDAPBerVal;
  499. PPLDAPBerVal = ^PLDAPBerVal;
  500. {$EXTERNALSYM PLDAP_BERVAL}
  501. PLDAP_BERVAL = ^berval;
  502. {$EXTERNALSYM PBERVAL}
  503. PBERVAL = ^berval;
  504. {$EXTERNALSYM berval}
  505. berval = record
  506. bv_len: ULONG;
  507. bv_val: PChar;
  508. end;
  509. {$EXTERNALSYM LDAP_BERVAL}
  510. LDAP_BERVAL = berval;
  511. TLDAPBerVal = berval;
  512. //
  513. // The following structure has to be compatible with reference implementation.
  514. //
  515. PPLDAPMessage = ^PLDAPMessage;
  516. {$EXTERNALSYM PLDAPMessage}
  517. PLDAPMessage = ^LDAPMessage;
  518. {$EXTERNALSYM ldapmsg}
  519. ldapmsg = record
  520. lm_msgid: ULONG; // message number for given connection
  521. lm_msgtype: ULONG; // message type of the form LDAP_RES_xxx
  522. lm_ber: Pointer; // ber form of message
  523. lm_chain: PLDAPMessage; // pointer to next result value
  524. lm_next: PLDAPMessage; // pointer to next message
  525. lm_time: ULONG;
  526. //
  527. // new fields below not in reference implementation
  528. //
  529. Connection: PLDAP; // connection from which we received response
  530. Request: Pointer; // owning request(opaque structure)
  531. lm_returncode: ULONG; // server's return code
  532. lm_referral: Word; // index of referral within ref table
  533. lm_chased: ByteBool; // has referral been chased already?
  534. lm_eom: ByteBool; // is this the last entry for this message?
  535. ConnectionReferenced: ByteBool; // is the Connection still valid?
  536. end;
  537. {$EXTERNALSYM LDAPMessage}
  538. LDAPMessage = ldapmsg;
  539. //
  540. // Controls... there are three types :
  541. //
  542. // 1) those passed to the server
  543. // 2) those passed to the client and handled by the client API
  544. // 3) those returned by the server
  545. //
  546. // Extra types defined for use as parameter.
  547. PPPLDAPControlA = ^PPLDAPControlA;
  548. {$NODEFINE PPPLDAPControlA}
  549. PPPLDAPControlW = ^PPLDAPControlW;
  550. {$NODEFINE PPPLDAPControlW}
  551. PPPLDAPControl = PPPLDAPControlA;
  552. PPLDAPControlA = ^PLDAPControlA;
  553. {$NODEFINE PPLDAPControlA}
  554. PPLDAPControlW = ^PLDAPControlW;
  555. {$NODEFINE PPLDAPControlW}
  556. PPLDAPControl = PPLDAPControlA;
  557. {$EXTERNALSYM PLDAPControlA}
  558. PLDAPControlA = ^LDAPControlA;
  559. {$EXTERNALSYM PLDAPControlW}
  560. PLDAPControlW = ^LDAPControlW;
  561. {$EXTERNALSYM PLDAPControl}
  562. PLDAPControl = PLDAPControlA;
  563. {$EXTERNALSYM LDAPControlA}
  564. LDAPControlA = record
  565. ldctl_oid: PAnsiChar;
  566. ldctl_value: TLDAPBerVal;
  567. ldctl_iscritical: ByteBool;
  568. end;
  569. {$EXTERNALSYM LDAPControlW}
  570. LDAPControlW = record
  571. ldctl_oid: PWideChar;
  572. ldctl_value: TLDAPBerVal;
  573. ldctl_iscritical: ByteBool;
  574. end;
  575. {$EXTERNALSYM LDAPControl}
  576. LDAPControl = LDAPControlA;
  577. TLDAPControlA = LDAPControlA;
  578. TLDAPControlW = LDAPControlW;
  579. TLDAPControl = TLDAPControlA;
  580. //
  581. // Client controls section : these are the client controls that wldap32.dll
  582. // supports.
  583. //
  584. // If you specify LDAP_CONTROL_REFERRALS in a control, the value field should
  585. // point to a ULONG of the following flags :
  586. //
  587. // LDAP_CHASE_SUBORDINATE_REFERRALS
  588. // LDAP_CHASE_EXTERNAL_REFERRALS
  589. //
  590. const
  591. {$EXTERNALSYM LDAP_CONTROL_REFERRALS_W}
  592. LDAP_CONTROL_REFERRALS_W = '1.2.840.113556.1.4.616';
  593. {$EXTERNALSYM LDAP_CONTROL_REFERRALS}
  594. LDAP_CONTROL_REFERRALS = '1.2.840.113556.1.4.616';
  595. //
  596. // Values required for Modification command These are options for the
  597. // mod_op field of LDAPMod structure
  598. //
  599. const
  600. {$EXTERNALSYM LDAP_MOD_ADD}
  601. LDAP_MOD_ADD = $00;
  602. {$EXTERNALSYM LDAP_MOD_DELETE}
  603. LDAP_MOD_DELETE = $01;
  604. {$EXTERNALSYM LDAP_MOD_REPLACE}
  605. LDAP_MOD_REPLACE = $02;
  606. {$EXTERNALSYM LDAP_MOD_BVALUES}
  607. LDAP_MOD_BVALUES = $80;
  608. type
  609. {$EXTERNALSYM PLDAPModA}
  610. PLDAPModA = ^LDAPModA;
  611. {$EXTERNALSYM PLDAPModW}
  612. PLDAPModW = ^LDAPModW;
  613. {$EXTERNALSYM PLDAPMod}
  614. PLDAPMod = PLDAPModA;
  615. {$EXTERNALSYM LDAPModA}
  616. LDAPModA = record
  617. mod_op: ULONG;
  618. mod_type: PAnsiChar;
  619. case integer of
  620. 0:(modv_strvals: ^PAnsiChar);
  621. 1:(modv_bvals: ^PLDAPBerVal);
  622. end;
  623. {$EXTERNALSYM LDAPModW}
  624. LDAPModW = record
  625. mod_op: ULONG;
  626. mod_type: PWideChar;
  627. case integer of
  628. 0:(modv_strvals: ^PWideChar);
  629. 1:(modv_bvals: ^PLDAPBerVal);
  630. end;
  631. {$EXTERNALSYM LDAPMod}
  632. LDAPMod = LDAPModA;
  633. TLDAPModA = LDAPModA;
  634. TLDAPModW = LDAPModW;
  635. TLDAPMod = TLDAPModA;
  636. {$HPPEMIT '#pragma pack(pop)'}
  637. //
  638. // macros compatible with reference implementation...
  639. //
  640. {$EXTERNALSYM LDAP_IS_CLDAP}
  641. function LDAP_IS_CLDAP(ld: PLDAP): Boolean;
  642. {$EXTERNALSYM NAME_ERROR}
  643. function NAME_ERROR(n: Integer): Boolean;
  644. //
  645. // function definitions for LDAP API
  646. //
  647. //
  648. // Create a connection block to an LDAP server. HostName can be NULL, in
  649. // which case we'll try to go off and find the "default" LDAP server.
  650. //
  651. // Note that if we have to go off and find the default server, we'll pull
  652. // in NETAPI32.DLL and ADVAPI32.DLL.
  653. //
  654. // If it returns NULL, an error occurred. Pick up error code with
  655. // GetLastError().
  656. //
  657. // ldap_open actually opens the connection at the time of the call,
  658. // whereas ldap_init only opens the connection when an operation is performed
  659. // that requires it.
  660. {$EXTERNALSYM ldap_openA}
  661. function ldap_openA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
  662. {$EXTERNALSYM ldap_openW}
  663. function ldap_openW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
  664. {$EXTERNALSYM ldap_open}
  665. function ldap_open(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
  666. {$EXTERNALSYM ldap_initA}
  667. function ldap_initA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
  668. {$EXTERNALSYM ldap_initW}
  669. function ldap_initW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
  670. {$EXTERNALSYM ldap_init}
  671. function ldap_init(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
  672. {$EXTERNALSYM ldap_sslinitA}
  673. function ldap_sslinitA(HostName: PAnsiChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
  674. {$EXTERNALSYM ldap_sslinitW}
  675. function ldap_sslinitW(HostName: PWideChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
  676. {$EXTERNALSYM ldap_sslinit}
  677. function ldap_sslinit(HostName: PChar; PortNumber: ULONG; secure: integer): PLDAP; cdecl;
  678. //
  679. // when calling ldap_init, you can call ldap_connect explicitly to have the
  680. // library contact the server. This is useful for checking for server
  681. // availability. This call is not required however, since the other functions
  682. // will call it internally if it hasn't already been called.
  683. //
  684. {$EXTERNALSYM ldap_connect}
  685. function ldap_connect(ld: PLDAP; timeout: PLDAPTimeval): ULONG; cdecl;
  686. //
  687. // This is similar to ldap_open except it creates a connection block for
  688. // UDP based Connectionless LDAP services. No TCP session is maintained.
  689. //
  690. // If it returns NULL, an error occurred. Pick up error code with
  691. // GetLastError().
  692. //
  693. {$EXTERNALSYM cldap_openA}
  694. function cldap_openA(HostName: PAnsiChar; PortNumber: ULONG): PLDAP; cdecl;
  695. {$EXTERNALSYM cldap_openW}
  696. function cldap_openW(HostName: PWideChar; PortNumber: ULONG): PLDAP; cdecl;
  697. {$EXTERNALSYM cldap_open}
  698. function cldap_open(HostName: PChar; PortNumber: ULONG): PLDAP; cdecl;
  699. //
  700. // Call unbind when you're done with the connection, it will free all
  701. // resources associated with the connection.
  702. //
  703. // There is no ldap_close... use ldap_unbind even if you haven't called
  704. // ldap_bind on the connection.
  705. //
  706. {$EXTERNALSYM ldap_unbind}
  707. function ldap_unbind(ld: PLDAP): ULONG; cdecl;
  708. {$EXTERNALSYM ldap_unbind_s}
  709. function ldap_unbind_s(ld: PLDAP): ULONG; cdecl; // calls ldap_unbind
  710. //
  711. // Calls to get and set options on connection blocks... use them rather
  712. // than modifying the LDAP block directly.
  713. //
  714. {$EXTERNALSYM ldap_get_option}
  715. function ldap_get_option(ld: PLDAP; option: integer; outvalue: pointer): ULONG; cdecl;
  716. {$EXTERNALSYM ldap_get_optionW}
  717. function ldap_get_optionW(ld: PLDAP; option: integer; outvalue: pointer): ULONG; cdecl;
  718. {$EXTERNALSYM ldap_set_option}
  719. function ldap_set_option(ld: PLDAP; option: integer; invalue: pointer): ULONG; cdecl;
  720. {$EXTERNALSYM ldap_set_optionW}
  721. function ldap_set_optionW(ld: PLDAP; option: integer; invalue: pointer): ULONG; cdecl;
  722. //
  723. // These are the values to pass to ldap_get/set_option :
  724. //
  725. const
  726. {$EXTERNALSYM LDAP_OPT_DESC}
  727. LDAP_OPT_DESC = $01;
  728. {$EXTERNALSYM LDAP_OPT_DEREF}
  729. LDAP_OPT_DEREF = $02;
  730. {$EXTERNALSYM LDAP_OPT_SIZELIMIT}
  731. LDAP_OPT_SIZELIMIT = $03;
  732. {$EXTERNALSYM LDAP_OPT_TIMELIMIT}
  733. LDAP_OPT_TIMELIMIT = $04;
  734. {$EXTERNALSYM LDAP_OPT_THREAD_FN_PTRS}
  735. LDAP_OPT_THREAD_FN_PTRS = $05;
  736. {$EXTERNALSYM LDAP_OPT_REBIND_FN}
  737. LDAP_OPT_REBIND_FN = $06;
  738. {$EXTERNALSYM LDAP_OPT_REBIND_ARG}
  739. LDAP_OPT_REBIND_ARG = $07;
  740. {$EXTERNALSYM LDAP_OPT_REFERRALS}
  741. LDAP_OPT_REFERRALS = $08;
  742. {$EXTERNALSYM LDAP_OPT_RESTART}
  743. LDAP_OPT_RESTART = $09;
  744. LDAP_OPT_SSL = $0a;
  745. {$EXTERNALSYM LDAP_OPT_IO_FN_PTRS}
  746. LDAP_OPT_IO_FN_PTRS = $0b;
  747. {$EXTERNALSYM LDAP_OPT_CACHE_FN_PTRS}
  748. LDAP_OPT_CACHE_FN_PTRS = $0d;
  749. {$EXTERNALSYM LDAP_OPT_CACHE_STRATEGY}
  750. LDAP_OPT_CACHE_STRATEGY = $0e;
  751. {$EXTERNALSYM LDAP_OPT_CACHE_ENABLE}
  752. LDAP_OPT_CACHE_ENABLE = $0f;
  753. {$EXTERNALSYM LDAP_OPT_REFERRAL_HOP_LIMIT}
  754. LDAP_OPT_REFERRAL_HOP_LIMIT = $10;
  755. {$EXTERNALSYM LDAP_OPT_PROTOCOL_VERSION}
  756. LDAP_OPT_PROTOCOL_VERSION = $11;
  757. {$EXTERNALSYM LDAP_OPT_VERSION}
  758. LDAP_OPT_VERSION = $11;
  759. {$EXTERNALSYM LDAP_OPT_SORTKEYS}
  760. LDAP_OPT_SORTKEYS = $11;
  761. //
  762. // These are new ones that we've defined, not in current RFC draft.
  763. //
  764. {$EXTERNALSYM LDAP_OPT_HOST_NAME}
  765. LDAP_OPT_HOST_NAME = $30;
  766. {$EXTERNALSYM LDAP_OPT_ERROR_NUMBER}
  767. LDAP_OPT_ERROR_NUMBER = $31;
  768. {$EXTERNALSYM LDAP_OPT_ERROR_STRING}
  769. LDAP_OPT_ERROR_STRING = $32;
  770. {$EXTERNALSYM LDAP_OPT_SERVER_ERROR}
  771. LDAP_OPT_SERVER_ERROR = $33;
  772. {$EXTERNALSYM LDAP_OPT_SERVER_EXT_ERROR}
  773. LDAP_OPT_SERVER_EXT_ERROR = $34;
  774. {$EXTERNALSYM LDAP_OPT_HOST_REACHABLE}
  775. LDAP_OPT_HOST_REACHABLE = $3E;
  776. //
  777. // These options control the keep-alive logic. Keep alives are sent as
  778. // ICMP ping messages (which currently don't go through firewalls).
  779. //
  780. // There are three values that control how this works :
  781. // PING_KEEP_ALIVE : min number of seconds since we last received a response
  782. // from the server before we send a keep-alive ping
  783. // PING_WAIT_TIME : number of milliseconds we wait for the response to
  784. // come back when we send a ping
  785. // PING_LIMIT : number of unanswered pings we send before we close the
  786. // connection.
  787. //
  788. // To disable the keep-alive logic, set any of the values (PING_KEEP_ALIVE,
  789. // PING_LIMIT, or PING_WAIT_TIME) to zero.
  790. //
  791. // The current default/min/max for these values are as follows :
  792. //
  793. // PING_KEEP_ALIVE : 120/5/maxInt seconds (may also be zero)
  794. // PING_WAIT_TIME : 2000/10/60000 milliseconds (may also be zero)
  795. // PING_LIMIT : 4/0/maxInt
  796. //
  797. {$EXTERNALSYM LDAP_OPT_PING_KEEP_ALIVE}
  798. LDAP_OPT_PING_KEEP_ALIVE = $36;
  799. {$EXTERNALSYM LDAP_OPT_PING_WAIT_TIME}
  800. LDAP_OPT_PING_WAIT_TIME = $37;
  801. {$EXTERNALSYM LDAP_OPT_PING_LIMIT}
  802. LDAP_OPT_PING_LIMIT = $38;
  803. //
  804. // These won't be in the RFC. Only use these if you're going to be dependent
  805. // on our implementation.
  806. //
  807. {$EXTERNALSYM LDAP_OPT_DNSDOMAIN_NAME}
  808. LDAP_OPT_DNSDOMAIN_NAME = $3B; // return DNS name of domain
  809. {$EXTERNALSYM LDAP_OPT_GETDSNAME_FLAGS}
  810. LDAP_OPT_GETDSNAME_FLAGS = $3D; // flags for DsGetDcName
  811. {$EXTERNALSYM LDAP_OPT_PROMPT_CREDENTIALS}
  812. LDAP_OPT_PROMPT_CREDENTIALS = $3F; // prompt for creds? currently
  813. // only for DPA & NTLM if no creds
  814. // are loaded
  815. {$EXTERNALSYM LDAP_OPT_AUTO_RECONNECT}
  816. LDAP_OPT_AUTO_RECONNECT = $91; // enable/disable autoreconnect
  817. {$EXTERNALSYM LDAP_OPT_SSPI_FLAGS}
  818. LDAP_OPT_SSPI_FLAGS = $92; // flags to pass to InitSecurityContext
  819. //
  820. // To retrieve information on an secure connection, a pointer to a
  821. // SecPkgContext_connectionInfo structure (defined in schnlsp.h) must be
  822. // passed in. On success, it is filled with relevent security information.
  823. //
  824. {$EXTERNALSYM LDAP_OPT_SSL_INFO}
  825. LDAP_OPT_SSL_INFO = $93;
  826. //
  827. // Turing on either the sign or the encrypt option prior to binding using
  828. // LDAP_AUTH_NEGOTIATE will result in the ensuing LDAP session to be signed
  829. // or encrypted using either Kerberos or NTLM (as negotiated by the underlying
  830. // security packages). Note that these options can't be used with SSL.
  831. //
  832. {$EXTERNALSYM LDAP_OPT_SIGN}
  833. LDAP_OPT_SIGN = $95;
  834. {$EXTERNALSYM LDAP_OPT_ENCRYPT}
  835. LDAP_OPT_ENCRYPT = $96;
  836. //
  837. // The user can set a preferred SASL method prior to binding using LDAP_AUTH_NEGOTIATE
  838. // We will try to use this mechanism while binding. One example is "GSSAPI".
  839. //
  840. {$EXTERNALSYM LDAP_OPT_SASL_METHOD}
  841. LDAP_OPT_SASL_METHOD = $97;
  842. //
  843. // Setting this option to LDAP_OPT_ON will instruct the library to only perform an
  844. // A-Record DNS lookup on the supplied host string. This option is OFF by default.
  845. //
  846. {$EXTERNALSYM LDAP_OPT_AREC_EXCLUSIVE}
  847. LDAP_OPT_AREC_EXCLUSIVE = $98;
  848. //
  849. // Retrieve the security context associated with the connection.
  850. //
  851. {$EXTERNALSYM LDAP_OPT_SECURITY_CONTEXT}
  852. LDAP_OPT_SECURITY_CONTEXT = $99;
  853. //
  854. // End of Microsoft only options
  855. //
  856. {$EXTERNALSYM LDAP_OPT_ON}
  857. LDAP_OPT_ON = Pointer(1);
  858. {$EXTERNALSYM LDAP_OPT_OFF}
  859. LDAP_OPT_OFF = Pointer(0);
  860. //
  861. // For chasing referrals, we extend this a bit for LDAP_OPT_REFERRALS. If
  862. // the value is not LDAP_OPT_ON or LDAP_OPT_OFF, we'll treat them as the
  863. // following :
  864. //
  865. // LDAP_CHASE_SUBORDINATE_REFERRALS : chase subordinate referrals (or
  866. // references) returned in a v3 search
  867. // LDAP_CHASE_EXTERNAL_REFERRALS : chase external referrals. These are
  868. // returned possibly on any operation except bind.
  869. //
  870. // If you OR these flags together, it's equivalent to setting referrals to
  871. // LDAP_OPT_ON.
  872. //
  873. {$EXTERNALSYM LDAP_CHASE_SUBORDINATE_REFERRALS}
  874. LDAP_CHASE_SUBORDINATE_REFERRALS = $00000020;
  875. {$EXTERNALSYM LDAP_CHASE_EXTERNAL_REFERRALS}
  876. LDAP_CHASE_EXTERNAL_REFERRALS = $00000040;
  877. //
  878. // Bind is required as the first operation to v2 servers, not so for v3
  879. // servers. See above description of authentication methods.
  880. //
  881. {$EXTERNALSYM ldap_simple_bindA}
  882. function ldap_simple_bindA(ld: PLDAP; dn, passwd: PAnsiChar): ULONG; cdecl;
  883. {$EXTERNALSYM ldap_simple_bindW}
  884. function ldap_simple_bindW(ld: PLDAP; dn, passwd: PWideChar): ULONG; cdecl;
  885. {$EXTERNALSYM ldap_simple_bind}
  886. function ldap_simple_bind(ld: PLDAP; dn, passwd: PChar): ULONG; cdecl;
  887. {$EXTERNALSYM ldap_simple_bind_sA}
  888. function ldap_simple_bind_sA(ld: PLDAP; dn, passwd: PAnsiChar): ULONG; cdecl;
  889. {$EXTERNALSYM ldap_simple_bind_sW}
  890. function ldap_simple_bind_sW(ld: PLDAP; dn, passwd: PWideChar): ULONG; cdecl;
  891. {$EXTERNALSYM ldap_simple_bind_s}
  892. function ldap_simple_bind_s(ld: PLDAP; dn, passwd: PChar): ULONG; cdecl;
  893. {$EXTERNALSYM ldap_bindA}
  894. function ldap_bindA(ld: PLDAP; dn, cred: PAnsiChar; method: ULONG): ULONG; cdecl;
  895. {$EXTERNALSYM ldap_bindW}
  896. function ldap_bindW(ld: PLDAP; dn, cred: PWideChar; method: ULONG): ULONG; cdecl;
  897. {$EXTERNALSYM ldap_bind}
  898. function ldap_bind(ld: PLDAP; dn, cred: PChar; method: ULONG): ULONG; cdecl;
  899. {$EXTERNALSYM ldap_bind_sA}
  900. function ldap_bind_sA(ld: PLDAP; dn, cred: PAnsiChar; method: ULONG): ULONG; cdecl;
  901. {$EXTERNALSYM ldap_bind_sW}
  902. function ldap_bind_sW(ld: PLDAP; dn, cred: PWideChar; method: ULONG): ULONG; cdecl;
  903. {$EXTERNALSYM ldap_bind_s}
  904. function ldap_bind_s(ld: PLDAP; dn, cred: PChar; method: ULONG): ULONG; cdecl;
  905. // The following functions can be used to pass in any arbitrary credentials
  906. // to the server. The application must be ready to interpret the response
  907. // sent back from the server.
  908. //
  909. {$EXTERNALSYM ldap_sasl_bindA}
  910. function ldap_sasl_bindA(ExternalHandle: PLDAP; DistName: PAnsiChar;
  911. AuthMechanism: PAnsiChar; cred: PBERVAL;
  912. var ServerCtrls, ClientCtrls: PLDAPControlA;
  913. var MessageNumber: Integer): Integer; cdecl;
  914. {$EXTERNALSYM ldap_sasl_bindW}
  915. function ldap_sasl_bindW(ExternalHandle: PLDAP; DistName: PWideChar;
  916. AuthMechanism: PWideChar; cred: PBERVAL;
  917. var ServerCtrls, ClientCtrls: PLDAPControlW;
  918. var MessageNumber: Integer): Integer; cdecl;
  919. {$EXTERNALSYM ldap_sasl_bind}
  920. function ldap_sasl_bind(ExternalHandle: PLDAP; DistName: PChar;
  921. AuthMechanism: PChar; cred: PBERVAL;
  922. var ServerCtrls, ClientCtrls: PLDAPControl;
  923. var MessageNumber: Integer): Integer; cdecl;
  924. function ldap_sasl_bind_sA(ExternalHandle: PLDAP; DistName: PAnsiChar;
  925. AuthMechanism: PAnsiChar; cred: PBERVAL;
  926. var ServerCtrls, ClientCtrls: PLDAPControlA;
  927. var ServerData: PBERVAL): Integer; cdecl;
  928. function ldap_sasl_bind_sW(ExternalHandle: PLDAP; DistName: PWideChar;
  929. AuthMechanism: PWideChar; cred: PBERVAL;
  930. var ServerCtrls, ClientCtrls: PLDAPControlW;
  931. var ServerData: PBERVAL): Integer; cdecl;
  932. function ldap_sasl_bind_s(ExternalHandle: PLDAP; DistName: PChar;
  933. AuthMechanism: PChar; cred: PBERVAL;
  934. var ServerCtrls, ClientCtrls: PLDAPControl;
  935. var ServerData: PBERVAL): Integer; cdecl;
  936. //
  937. // Synchronous and asynch search routines.
  938. //
  939. // filter follows RFC 1960 with the addition that '(' ')' '*' ' ' '\' and
  940. // '\0' are all escaped with '\'
  941. //
  942. // Scope of search. This corresponds to the "scope" parameter on search
  943. const
  944. {$EXTERNALSYM LDAP_SCOPE_BASE}
  945. LDAP_SCOPE_BASE = $00;
  946. {$EXTERNALSYM LDAP_SCOPE_ONELEVEL}
  947. LDAP_SCOPE_ONELEVEL = $01;
  948. {$EXTERNALSYM LDAP_SCOPE_SUBTREE}
  949. LDAP_SCOPE_SUBTREE = $02;
  950. {$EXTERNALSYM ldap_searchA}
  951. function ldap_searchA(
  952. ld: PLDAP;
  953. base: PAnsiChar; // distinguished name or ''
  954. scope: ULONG; // LDAP_SCOPE_xxxx
  955. filter: PAnsiChar;
  956. attrs: PAnsiChar; // pointer to an array of PAnsiChar attribute names
  957. attrsonly: ULONG // boolean on whether to only return attr names
  958. ): ULONG; cdecl;
  959. {$EXTERNALSYM ldap_searchW}
  960. function ldap_searchW(
  961. ld: PLDAP;
  962. base: PWideChar; // distinguished name or ''
  963. scope: ULONG; // LDAP_SCOPE_xxxx
  964. filter: PWideChar;
  965. attrs: PWideChar; // pointer to an array of PAnsiChar attribute names
  966. attrsonly: ULONG // boolean on whether to only return attr names
  967. ): ULONG; cdecl;
  968. {$EXTERNALSYM ldap_search}
  969. function ldap_search(
  970. ld: PLDAP;
  971. base: PChar; // distinguished name or ''
  972. scope: ULONG; // LDAP_SCOPE_xxxx
  973. filter: PChar;
  974. attrs: PChar; // pointer to an array of PAnsiChar attribute names
  975. attrsonly: ULONG // boolean on whether to only return attr names
  976. ): ULONG; cdecl;
  977. {$EXTERNALSYM ldap_search_sA}
  978. function ldap_search_sA(ld: PLDAP; base: PAnsiChar; scope: ULONG;
  979. filter, attrs: PAnsiChar; attrsonly: ULONG;
  980. var res: PLDAPMessage): ULONG; cdecl;
  981. {$EXTERNALSYM ldap_search_sW}
  982. function ldap_search_sW(ld: PLDAP; base: PWideChar; scope: ULONG;
  983. filter, attrs: PWideChar; attrsonly: ULONG;
  984. var res: PLDAPMessage): ULONG; cdecl;
  985. {$EXTERNALSYM ldap_search_s}
  986. function ldap_search_s(ld: PLDAP; base: PChar; scope: ULONG;
  987. filter, attrs: PChar; attrsonly: ULONG;
  988. var res: PLDAPMessage): ULONG; cdecl;
  989. {$EXTERNALSYM ldap_search_stA}
  990. function ldap_search_stA(ld: PLDAP; base: PAnsiChar; scope: ULONG;
  991. filter, attrs: PAnsiChar; attrsonly: ULONG; var timeout: TLDAPTimeVal;
  992. var res: PLDAPMessage): ULONG; cdecl;
  993. {$EXTERNALSYM ldap_search_stW}
  994. function ldap_search_stW(ld: PLDAP; base: PWideChar; scope: ULONG;
  995. filter, attrs: PWideChar; attrsonly: ULONG; var timeout: TLDAPTimeVal;
  996. var res: PLDAPMessage): ULONG; cdecl;
  997. {$EXTERNALSYM ldap_search_st}
  998. function ldap_search_st(ld: PLDAP; base: PChar; scope: ULONG;
  999. filter, attrs: PChar; attrsonly: ULONG; var timeout: TLDAPTimeVal;
  1000. var res: PLDAPMessage): ULONG; cdecl;
  1001. {$EXTERNALSYM ldap_search_extA}
  1002. function ldap_search_extA(ld: PLDAP; base: PAnsiChar; scope: ULONG;
  1003. filter, attrs: PAnsiChar; attrsonly: ULONG;
  1004. var ServerControls, ClientControls: PLDAPControlA;
  1005. TimeLimit, SizeLimit: ULONG; var MessageNumber: ULONG): ULONG; cdecl;
  1006. {$EXTERNALSYM ldap_search_extW}
  1007. function ldap_search_extW(ld: PLDAP; base: PWideChar; scope: ULONG;
  1008. filter, attrs: PWideChar; attrsonly: ULONG;
  1009. var ServerControls, ClientControls: PLDAPControlW;
  1010. TimeLimit, SizeLimit: ULONG; var MessageNumber: ULONG): ULONG; cdecl;
  1011. {$EXTERNALSYM ldap_search_ext}
  1012. function ldap_search_ext(ld: PLDAP; base: PChar; scope: ULONG;
  1013. filter, attrs: PChar; attrsonly: ULONG;
  1014. ServerControls, ClientControls: PPLDAPControl;
  1015. TimeLimit, SizeLimit: ULONG; var MessageNumber: ULONG): ULONG; cdecl;
  1016. {$EXTERNALSYM ldap_search_ext_sA}
  1017. function ldap_search_ext_sA(ld: PLDAP; base: PAnsiChar; scope: ULONG;
  1018. filter, attrs: PAnsiChar; attrsonly: ULONG;
  1019. var ServerControls, ClientControls: PLDAPControlA;
  1020. var timeout: TLDAPTimeVal; SizeLimit: ULONG;
  1021. var res: PLDAPMessage): ULONG; cdecl;
  1022. {$EXTERNALSYM ldap_search_ext_sW}
  1023. function ldap_search_ext_sW(ld: PLDAP; base: PWideChar; scope: ULONG;
  1024. filter, attrs: PWideChar; attrsonly: ULONG;
  1025. var ServerControls, ClientControls: PLDAPControlW;
  1026. var timeout: TLDAPTimeVal; SizeLimit: ULONG;
  1027. var res: PLDAPMessage): ULONG; cdecl;
  1028. {$EXTERNALSYM ldap_search_ext_s}
  1029. function ldap_search_ext_s(ld: PLDAP; base: PChar; scope: ULONG;
  1030. filter, attrs: PChar; attrsonly: ULONG;
  1031. ServerControls, ClientControls: PPLDAPControl;
  1032. timeout: PLDAPTimeVal; SizeLimit: ULONG;
  1033. var res: PLDAPMessage): ULONG; cdecl;
  1034. //
  1035. // Extended API to check filter syntax. Returns LDAP error code if syntax
  1036. // is invalid or LDAP_SUCCESS if it's ok.
  1037. //
  1038. {$EXTERNALSYM ldap_check_filterA}
  1039. function ldap_check_filterA(ld: PLDAP; SearchFilter: PAnsiChar): ULONG; cdecl;
  1040. {$EXTERNALSYM ldap_check_filterW}
  1041. function ldap_check_filterW(ld: PLDAP; SearchFilter: PWideChar): ULONG; cdecl;
  1042. {$EXTERNALSYM ldap_check_filter}
  1043. function ldap_check_filter(ld: PLDAP; SearchFilter: PChar): ULONG; cdecl;
  1044. //
  1045. // modify an existing entry
  1046. //
  1047. //
  1048. // multi-thread: ldap_modify calls are not safe in that the message number
  1049. // is returned rather than the return code. You have to look
  1050. // at the connection block in an error case and the return code
  1051. // may be overwritten by another thread inbetween.
  1052. //
  1053. // Use ldap_modify_ext instead, as these are thread safe.
  1054. //
  1055. // ldap_modify_s and ldap_modify_ext* calls are thread safe.
  1056. //
  1057. {$EXTERNALSYM ldap_modifyA}
  1058. function ldap_modifyA(ld: PLDAP; dn: PAnsiChar; var mods: PLDAPModA): ULONG; cdecl;
  1059. {$EXTERNALSYM ldap_modifyW}
  1060. function ldap_modifyW(ld: PLDAP; dn: PWideChar; var mods: PLDAPModW): ULONG; cdecl;
  1061. {$EXTERNALSYM ldap_modify}
  1062. function ldap_modify(ld: PLDAP; dn: PChar; var mods: PLDAPMod): ULONG; cdecl;
  1063. {$EXTERNALSYM ldap_modify_sA}
  1064. function ldap_modify_sA(ld: PLDAP; dn: PAnsiChar; var mods: PLDAPModA): ULONG; cdecl;
  1065. {$EXTERNALSYM ldap_modify_sW}
  1066. function ldap_modify_sW(ld: PLDAP; dn: PWideChar; var mods: PLDAPModW): ULONG; cdecl;
  1067. {$EXTERNALSYM ldap_modify_s}
  1068. function ldap_modify_s(ld: PLDAP; dn: PChar; var mods: PLDAPMod): ULONG; cdecl;
  1069. {$EXTERNALSYM ldap_modify_extA}
  1070. function ldap_modify_extA(ld: PLDAP; dn: PAnsiChar; var mods: PLDAPModA;
  1071. var ServerControls, ClientControls: PLDAPControlA;
  1072. var MessageNumber: ULONG): ULONG; cdecl;
  1073. {$EXTERNALSYM ldap_modify_extW}
  1074. function ldap_modify_extW(ld: PLDAP; dn: PWideChar; var mods: PLDAPModW;
  1075. var ServerControls, ClientControls: PLDAPControlW;
  1076. var MessageNumber: ULONG): ULONG; cdecl;
  1077. {$EXTERNALSYM ldap_modify_ext}
  1078. function ldap_modify_ext(ld: PLDAP; dn: PChar; var mods: PLDAPMod;
  1079. var ServerControls, ClientControls: PLDAPControl;
  1080. var MessageNumber: ULONG): ULONG; cdecl;
  1081. {$EXTERNALSYM ldap_modify_ext_sA}
  1082. function ldap_modify_ext_sA(ld: PLDAP; dn: PAnsiChar; var mods: PLDAPModA;
  1083. var ServerControls, ClientControls: PLDAPControlA): ULONG; cdecl;
  1084. {$EXTERNALSYM ldap_modify_ext_sW}
  1085. function ldap_modify_ext_sW(ld: PLDAP; dn: PWideChar; var mods: PLDAPModW;
  1086. var ServerControls, ClientControls: PLDAPControlW): ULONG; cdecl;
  1087. {$EXTERNALSYM ldap_modify_ext_s}
  1088. function ldap_modify_ext_s(ld: PLDAP; dn: PChar; var mods: PLDAPMod;
  1089. var ServerControls, ClientControls: PLDAPControl): ULONG; cdecl;
  1090. //
  1091. // modrdn and modrdn2 function both as RenameObject and MoveObject.
  1092. //
  1093. // Note that to LDAP v2 servers, only rename within a given container
  1094. // is supported... therefore NewDistinguishedName is actually NewRDN.
  1095. // Here are some examples :
  1096. //
  1097. // This works to both v2 and v3 servers :
  1098. //
  1099. // DN = CN=Bob,OU=FOO,O=BAR
  1100. // NewDN = CN=Joe
  1101. //
  1102. // result is: CN=Joe,OU=FOO,O=BAR
  1103. //
  1104. // This works to only v3 and above servers :
  1105. //
  1106. // DN = CN=Bob,OU=FOO,O=BAR
  1107. // NewDN = CN=Joe,OU=FOOBAR,O=BAR
  1108. //
  1109. // result is: CN=Joe,OU=FOOBAR,O=BAR
  1110. //
  1111. // If you try the second example to a v2 server, we'll send the whole
  1112. // NewDN over as the new RDN(rather than break up the parent OU and
  1113. // child). The server will then give you back some unknown error.
  1114. //
  1115. //
  1116. // multi-thread: ldap_modrdn and ldap_modrdn2 calls are not safe in that
  1117. // the message number is returned rather than the return code.
  1118. // You have to look at the connection block in an error case
  1119. // and the return code may be overwritten by another thread
  1120. // inbetween.
  1121. //
  1122. // Use ldap_rename_ext instead, as these are thread safe.
  1123. //
  1124. {$EXTERNALSYM ldap_modrdn2A}
  1125. function ldap_modrdn2A(var ExternalHandle: LDAP;
  1126. DistinguishedName, NewDistinguishedName: PAnsiChar;
  1127. DeleteOldRdn: Integer): ULONG; cdecl;
  1128. {$EXTERNALSYM ldap_modrdn2W}
  1129. function ldap_modrdn2W(var ExternalHandle: LDAP;
  1130. DistinguishedName, NewDistinguishedName: PWideChar;
  1131. DeleteOldRdn: Integer): ULONG; cdecl;
  1132. {$EXTERNALSYM ldap_modrdn2}
  1133. function ldap_modrdn2(var ExternalHandle: LDAP;
  1134. DistinguishedName, NewDistinguishedName: PChar;
  1135. DeleteOldRdn: Integer): ULONG; cdecl;
  1136. //
  1137. // ldap_modrdn simply calls ldap_modrdn2 with a value of 1 for DeleteOldRdn.
  1138. //
  1139. {$EXTERNALSYM ldap_modrdnA}
  1140. function ldap_modrdnA(var ExternalHandle: LDAP;
  1141. DistinguishedName, NewDistinguishedName: PAnsiChar): ULONG; cdecl;
  1142. {$EXTERNALSYM ldap_modrdnW}
  1143. function ldap_modrdnW(var ExternalHandle: LDAP;
  1144. DistinguishedName, NewDistinguishedName: PWideChar): ULONG; cdecl;
  1145. {$EXTERNALSYM ldap_modrdn}
  1146. function ldap_modrdn(var ExternalHandle: LDAP;
  1147. DistinguishedName, NewDistinguishedName: PChar): ULONG; cdecl;
  1148. {$EXTERNALSYM ldap_modrdn2_sA}
  1149. function ldap_modrdn2_sA(var ExternalHandle: LDAP;
  1150. DistinguishedName, NewDistinguishedName: PAnsiChar;
  1151. DeleteOldRdn: Integer): ULONG; cdecl;
  1152. {$EXTERNALSYM ldap_modrdn2_sW}
  1153. function ldap_modrdn2_sW(var ExternalHandle: LDAP;
  1154. DistinguishedName, NewDistinguishedName: PWideChar;
  1155. DeleteOldRdn: Integer): ULONG; cdecl;
  1156. {$EXTERNALSYM ldap_modrdn2_s}
  1157. function ldap_modrdn2_s(var ExternalHandle: LDAP;
  1158. DistinguishedName, NewDistinguishedName: PChar;
  1159. DeleteOldRdn: Integer): ULONG; cdecl;
  1160. {$EXTERNALSYM ldap_modrdn_sA}
  1161. function ldap_modrdn_sA(var ExternalHandle: LDAP;
  1162. DistinguishedName, NewDistinguishedName: PAnsiChar): ULONG; cdecl;
  1163. {$EXTERNALSYM ldap_modrdn_sW}
  1164. function ldap_modrdn_sW(var ExternalHandle: LDAP;
  1165. DistinguishedName, NewDistinguishedName: PWideChar): ULONG; cdecl;
  1166. {$EXTERNALSYM ldap_modrdn_s}
  1167. function ldap_modrdn_s(var ExternalHandle: LDAP;
  1168. DistinguishedName, NewDistinguishedName: PChar): ULONG; cdecl;
  1169. //
  1170. // Extended Rename operations. These take controls and separate out the
  1171. // parent from the RDN, for clarity.
  1172. //
  1173. {$EXTERNALSYM ldap_rename_extA}
  1174. function ldap_rename_extA(ld: PLDAP; dn, NewRDN, NewParent: PAnsiChar;
  1175. DeleteOldRdn: Integer; var ServerControls, ClientControls: PLDAPControlA;
  1176. var MessageNumber: ULONG): ULONG; cdecl;
  1177. {$EXTERNALSYM ldap_rename_extW}
  1178. function ldap_rename_extW(ld: PLDAP; dn, NewRDN, NewParent: PWideChar;
  1179. DeleteOldRdn: Integer; var ServerControls, ClientControls: PLDAPControlW;
  1180. var MessageNumber: ULONG): ULONG; cdecl;
  1181. {$EXTERNALSYM ldap_rename_ext}
  1182. function ldap_rename_ext(ld: PLDAP; dn, NewRDN, NewParent: PChar;
  1183. DeleteOldRdn: Integer; var ServerControls, ClientControls: PLDAPControl;
  1184. var MessageNumber: ULONG): ULONG; cdecl;
  1185. {$EXTERNALSYM ldap_rename_ext_sA}
  1186. function ldap_rename_ext_sA(ld: PLDAP;
  1187. dn, NewRDN, NewParent: PAnsiChar; DeleteOldRdn: Integer;
  1188. var ServerControls, ClientControls: PLDAPControlA): ULONG; cdecl;
  1189. {$EXTERNALSYM ldap_rename_ext_sW}
  1190. function ldap_rename_ext_sW(ld: PLDAP;
  1191. dn, NewRDN, NewParent: PWideChar; DeleteOldRdn: Integer;
  1192. var ServerControls, ClientControls: PLDAPControlW): ULONG; cdecl;
  1193. {$EXTERNALSYM ldap_rename_ext_s}
  1194. function ldap_rename_ext_s(ld: PLDAP;
  1195. dn, NewRDN, NewParent: PChar; DeleteOldRdn: Integer;
  1196. var ServerControls, ClientControls: PLDAPControl): ULONG; cdecl;
  1197. //
  1198. // Add an entry to the tree
  1199. //
  1200. //
  1201. // multi-thread: ldap_add calls are not safe in that the message number
  1202. // is returned rather than the return code. You have to look
  1203. // at the connection block in an error case and the return code
  1204. // may be overwritten by another thread inbetween.
  1205. //
  1206. // Use ldap_add_ext instead, as these are thread safe.
  1207. //
  1208. // ldap_add_s and ldap_add_ext* calls are thread safe.
  1209. //
  1210. {$EXTERNALSYM ldap_addA}
  1211. function ldap_addA(ld: PLDAP; dn: PAnsiChar; var attrs: PLDAPModA): ULONG; cdecl;
  1212. {$EXTERNALSYM ldap_addW}
  1213. function ldap_addW(ld: PLDAP; dn: PWideChar; var attrs: PLDAPModW): ULONG; cdecl;
  1214. {$EXTERNALSYM ldap_add}
  1215. function ldap_add(ld: PLDAP; dn: PChar; var attrs: PLDAPMod): ULONG; cdecl;
  1216. {$EXTERNALSYM ldap_add_sA}
  1217. function ldap_add_sA(ld: PLDAP; dn: PAnsiChar; var attrs: PLDAPModA): ULONG; cdecl;
  1218. {$EXTERNALSYM ldap_add_sW}
  1219. function ldap_add_sW(ld: PLDAP; dn: PWideChar; var attrs: PLDAPModW): ULONG; cdecl;
  1220. {$EXTERNALSYM ldap_add_s}
  1221. function ldap_add_s(ld: PLDAP; dn: PChar; var attrs: PLDAPMod): ULONG; cdecl;
  1222. {$EXTERNALSYM ldap_add_extA}
  1223. function ldap_add_extA(ld: PLDAP; dn: PAnsiChar; var attrs: PLDAPModA;
  1224. var ServerControls, ClientControls: PLDAPControlA;
  1225. var MessageNumber: ULONG): ULONG; cdecl;
  1226. {$EXTERNALSYM ldap_add_extW}
  1227. function ldap_add_extW(ld: PLDAP; dn: PWideChar; var attrs: PLDAPModW;
  1228. var ServerControls, ClientControls: PLDAPControlW;
  1229. var MessageNumber: ULONG): ULONG; cdecl;
  1230. {$EXTERNALSYM ldap_add_ext}
  1231. function ldap_add_ext(ld: PLDAP; dn: PChar; var attrs: PLDAPMod;
  1232. var ServerControls, ClientControls: PLDAPControl;
  1233. var MessageNumber: ULONG): ULONG; cdecl;
  1234. {$EXTERNALSYM ldap_add_ext_sA}
  1235. function ldap_add_ext_sA(ld: PLDAP; dn: PAnsiChar; var attrs: PLDAPModA;
  1236. var ServerControls, ClientControls: PLDAPControlA): ULONG; cdecl;
  1237. {$EXTERNALSYM ldap_add_ext_sW}
  1238. function ldap_add_ext_sW(ld: PLDAP; dn: PWideChar; var attrs: PLDAPModW;
  1239. var ServerControls, ClientControls: PLDAPControlW): ULONG; cdecl;
  1240. {$EXTERNALSYM ldap_add_ext_s}
  1241. function ldap_add_ext_s(ld: PLDAP; dn: PChar; var attrs: PLDAPMod;
  1242. var ServerControls, ClientControls: PLDAPControl): ULONG; cdecl;
  1243. //
  1244. // Compare the attribute for a given entry to a known value.
  1245. //
  1246. {$EXTERNALSYM ldap_compareA}
  1247. function ldap_compareA(ld: PLDAP; dn, attr, value: PAnsiChar): ULONG; cdecl;
  1248. {$EXTERNALSYM ldap_compareW}
  1249. function ldap_compareW(ld: PLDAP; dn, attr, value: PWideChar): ULONG; cdecl;
  1250. {$EXTERNALSYM ldap_compare}
  1251. function ldap_compare(ld: PLDAP; dn, attr, value: PChar): ULONG; cdecl;
  1252. {$EXTERNALSYM ldap_compare_sA}
  1253. function ldap_compare_sA(ld: PLDAP; dn, attr, value: PAnsiChar): ULONG; cdecl;
  1254. {$EXTERNALSYM ldap_compare_sW}
  1255. function ldap_compare_sW(ld: PLDAP; dn, attr, value: PWideChar): ULONG; cdecl;
  1256. {$EXTERNALSYM ldap_compare_s}
  1257. function ldap_compare_s(ld: PLDAP; dn, attr, value: PChar): ULONG; cdecl;
  1258. //
  1259. // Extended Compare operations. These take controls and are thread safe.
  1260. // They also allow you to specify a bval structure for the data, so that it
  1261. // isn't translated from Unicode or ANSI to UTF8. Allows for comparison of
  1262. // raw binary data.
  1263. //
  1264. // Specify either Data or Value as not NULL. If both are not NULL, the
  1265. // berval Data will be used.
  1266. //
  1267. // either value or Data is not null, not both
  1268. {$EXTERNALSYM ldap_compare_extA}
  1269. function ldap_compare_extA(ld: PLDAP; dn, Attr, Value: PAnsiChar;
  1270. Data: PLDAPBerVal; var ServerControls, ClientControls: PLDAPControlA;
  1271. var MessageNumber: ULONG): ULONG; cdecl;
  1272. {$EXTERNALSYM ldap_compare_extW}
  1273. function ldap_compare_extW(ld: PLDAP; dn, Attr, Value: PWideChar;
  1274. Data: PLDAPBerVal; var ServerControls, ClientControls: PLDAPControlW;
  1275. var MessageNumber: ULONG): ULONG; cdecl;
  1276. {$EXTERNALSYM ldap_compare_ext}
  1277. function ldap_compare_ext(ld: PLDAP; dn, Attr, Value: PChar;
  1278. Data: PLDAPBerVal; var ServerControls, ClientControls: PLDAPControl;
  1279. var MessageNumber: ULONG): ULONG; cdecl;
  1280. {$EXTERNALSYM ldap_compare_ext_sA}
  1281. function ldap_compare_ext_sA(ld: PLDAP;
  1282. dn, Attr, Value: PAnsiChar; Data: PLDAPBerVal;
  1283. var ServerControls, ClientControls: PLDAPControlA): ULONG; cdecl;
  1284. {$EXTERNALSYM ldap_compare_ext_sW}
  1285. function ldap_compare_ext_sW(ld: PLDAP;
  1286. dn, Attr, Value: PWideChar; Data: PLDAPBerVal;
  1287. var ServerControls, ClientControls: PLDAPControlW): ULONG; cdecl;
  1288. {$EXTERNALSYM ldap_compare_ext_s}
  1289. function ldap_compare_ext_s(ld: PLDAP;
  1290. dn, Attr, Value: PChar; Data: PLDAPBerVal;
  1291. var ServerControls, ClientControls: PLDAPControl): ULONG; cdecl;
  1292. //
  1293. // Delete an object out of the tree
  1294. //
  1295. //
  1296. // multi-thread: ldap_delete calls are not safe in that the message number
  1297. // is returned rather than the return code. You have to look
  1298. // at the connection block in an error case and the return code
  1299. // may be overwritten by another thread inbetween.
  1300. //
  1301. // Use ldap_delete_ext instead, as these are thread safe.
  1302. //
  1303. // ldap_delete_s and ldap_delete_ext* calls are thread safe.
  1304. //
  1305. {$EXTERNALSYM ldap_deleteA}
  1306. function ldap_deleteA(ld: PLDAP; dn: PAnsiChar): ULONG; cdecl;
  1307. {$EXTERNALSYM ldap_deleteW}
  1308. function ldap_deleteW(ld: PLDAP; dn: PWideChar): ULONG; cdecl;
  1309. {$EXTERNALSYM ldap_delete}
  1310. function ldap_delete(ld: PLDAP; dn: PChar): ULONG; cdecl;
  1311. {$EXTERNALSYM ldap_delete_sA}
  1312. function ldap_delete_sA(ld: PLDAP; dn: PAnsiChar): ULONG; cdecl;
  1313. {$EXTERNALSYM ldap_delete_sW}
  1314. function ldap_delete_sW(ld: PLDAP; dn: PWideChar): ULONG; cdecl;
  1315. {$EXTERNALSYM ldap_delete_s}
  1316. function ldap_delete_s(ld: PLDAP; dn: PChar): ULONG; cdecl;
  1317. {$EXTERNALSYM ldap_delete_extA}
  1318. function ldap_delete_extA(ld: PLDAP; dn: PAnsiChar;
  1319. var ServerControls, ClientControls: PLDAPControlA;
  1320. var MessageNumber: ULONG): ULONG; cdecl;
  1321. {$EXTERNALSYM ldap_delete_extW}
  1322. function ldap_delete_extW(ld: PLDAP; dn: PWideChar;
  1323. var ServerControls, ClientControls: PLDAPControlW;
  1324. var MessageNumber: ULONG): ULONG; cdecl;
  1325. {$EXTERNALSYM ldap_delete_ext}
  1326. function ldap_delete_ext(ld: PLDAP; dn: PChar;
  1327. var ServerControls, ClientControls: PLDAPControl;
  1328. var MessageNumber: ULONG): ULONG; cdecl;
  1329. {$EXTERNALSYM ldap_delete_ext_sA}
  1330. function ldap_delete_ext_sA(ld: PLDAP; dn: PAnsiChar;
  1331. var ServerControls, ClientControls: PLDAPControlA): ULONG; cdecl;
  1332. {$EXTERNALSYM ldap_delete_ext_sW}
  1333. function ldap_delete_ext_sW(ld: PLDAP; dn: PWideChar;
  1334. var ServerControls, ClientControls: PLDAPControlW): ULONG; cdecl;
  1335. {$EXTERNALSYM ldap_delete_ext_s}
  1336. function ldap_delete_ext_s(ld: PLDAP; dn: PChar;
  1337. var ServerControls, ClientControls: PLDAPControl): ULONG; cdecl;
  1338. //
  1339. // Give up on a request. No guarentee that it got there as there is no
  1340. // response from the server.
  1341. //
  1342. {$EXTERNALSYM ldap_abandon}
  1343. function ldap_abandon(ld: PLDAP; msgid: ULONG): ULONG; cdecl;
  1344. //
  1345. // Possible values for "all" field in ldap_result. We've enhanced it such
  1346. // that if someone passes in LDAP_MSG_RECEIVED, we'll pass all values we've
  1347. // received up to that point.
  1348. //
  1349. const
  1350. {$EXTERNALSYM LDAP_MSG_ONE}
  1351. LDAP_MSG_ONE = 0;
  1352. {$EXTERNALSYM LDAP_MSG_ALL}
  1353. LDAP_MSG_ALL = 1;
  1354. {$EXTERNALSYM LDAP_MSG_RECEIVED}
  1355. LDAP_MSG_RECEIVED = 2;
  1356. //
  1357. // Get a response from a connection. One enhancement here is that ld can
  1358. // be null, in which case we'll return responses from any server. Free
  1359. // responses here with ldap_msgfree.
  1360. //
  1361. // For connection-less LDAP, you should pass in both a LDAP connection
  1362. // handle and a msgid. This will ensure we know which request the app
  1363. // is waiting on a reply to. (we actively resend request until we get
  1364. // a response.)
  1365. //
  1366. {$EXTERNALSYM ldap_result}
  1367. function ldap_result(ld: PLDAP; msgid, all: ULONG;
  1368. timeout: PLDAP_TIMEVAL; var res: PLDAPMessage): ULONG; cdecl;
  1369. {$EXTERNALSYM ldap_msgfree}
  1370. function ldap_msgfree(res: PLDAPMessage): ULONG; cdecl;
  1371. //
  1372. // This parses a message and returns the error code. It optionally frees
  1373. // the message by calling ldap_msgfree.
  1374. //
  1375. // multi-thread: ldap_result2error call is thread safe
  1376. // freeit is boolean.. free the message?
  1377. {$EXTERNALSYM ldap_result2error}
  1378. function ldap_result2error(ld: PLDAP; res: PLDAPMessage;
  1379. freeit: ULONG): ULONG; cdecl;
  1380. //
  1381. // Similar to ldap_result2error, this parses responses from the server and
  1382. // returns the appropriate fields. Use this one if you want to get at the
  1383. // referrals, matchingDNs, or server controls returned.
  1384. //
  1385. // multi-thread: ldap_parse_result call is thread safe
  1386. {$EXTERNALSYM ldap_parse_resultA}
  1387. function ldap_parse_resultA (
  1388. var Connection: LDAP;
  1389. ResultMessage: PLDAPMessage;
  1390. ReturnCode: PULONG; // returned by server
  1391. MatchedDNs: PPCharA; // free with ldap_memfree
  1392. ErrorMessage: PPCharA; // free with ldap_memfree
  1393. Referrals: PPPCharA; // free with ldap_value_freeW
  1394. var ServerControls: PPLDAPControlA; // free with ldap_free_controlsW
  1395. Freeit: BOOL): ULONG; cdecl;
  1396. {$EXTERNALSYM ldap_parse_resultW}
  1397. function ldap_parse_resultW (
  1398. var Connection: LDAP;
  1399. ResultMessage: PLDAPMessage;
  1400. ReturnCode: PULONG; // returned by server
  1401. MatchedDNs: PPCharW; // free with ldap_memfree
  1402. ErrorMessage: PPCharW; // free with ldap_memfree
  1403. Referrals: PPPCharW; // free with ldap_value_freeW
  1404. var ServerControls: PPLDAPControlW; // free with ldap_free_controlsW
  1405. Freeit: BOOL): ULONG; cdecl;
  1406. {$EXTERNALSYM ldap_parse_result}
  1407. function ldap_parse_result (
  1408. var Connection: LDAP;
  1409. ResultMessage: PLDAPMessage;
  1410. ReturnCode: PULONG; // returned by server
  1411. MatchedDNs: PPChar; // free with ldap_memfree
  1412. ErrorMessage: PPChar; // free with ldap_memfree
  1413. Referrals: PPPChar; // free with ldap_value_freeW
  1414. var ServerControls: PPLDAPControl; // free with ldap_free_controlsW
  1415. Freeit: BOOL): ULONG; cdecl;
  1416. {$EXTERNALSYM ldap_controls_freeA}
  1417. function ldap_controls_freeA(var Controls: PLDAPControlA): ULONG; cdecl;
  1418. {$EXTERNALSYM ldap_controls_freeW}
  1419. function ldap_controls_freeW(var Controls: PLDAPControlW): ULONG; cdecl;
  1420. {$EXTERNALSYM ldap_controls_free}
  1421. function ldap_controls_free(var Controls: PLDAPControl): ULONG; cdecl;
  1422. {$EXTERNALSYM ldap_parse_extended_resultA}
  1423. function ldap_parse_extended_resultA(
  1424. Connection: PLDAP;
  1425. ResultMessage: PLDAPMessage; // returned by server
  1426. var ResultOID: PAnsiChar; // free with ldap_memfree
  1427. var ResultData: PBERVAL; // free with ldap_memfree
  1428. Freeit: ByteBool // Don't need the message anymore
  1429. ): ULONG; cdecl;
  1430. {$EXTERNALSYM ldap_parse_extended_resultW}
  1431. function ldap_parse_extended_resultW(
  1432. Connection: PLDAP;
  1433. ResultMessage: PLDAPMessage; // returned by server
  1434. var ResultOID: PWideChar; // free with ldap_memfree
  1435. var ResultData: PBERVAL; // free with ldap_memfree
  1436. Freeit: ByteBool // Don't need the message anymore
  1437. ): ULONG; cdecl;
  1438. {$EXTERNALSYM ldap_parse_extended_result}
  1439. function ldap_parse_extended_result(
  1440. Connection: PLDAP;
  1441. ResultMessage: PLDAPMessage; // returned by server
  1442. var ResultOID: PChar; // free with ldap_memfree
  1443. var ResultData: PBERVAL; // free with ldap_memfree
  1444. Freeit: ByteBool // Don't need the message anymore
  1445. ): ULONG; cdecl;
  1446. {$EXTERNALSYM ldap_control_freeA}
  1447. function ldap_control_freeA(var Control: LDAPControlA): ULONG; cdecl;
  1448. {$EXTERNALSYM ldap_control_freeW}
  1449. function ldap_control_freeW(var Control: LDAPControlW): ULONG; cdecl;
  1450. {$EXTERNALSYM ldap_control_free}
  1451. function ldap_control_free(var Control: LDAPControl): ULONG; cdecl;
  1452. //
  1453. // ldap_free_controls are old, use ldap_controls_free
  1454. //
  1455. {$EXTERNALSYM ldap_free_controlsA}
  1456. function ldap_free_controlsA(var Controls: PLDAPControlA): ULONG; cdecl;
  1457. {$EXTERNALSYM ldap_free_controlsW}
  1458. function ldap_free_controlsW(var Controls: PLDAPControlW): ULONG; cdecl;
  1459. {$EXTERNALSYM ldap_free_controls}
  1460. function ldap_free_controls(var Controls: PLDAPControl): ULONG; cdecl;
  1461. //
  1462. // ldap_err2string returns a pointer to a string describing the error. This
  1463. // string should not be freed.
  1464. //
  1465. {$EXTERNALSYM ldap_err2stringA}
  1466. function ldap_err2stringA(err: ULONG): PAnsiChar; cdecl;
  1467. {$EXTERNALSYM ldap_err2stringW}
  1468. function ldap_err2stringW(err: ULONG): PWideChar; cdecl;
  1469. {$EXTERNALSYM ldap_err2string}
  1470. function ldap_err2string(err: ULONG): PChar; cdecl;
  1471. //
  1472. // ldap_perror does nothing and is here just for compatibility.
  1473. //
  1474. {$EXTERNALSYM ldap_perror}
  1475. procedure ldap_perror(ld: PLDAP; msg: PChar); cdecl;
  1476. //
  1477. // Return the first entry of a message. It is freed when the message is
  1478. // freed so should not be freed explicitly.
  1479. //
  1480. {$EXTERNALSYM ldap_first_entry}
  1481. function ldap_first_entry(ld: PLDAP; res: PLDAPMessage): PLDAPMessage; cdecl;
  1482. //
  1483. // Return the next entry of a message. It is freed when the message is
  1484. // freed so should not be freed explicitly.
  1485. //
  1486. {$EXTERNALSYM ldap_next_entry}
  1487. function ldap_next_entry(ld: PLDAP; entry: PLDAPMessage): PLDAPMessage; cdecl;
  1488. //
  1489. // Count the number of search entries returned by the server in a response
  1490. // to a server request.
  1491. //
  1492. {$EXTERNALSYM ldap_count_entries}
  1493. function ldap_count_entries(ld: PLDAP; res: PLDAPMessage): ULONG; cdecl;
  1494. //
  1495. // A BerElement really maps out to a C++ class object that does BER encoding.
  1496. // Don't mess with it as it's opaque.
  1497. //
  1498. type
  1499. PBerElement = ^BerElement;
  1500. {$EXTERNALSYM BerElement}
  1501. BerElement = record
  1502. opaque: PChar; // this is an opaque structure used just for
  1503. // compatibility with reference implementation
  1504. end;
  1505. const
  1506. {$EXTERNALSYM NULLBER}
  1507. NULLBER = PBerElement(nil);
  1508. //
  1509. // For a given entry, return the first attribute. The pointer returned is
  1510. // actually a buffer in the connection block(with allowances for
  1511. // multi-threaded apps)so it should not be freed.
  1512. //
  1513. {$EXTERNALSYM ldap_first_attributeA}
  1514. function ldap_first_attributeA(ld: PLDAP; entry: PLDAPMessage;
  1515. var ptr: PBerElement): PAnsiChar; cdecl;
  1516. {$EXTERNALSYM ldap_first_attributeW}
  1517. function ldap_first_attributeW(ld: PLDAP; entry: PLDAPMessage;
  1518. var ptr: PBerElement): PWideChar; cdecl;
  1519. {$EXTERNALSYM ldap_first_attribute}
  1520. function ldap_first_attribute(ld: PLDAP; entry: PLDAPMessage;
  1521. var ptr: PBerElement): PChar; cdecl;
  1522. //
  1523. // Return the next attribute... again, the attribute pointer should not be
  1524. // freed.
  1525. //
  1526. {$EXTERNALSYM ldap_next_attributeA}
  1527. function ldap_next_attributeA(ld: PLDAP; entry: PLDAPMessage;
  1528. ptr: PBerElement): PAnsiChar; cdecl;
  1529. {$EXTERNALSYM ldap_next_attributeW}
  1530. function ldap_next_attributeW(ld: PLDAP; entry: PLDAPMessage;
  1531. ptr: PBerElement): PWideChar; cdecl;
  1532. {$EXTERNALSYM ldap_next_attribute}
  1533. function ldap_next_attribute(ld: PLDAP; entry: PLDAPMessage;
  1534. ptr: PBerElement): PChar; cdecl;
  1535. //
  1536. // Get a given attribute's list of values. This is used during parsing of
  1537. // a search response. It returns a list of pointers to values, the list is
  1538. // null terminated.
  1539. //
  1540. // If the values are generic octet strings and not null terminated strings,
  1541. // use ldap_get_values_len instead.
  1542. //
  1543. // The returned value should be freed when your done with it by calling
  1544. // ldap_value_free.
  1545. //
  1546. {$EXTERNALSYM ldap_get_valuesA}
  1547. function ldap_get_valuesA(ld: PLDAP; entry: PLDAPMessage;
  1548. attr: PAnsiChar): PPCharA; cdecl;
  1549. {$EXTERNALSYM ldap_get_valuesW}
  1550. function ldap_get_valuesW(ld: PLDAP; entry: PLDAPMessage;
  1551. attr: PWideChar): PPCharW; cdecl;
  1552. {$EXTERNALSYM ldap_get_values}
  1553. function ldap_get_values(ld: PLDAP; entry: PLDAPMessage;
  1554. attr: PChar): PPChar; cdecl;
  1555. //
  1556. // Get a given attribute's list of values. This is used during parsing of
  1557. // a search response. It returns a list of berval structures to values,
  1558. // the list is null terminated.
  1559. //
  1560. // If the values are null terminated strings, it may be easier to process them
  1561. // by calling ldap_get_values instead.
  1562. //
  1563. // The returned value should be freed when your done with it by calling
  1564. // ldap_value_free_len.
  1565. //
  1566. {$EXTERNALSYM ldap_get_values_lenA}
  1567. function ldap_get_values_lenA(ExternalHandle: PLDAP; Message: PLDAPMessage;
  1568. attr: PAnsiChar): PPLDAPBerVal; cdecl;
  1569. {$EXTERNALSYM ldap_get_values_lenW}
  1570. function ldap_get_values_lenW(ExternalHandle: PLDAP; Message: PLDAPMessage;
  1571. attr: PWideChar): PPLDAPBerVal; cdecl;
  1572. {$EXTERNALSYM ldap_get_values_len}
  1573. function ldap_get_values_len(ExternalHandle: PLDAP; Message: PLDAPMessage;
  1574. attr: PChar): PPLDAPBerVal; cdecl;
  1575. //
  1576. // Return the number of values in a list returned by ldap_get_values.
  1577. //
  1578. {$EXTERNALSYM ldap_count_valuesA}
  1579. function ldap_count_valuesA(vals: PPCharA): ULONG; cdecl;
  1580. {$EXTERNALSYM ldap_count_valuesW}
  1581. function ldap_count_valuesW(vals: PPCharW): ULONG; cdecl;
  1582. {$EXTERNALSYM ldap_count_values}
  1583. function ldap_count_values(vals: PPChar): ULONG; cdecl;
  1584. //
  1585. // Return the number of values in a list returned by ldap_get_values_len.
  1586. //
  1587. {$EXTERNALSYM ldap_count_values_len}
  1588. function ldap_count_values_len(vals: PPLDAPBerVal): ULONG; cdecl;
  1589. //
  1590. // Free structures returned by ldap_get_values.
  1591. //
  1592. {$EXTERNALSYM ldap_value_freeA}
  1593. function ldap_value_freeA(vals: PPCharA): ULONG; cdecl;
  1594. {$EXTERNALSYM ldap_value_freeW}
  1595. function ldap_value_freeW(vals: PPCharW): ULONG; cdecl;
  1596. {$EXTERNALSYM ldap_value_free}
  1597. function ldap_value_free(vals: PPChar): ULONG; cdecl;
  1598. //
  1599. // Free structures returned by ldap_get_values_len.
  1600. //
  1601. {$EXTERNALSYM ldap_value_free_len}
  1602. function ldap_value_free_len(vals: PPLDAPBerVal): ULONG; cdecl;
  1603. //
  1604. // Get the distinguished name for a given search entry. It should be freed
  1605. // by calling ldap_memfree.
  1606. //
  1607. {$EXTERNALSYM ldap_get_dnA}
  1608. function ldap_get_dnA(ld: PLDAP; entry: PLDAPMessage): PAnsiChar; cdecl;
  1609. {$EXTERNALSYM ldap_get_dnW}
  1610. function ldap_get_dnW(ld: PLDAP; entry: PLDAPMessage): PWideChar; cdecl;
  1611. {$EXTERNALSYM ldap_get_dn}
  1612. function ldap_get_dn(ld: PLDAP; entry: PLDAPMessage): PChar; cdecl;
  1613. //
  1614. // When using ldap_explode_dn, you should free the returned string by
  1615. // calling ldap_value_free.
  1616. //
  1617. {$EXTERNALSYM ldap_explode_dnA}
  1618. function ldap_explode_dnA(dn: PAnsiChar; notypes: ULONG): PPCharA; cdecl;
  1619. {$EXTERNALSYM ldap_explode_dnW}
  1620. function ldap_explode_dnW(dn: PWideChar; notypes: ULONG): PPCharW; cdecl;
  1621. {$EXTERNALSYM ldap_explode_dn}
  1622. function ldap_explode_dn(dn: PChar; notypes: ULONG): PPChar; cdecl;
  1623. //
  1624. // When calling ldap_dn2ufn, you should free the returned string by calling
  1625. // ldap_memfree.
  1626. //
  1627. {$EXTERNALSYM ldap_dn2ufnA}
  1628. function ldap_dn2ufnA(dn: PAnsiChar): PAnsiChar; cdecl;
  1629. {$EXTERNALSYM ldap_dn2ufnW}
  1630. function ldap_dn2ufnW(dn: PWideChar): PWideChar; cdecl;
  1631. {$EXTERNALSYM ldap_dn2ufn}
  1632. function ldap_dn2ufn(dn: PChar): PChar; cdecl;
  1633. //
  1634. // This is used to free strings back to the LDAP API heap. Don't pass in
  1635. // values that you've gotten from ldap_open, ldap_get_values, etc.
  1636. //
  1637. {$EXTERNALSYM ldap_memfreeA}
  1638. procedure ldap_memfreeA(Block: PAnsiChar); cdecl;
  1639. {$EXTERNALSYM ldap_memfreeW}
  1640. procedure ldap_memfreeW(Block: PWideChar); cdecl;
  1641. {$EXTERNALSYM ldap_memfree}
  1642. procedure ldap_memfree(Block: PChar); cdecl;
  1643. {$EXTERNALSYM ber_bvfree}
  1644. procedure ber_bvfree(bv: PLDAPBerVal); cdecl;
  1645. //
  1646. // The function ldap_ufn2dn attempts to "normalize" a user specified DN
  1647. // to make it "proper". It follows RFC 1781(add CN= if not present,
  1648. // add OU= if none present, etc). If it runs into any problems at all
  1649. // while normalizing, it simply returns a copy of what was passed in.
  1650. //
  1651. // It allocates the output string from the LDAP memory pool. If the pDn
  1652. // comes back as non-NULL, you should free it when you're done with a call
  1653. // to ldap_memfree.
  1654. //
  1655. {$EXTERNALSYM ldap_ufn2dnA}
  1656. function ldap_ufn2dnA(ufn: PAnsiChar; var pDn: PAnsiChar): ULONG; cdecl;
  1657. {$EXTERNALSYM ldap_ufn2dnW}
  1658. function ldap_ufn2dnW(ufn: PWideChar; var pDn: PWideChar): ULONG; cdecl;
  1659. {$EXTERNALSYM ldap_ufn2dn}
  1660. function ldap_ufn2dn(ufn: PChar; var pDn: PChar): ULONG; cdecl;
  1661. const
  1662. {$EXTERNALSYM LBER_USE_DER}
  1663. LBER_USE_DER = $01;
  1664. {$EXTERNALSYM LBER_USE_INDEFINITE_LEN}
  1665. LBER_USE_INDEFINITE_LEN = $02;
  1666. {$EXTERNALSYM LBER_TRANSLATE_STRINGS}
  1667. LBER_TRANSLATE_STRINGS = $04;
  1668. //
  1669. // Call to initialize the LDAP library. Pass in a version structure with
  1670. // lv_size set to sizeof(LDAP_VERSION), lv_major set to LAPI_MAJOR_VER1,
  1671. // and lv_minor set to LAPI_MINOR_VER1. Return value will be either
  1672. // LDAP_SUCCESS if OK or LDAP_OPERATIONS_ERROR if can't be supported.
  1673. //
  1674. {$EXTERNALSYM LAPI_MAJOR_VER1}
  1675. LAPI_MAJOR_VER1 = 1;
  1676. {$EXTERNALSYM LAPI_MINOR_VER1}
  1677. LAPI_MINOR_VER1 = 1;
  1678. type
  1679. PLDAPVersionInfo = ^TLDAPVersionInfo;
  1680. {$EXTERNALSYM PLDAP_VERSION_INFO}
  1681. PLDAP_VERSION_INFO = ^LDAP_VERSION_INFO;
  1682. {$EXTERNALSYM LDAP_VERSION_INFO}
  1683. LDAP_VERSION_INFO = record
  1684. lv_size: ULONG;
  1685. lv_major: ULONG;
  1686. lv_minor: ULONG;
  1687. end;
  1688. TLDAPVersionInfo = LDAP_VERSION_INFO;
  1689. {$EXTERNALSYM ldap_startup}
  1690. function ldap_startup(var version: TLDAPVersionInfo): ULONG; cdecl;
  1691. //
  1692. // ldap_cleanup unloads the library when the refcount of opens goes to zero.
  1693. // (i.e. if a DLL calls it within a program that is also using it, it won't
  1694. // free all resources)
  1695. //
  1696. {$EXTERNALSYM ldap_cleanup}
  1697. function ldap_cleanup(hInstance: THandle): ULONG; cdecl;
  1698. //
  1699. // Extended API to support allowing opaque blobs of data in search filters.
  1700. // This API takes any filter element and converts it to a safe text string that
  1701. // can safely be passed in a search filter.
  1702. // An example of using this is :
  1703. //
  1704. // filter is something like guid=4826BF6CF0123444
  1705. // this will put out on the wire guid of binary 0x4826BF6CF0123444
  1706. //
  1707. // call ldap_escape_filter_element with sourceFilterElement pointing to
  1708. // raw data, sourceCount set appropriately to length of data.
  1709. //
  1710. // if destFilterElement is NULL, then return value is length required for
  1711. // output buffer.
  1712. //
  1713. // if destFilterElement is not NULL, then the function will copy the source
  1714. // into the dest buffer and ensure that it is of a safe format.
  1715. //
  1716. // then simply insert the dest buffer into your search filter after the
  1717. // "attributetype=".
  1718. //
  1719. // this will put out on the wire guid of binary 0x004826BF6CF000123444
  1720. //
  1721. // Note : don't call this for attribute values that are really strings, as
  1722. // we won't do any conversion from what you passed in to UTF-8. Should only
  1723. // be used for attributes that really are raw binary.
  1724. //
  1725. {$EXTERNALSYM ldap_escape_filter_elementA}
  1726. function ldap_escape_filter_elementA(
  1727. sourceFilterElement: PChar; sourceLength: ULONG;
  1728. destFilterElement: PAnsiChar; destLength: ULONG): ULONG; cdecl;
  1729. {$EXTERNALSYM ldap_escape_filter_elementW}
  1730. function ldap_escape_filter_elementW(
  1731. sourceFilterElement: PChar; sourceLength: ULONG;
  1732. destFilterElement: PWideChar; destLength: ULONG): ULONG; cdecl;
  1733. {$EXTERNALSYM ldap_escape_filter_element}
  1734. function ldap_escape_filter_element(
  1735. sourceFilterElement: PChar; sourceLength: ULONG;
  1736. destFilterElement: PChar; destLength: ULONG): ULONG; cdecl;
  1737. //
  1738. // Misc extensions for additional debugging.
  1739. //
  1740. // Note that these do nothing on free builds.
  1741. //
  1742. {$EXTERNALSYM ldap_set_dbg_flags}
  1743. function ldap_set_dbg_flags(NewFlags: ULONG): ULONG; cdecl;
  1744. // NOTE by translator: Original function type has ellipsis, which means
  1745. // there can be var_args. Object Pascal doesn't support this, so you'll
  1746. // have to define a function that does what you want (probably using BASM
  1747. // to get the extra parameters, or linking a C function), and then cast
  1748. // that to TDbgPrint.
  1749. type
  1750. {$EXTERNALSYM DBGPRINT}
  1751. DBGPRINT = function(Format: PChar {; ...} ): ULONG cdecl;
  1752. TDbgPrint = DBGPRINT;
  1753. {$EXTERNALSYM ldap_set_dbg_routine}
  1754. procedure ldap_set_dbg_routine(DebugPrintRoutine: TDbgPrint); cdecl;
  1755. //
  1756. // These routines are possibly useful by other modules. Note that Win95
  1757. // doesn't by default have the UTF-8 codepage loaded. So a good way to
  1758. // convert from UTF-8 to Unicode.
  1759. //
  1760. {$EXTERNALSYM LdapUTF8ToUnicode}
  1761. function LdapUTF8ToUnicode(lpSrcStr: LPCSTR; cchSrc: Integer;
  1762. lpDestStr: LPWSTR; cchDest: Integer): Integer; cdecl;
  1763. {$EXTERNALSYM LdapUnicodeToUTF8}
  1764. function LdapUnicodeToUTF8(lpSrcStr: LPCWSTR; cchSrc: Integer;
  1765. lpDestStr: LPSTR; cchDest: Integer): Integer; cdecl;
  1766. //
  1767. // LDAPv3 features :
  1768. //
  1769. // Sort Keys... these are used to ask the server to sort the results
  1770. // before sending the results back. LDAPv3 only and optional to implement
  1771. // on the server side. Check supportedControl for an OID of
  1772. // "1.2.840.113556.1.4.473" to see if the server supports it.
  1773. //
  1774. const
  1775. {$EXTERNALSYM LDAP_SERVER_SORT_OID}
  1776. LDAP_SERVER_SORT_OID = '1.2.840.113556.1.4.473';
  1777. {$EXTERNALSYM LDAP_SERVER_SORT_OID_W}
  1778. LDAP_SERVER_SORT_OID_W = '1.2.840.113556.1.4.473';
  1779. {$EXTERNALSYM LDAP_SERVER_RESP_SORT_OID}
  1780. LDAP_SERVER_RESP_SORT_OID = '1.2.840.113556.1.4.474';
  1781. {$EXTERNALSYM LDAP_SERVER_RESP_SORT_OID_W}
  1782. LDAP_SERVER_RESP_SORT_OID_W = '1.2.840.113556.1.4.474';
  1783. {
  1784. NOTE from translator: I'm not quite sure about the following
  1785. declaration:
  1786. typedef struct ldapsearch LDAPSearch, *PLDAPSearch;
  1787. }
  1788. type
  1789. // Note from translator:
  1790. // The following two types don't have a TLDAPxxx type declared, since they are
  1791. // meant as opaque pointer types only, so a TLDAPxxx is not needed.
  1792. {$EXTERNALSYM PLDAPSearch}
  1793. PLDAPSearch = ^LDAPSearch;
  1794. {$EXTERNALSYM LDAPSearch}
  1795. LDAPSearch = record end;
  1796. {$EXTERNALSYM PLDAPSortKeyA}
  1797. PLDAPSortKeyA = ^LDAPSortKeyA;
  1798. {$EXTERNALSYM PLDAPSortKeyW}
  1799. PLDAPSortKeyW = ^LDAPSortKeyW;
  1800. {$EXTERNALSYM PLDAPSortKey}
  1801. PLDAPSortKey = PLDAPSortKeyA;
  1802. {$EXTERNALSYM LDAPSortKeyA}
  1803. LDAPSortKeyA = packed record
  1804. sk_attrtype: PAnsiChar;
  1805. sk_matchruleoid: PAnsiChar;
  1806. sk_reverseorder: ByteBool;
  1807. end;
  1808. {$EXTERNALSYM LDAPSortKeyW}
  1809. LDAPSortKeyW = packed record
  1810. sk_attrtype: PWideChar;
  1811. sk_matchruleoid: PWideChar;
  1812. sk_reverseorder: ByteBool;
  1813. end;
  1814. {$EXTERNALSYM LDAPSortKey}
  1815. LDAPSortKey = LDAPSortKeyA;
  1816. //
  1817. // This API formats a list of sort keys into a search control. Call
  1818. // ldap_control_free when you're finished with the control.
  1819. //
  1820. // Use this one rather than ldap_encode_sort_control as this is per RFC.
  1821. //
  1822. {$EXTERNALSYM ldap_create_sort_controlA}
  1823. function ldap_create_sort_controlA(ExternalHandle: PLDAP;
  1824. var SortKeys: PLDAPSortKeyA; IsCritical: UCHAR;
  1825. var Control: PLDAPControlA): ULONG; cdecl;
  1826. {$EXTERNALSYM ldap_create_sort_controlW}
  1827. function ldap_create_sort_controlW(ExternalHandle: PLDAP;
  1828. var SortKeys: PLDAPSortKeyW; IsCritical: UCHAR;
  1829. var Control: PLDAPControlW): ULONG; cdecl;
  1830. {$EXTERNALSYM ldap_create_sort_control}
  1831. function ldap_create_sort_control(ExternalHandle: PLDAP;
  1832. var SortKeys: PLDAPSortKey; IsCritical: UCHAR;
  1833. var Control: PLDAPControl): ULONG; cdecl;
  1834. //
  1835. // This API parses the sort control returned by the server. Use ldap_memfree
  1836. // to free the attribute value, if it's returned.
  1837. //
  1838. {$EXTERNALSYM ldap_parse_sort_controlA}
  1839. function ldap_parse_sort_controlA(ExternalHandle: PLDAP;
  1840. var Control: PLDAPControlA; var Result: ULONG;
  1841. var Attribute: PAnsiChar): ULONG; cdecl;
  1842. {$EXTERNALSYM ldap_parse_sort_controlW}
  1843. function ldap_parse_sort_controlW(ExternalHandle: PLDAP;
  1844. var Control: PLDAPControlW; var Result: ULONG;
  1845. var Attribute: PWideChar): ULONG; cdecl;
  1846. {$EXTERNALSYM ldap_parse_sort_control}
  1847. function ldap_parse_sort_control(ExternalHandle: PLDAP;
  1848. var Control: PLDAPControl; var Result: ULONG;
  1849. var Attribute: PChar): ULONG; cdecl;
  1850. //
  1851. // This API formats a list of sort keys into a search control. Call
  1852. // ldap_memfree for both Control->ldctl_value.bv_val and
  1853. // Control->currentControl->ldctl_oid when you're finished with the control.
  1854. //
  1855. // This is the old sort API that will be shortly pulled. Please use
  1856. // ldap_create_sort_control defined above.
  1857. //
  1858. {$EXTERNALSYM ldap_encode_sort_controlA}
  1859. function ldap_encode_sort_controlA(ExternalHandle: PLDAP;
  1860. var SortKeys: PLDAPSortKeyA; Control: PLDAPControlA;
  1861. Criticality: ByteBool): ULONG; cdecl;
  1862. {$EXTERNALSYM ldap_encode_sort_controlW}
  1863. function ldap_encode_sort_controlW(ExternalHandle: PLDAP;
  1864. var SortKeys: PLDAPSortKeyW; Control: PLDAPControlW;
  1865. Criticality: ByteBool): ULONG; cdecl;
  1866. {$EXTERNALSYM ldap_encode_sort_control}
  1867. function ldap_encode_sort_control(ExternalHandle: PLDAP;
  1868. var SortKeys: PLDAPSortKey; Control: PLDAPControl;
  1869. Criticality: ByteBool): ULONG; cdecl;
  1870. //
  1871. // LDAPv3: This is the RFC defined API for the simple paging of results
  1872. // control. Use ldap_control_free to free the control allocated by
  1873. // ldap_create_page_control.
  1874. //
  1875. {$EXTERNALSYM ldap_create_page_controlA}
  1876. function ldap_create_page_controlA(ExternalHandle: PLDAP;
  1877. PageSize: ULONG; var Cookie: TLDAPBerVal; IsCritical: UCHAR;
  1878. var Control: PLDAPControlA): ULONG; cdecl;
  1879. {$EXTERNALSYM ldap_create_page_controlW}
  1880. function ldap_create_page_controlW(ExternalHandle: PLDAP;
  1881. PageSize: ULONG; var Cookie: TLDAPBerVal; IsCritical: UCHAR;
  1882. var Control: PLDAPControlW): ULONG; cdecl;
  1883. {$EXTERNALSYM ldap_create_page_control}
  1884. function ldap_create_page_control(ExternalHandle: PLDAP;
  1885. PageSize: ULONG; var Cookie: TLDAPBerVal; IsCritical: UCHAR;
  1886. var Control: PLDAPControl): ULONG; cdecl;
  1887. {$EXTERNALSYM ldap_parse_page_controlA}
  1888. function ldap_parse_page_controlA(ExternalHandle: PLDAP;
  1889. ServerControls: PPLDAPControlA; var TotalCount: ULONG;
  1890. var Cookie: PLDAPBerVal): ULONG; cdecl; // Use ber_bvfree to free Cookie
  1891. {$EXTERNALSYM ldap_parse_page_controlW}
  1892. function ldap_parse_page_controlW(ExternalHandle: PLDAP;
  1893. ServerControls: PPLDAPControlW; var TotalCount: ULONG;
  1894. var Cookie: PLDAPBerVal): ULONG; cdecl; // Use ber_bvfree to free Cookie
  1895. {$EXTERNALSYM ldap_parse_page_control}
  1896. function ldap_parse_page_control(ExternalHandle: PLDAP;
  1897. ServerControls: PPLDAPControl; var TotalCount: ULONG;
  1898. var Cookie: PLDAPBerVal): ULONG; cdecl; // Use ber_bvfree to free Cookie
  1899. //
  1900. // LDAPv3: This is the interface for simple paging of results. To ensure
  1901. // that the server supports it, check the supportedControl property off of
  1902. // the root for an OID of 1.2.840.113556.1.4.319. If it is there, then it
  1903. // supports this feature.
  1904. //
  1905. // If you're going to specify sort keys, see section above on sort keys on
  1906. // now to tell if they're supported by the server.
  1907. //
  1908. // You first call ldap_search_init_page. If it returns a non-NULL LDAPSearch
  1909. // block, then it worked ok. Otherwise call LdapGetLastError to find error.
  1910. //
  1911. // With a valid LDAPSearch block (there are opaque), call ldap_get_next_page
  1912. // or ldap_get_next_page_s. If you call ldap_get_next_page, you MUST call
  1913. // ldap_get_paged_count for each set of results that you get for that message.
  1914. // This allows the library to save off the cookie that the server sent to
  1915. // resume the search.
  1916. //
  1917. // Other than calling ldap_get_paged_count, the results you get back from
  1918. // ldap_get_next_page can be treated as any other search result, and should
  1919. // be freed when you're done by calling ldap_msgfree.
  1920. //
  1921. // When the end of the search is hit, you'll get a return code of
  1922. // LDAP_NO_RESULTS_RETURNED. At this point, (or any point after LDAPSearch
  1923. // structure has been allocated), you call ldap_search_abandon_page. You
  1924. // need to call this even after you get a return code of
  1925. // LDAP_NO_RESULTS_RETURNED.
  1926. //
  1927. // If you call ldap_get_next_page_s, you don't need to call
  1928. // ldap_get_paged_count.
  1929. //
  1930. const
  1931. {$EXTERNALSYM LDAP_PAGED_RESULT_OID_STRING}
  1932. LDAP_PAGED_RESULT_OID_STRING = '1.2.840.113556.1.4.319';
  1933. {$EXTERNALSYM LDAP_PAGED_RESULT_OID_STRING_W}
  1934. LDAP_PAGED_RESULT_OID_STRING_W = '1.2.840.113556.1.4.319';
  1935. {$EXTERNALSYM ldap_search_init_pageA}
  1936. function ldap_search_init_pageA(ExternalHandle: PLDAP;
  1937. DistinguishedName: PAnsiChar; ScopeOfSearch: ULONG; SearchFilter: PAnsiChar;
  1938. AttributeList: PPCharA; AttributesOnly: ULONG;
  1939. var ServerControls, ClientControls: PLDAPControlA;
  1940. PageTimeLimit, TotalSizeLimit: ULONG;
  1941. var SortKeys: PLDAPSortKeyA): PLDAPSearch; cdecl;
  1942. {$EXTERNALSYM ldap_search_init_pageW}
  1943. function ldap_search_init_pageW(ExternalHandle: PLDAP;
  1944. DistinguishedName: PWideChar; ScopeOfSearch: ULONG; SearchFilter: PWideChar;
  1945. AttributeList: PPCharW; AttributesOnly: ULONG;
  1946. var ServerControls, ClientControls: PLDAPControlW;
  1947. PageTimeLimit, TotalSizeLimit: ULONG;
  1948. var SortKeys: PLDAPSortKeyW): PLDAPSearch; cdecl;
  1949. {$EXTERNALSYM ldap_search_init_page}
  1950. function ldap_search_init_page(ExternalHandle: PLDAP;
  1951. DistinguishedName: PChar; ScopeOfSearch: ULONG; SearchFilter: PChar;
  1952. AttributeList: PPChar; AttributesOnly: ULONG;
  1953. var ServerControls, ClientControls: PLDAPControl;
  1954. PageTimeLimit, TotalSizeLimit: ULONG;
  1955. var SortKeys: PLDAPSortKey): PLDAPSearch; cdecl;
  1956. {$EXTERNALSYM ldap_get_next_page}
  1957. function ldap_get_next_page(ExternalHandle: PLDAP; SearchHandle: PLDAPSearch;
  1958. PageSize: ULONG; var MessageNumber: ULONG): ULONG; cdecl;
  1959. {$EXTERNALSYM ldap_get_next_page_s}
  1960. function ldap_get_next_page_s(ExternalHandle: PLDAP; SearchHandle: PLDAPSearch;
  1961. var timeout: TLDAPTimeVal; PageSize: ULONG; var TotalCount: ULONG;
  1962. var Results: PLDAPMessage): ULONG; cdecl;
  1963. {$EXTERNALSYM ldap_get_paged_count}
  1964. function ldap_get_paged_count(ExternalHandle: PLDAP; SearchBlock: PLDAPSearch;
  1965. var TotalCount: ULONG; Results: PLDAPMessage): ULONG; cdecl;
  1966. {$EXTERNALSYM ldap_search_abandon_page}
  1967. function ldap_search_abandon_page(ExternalHandle: PLDAP;
  1968. SearchBlock: PLDAPSearch): ULONG; cdecl;
  1969. //
  1970. // These functions return subordinate referrals (references) that are returned
  1971. // in search responses. There are two types of referrals. External referrals
  1972. // where the naming context doesn't reside on the server (e.g. server says 'I
  1973. // don't have the data, look over there') and Subordinate referrals (or
  1974. // references) where some data has been returned and the referrals are passed
  1975. // to other naming contexts below the current one (e.g. servers says 'Here's
  1976. // some data from the tree I hold, go look here, there, and over there for
  1977. // more data that is further down in the tree.').
  1978. //
  1979. // These routines handle the latter. For external references, use
  1980. // ldap_parse_result.
  1981. //
  1982. // Return the first reference from a message. It is freed when the message is
  1983. // freed so should not be freed explicitly.
  1984. //
  1985. {$EXTERNALSYM ldap_first_reference}
  1986. function ldap_first_reference(ld: PLDAP; res: PLDAPMessage): PLDAPMessage;
  1987. //
  1988. // Return the next entry of a message. It is freed when the message is
  1989. // freed so should not be freed explicitly.
  1990. //
  1991. {$EXTERNALSYM ldap_next_reference}
  1992. function ldap_next_reference(ld: PLDAP; entry: PLDAPMessage): PLDAPMessage;
  1993. //
  1994. // Count the number of subordinate references returned by the server in a
  1995. // response to a search request.
  1996. //
  1997. {$EXTERNALSYM ldap_count_references}
  1998. function ldap_count_references(ld: PLDAP; res: PLDAPMessage): ULONG; cdecl;
  1999. //
  2000. // We return the list of subordinate referrals in a search response message.
  2001. //
  2002. // free Referrals with ldap_value_freeW
  2003. {$EXTERNALSYM ldap_parse_referenceA}
  2004. function ldap_parse_referenceA(Connection: PLDAP; ResultMessage: PLDAPMessage;
  2005. var Referrals: PPCharA): ULONG; cdecl;
  2006. {$EXTERNALSYM ldap_parse_referenceW}
  2007. function ldap_parse_referenceW(Connection: PLDAP; ResultMessage: PLDAPMessage;
  2008. var Referrals: PPCharW): ULONG; cdecl;
  2009. {$EXTERNALSYM ldap_parse_reference}
  2010. function ldap_parse_reference(Connection: PLDAP; ResultMessage: PLDAPMessage;
  2011. var Referrals: PPChar): ULONG; cdecl;
  2012. //
  2013. // These APIs allow a client to send an extended request (free for all) to
  2014. // an LDAPv3 (or above) server. The functionality is fairly open... you can
  2015. // send any request you'd like. Note that since we don't know if you'll
  2016. // be receiving a single or multiple responses, you'll have to explicitly tell
  2017. // us when you're done with the request by calling ldap_close_extended_op.
  2018. //
  2019. // These are thread safe.
  2020. //
  2021. {$EXTERNALSYM ldap_extended_operationA}
  2022. function ldap_extended_operationA(ld: PLDAP; Oid: PAnsiChar;
  2023. var Data: TLDAPBerVal; var ServerControls, ClientControls: PLDAPControlA;
  2024. var MessageNumber: ULONG): ULONG; cdecl;
  2025. {$EXTERNALSYM ldap_extended_operationW}
  2026. function ldap_extended_operationW(ld: PLDAP; Oid: PWideChar;
  2027. var Data: TLDAPBerVal; var ServerControls, ClientControls: PLDAPControlW;
  2028. var MessageNumber: ULONG): ULONG; cdecl;
  2029. {$EXTERNALSYM ldap_extended_operation}
  2030. function ldap_extended_operation(ld: PLDAP; Oid: PChar;
  2031. var Data: TLDAPBerVal; var ServerControls, ClientControls: PLDAPControl;
  2032. var MessageNumber: ULONG): ULONG; cdecl;
  2033. {$EXTERNALSYM ldap_close_extended_op}
  2034. function ldap_close_extended_op(ld: PLDAP; MessageNumber: ULONG): ULONG; cdecl;
  2035. //
  2036. // Some enhancements that will probably never make it into the RFC related
  2037. // to callouts to allow external caching of connections.
  2038. //
  2039. // Call ldap_set_option( conn, LDAP_OPT_REFERRAL_CALLBACK, &referralRoutines )
  2040. // where referralRoutines is the address of an LDAP_REFERRAL_CALLBACK
  2041. // structure with your routines. They may be NULL, in which case we'll
  2042. // obviously not make the calls.
  2043. //
  2044. // Any connections that are created will inherit the current callbacks from
  2045. // the primary connection that the request was initiated on.
  2046. //
  2047. const
  2048. {$EXTERNALSYM LDAP_OPT_REFERRAL_CALLBACK}
  2049. LDAP_OPT_REFERRAL_CALLBACK = $70;
  2050. //
  2051. // This first routine is called when we're about to chase a referral. We
  2052. // callout to it to see if there is already a connection cached that we
  2053. // can use. If so, the callback routine returns the pointer to the
  2054. // connection to use in ConnectionToUse. If not, it sets
  2055. // *ConnectionToUse to NULL.
  2056. //
  2057. // For a return code, it should return 0 if we should continue to chase the
  2058. // referral. If it returns a non-zero return code, we'll treat that as the
  2059. // error code for chasing the referral. This allows caching of host names
  2060. // that are not reachable, if we decide to add that in the future.
  2061. //
  2062. type
  2063. {$EXTERNALSYM QUERYFORCONNECTION}
  2064. QUERYFORCONNECTION = function(
  2065. PrimaryConnection: PLDAP;
  2066. ReferralFromConnection: PLDAP;
  2067. NewDN: PWideChar;
  2068. HostName: PChar;
  2069. PortNumber: ULONG;
  2070. SecAuthIdentity: Pointer; // if null, use CurrentUser below
  2071. CurrentUserToken: Pointer; // pointer to current user's LUID
  2072. var ConnectionToUse: PLDAP):ULONG cdecl;
  2073. TQueryForConnection = QUERYFORCONNECTION;
  2074. //
  2075. // This next function is called when we've created a new connection while
  2076. // chasing a referral. Note that it gets assigned the same callback functions
  2077. // as the PrimaryConnection. If the return code is FALSE, then the call
  2078. // back function doesn't want to cache the connection and it will be
  2079. // destroyed after the operation is complete. If TRUE is returned, we'll
  2080. // assume that the callee has taken ownership of the connection and it will
  2081. // not be destroyed after the operation is complete.
  2082. //
  2083. // If the ErrorCodeFromBind field is not 0, then the bind operation to
  2084. // that server failed.
  2085. //
  2086. {$EXTERNALSYM NOTIFYOFNEWCONNECTION}
  2087. NOTIFYOFNEWCONNECTION = function(
  2088. PrimaryConnection: PLDAP;
  2089. ReferralFromConnection: PLDAP;
  2090. NewDN: PWideChar;
  2091. HostName: PChar;
  2092. NewConnection: PLDAP;
  2093. PortNumber: ULONG;
  2094. SecAuthIdentity: Pointer; // if null, use CurrentUser below
  2095. CurrentUser: Pointer; // pointer to current user's LUID
  2096. ErrorCodeFromBind: ULONG): ByteBool cdecl;
  2097. TNotifyOfNewConnection = NOTIFYOFNEWCONNECTION;
  2098. //
  2099. // This next function is called when we've successfully called off to the
  2100. // QueryForConnection call and received a connection OR when we called off
  2101. // to the NotifyOfNewConnection call and it returned TRUE. We call this
  2102. // function when we're dereferencing the connection after we're done with it.
  2103. //
  2104. // Return code is currently ignored, but the function should return
  2105. // LDAP_SUCCESS if all went well.
  2106. //
  2107. {$EXTERNALSYM DEREFERENCECONNECTION}
  2108. DEREFERENCECONNECTION = function(PrimaryConnection: PLDAP;
  2109. ConnectionToDereference: PLDAP): ULONG cdecl;
  2110. TDereferenceConnection = DEREFERENCECONNECTION;
  2111. PLDAPReferralCallback = ^TLDAPReferralCallback;
  2112. {$EXTERNALSYM LdapReferralCallback}
  2113. LdapReferralCallback = packed record
  2114. SizeOfCallbacks: ULONG; // set to sizeof( LDAP_REFERRAL_CALLBACK )
  2115. QueryForConnection: QUERYFORCONNECTION;
  2116. NotifyRoutine: NOTIFYOFNEWCONNECTION;
  2117. DereferenceRoutine: DEREFERENCECONNECTION;
  2118. end;
  2119. {$EXTERNALSYM LDAP_REFERRAL_CALLBACK}
  2120. LDAP_REFERRAL_CALLBACK = LdapReferralCallback;
  2121. {$EXTERNALSYM PLDAP_REFERRAL_CALLBACK}
  2122. PLDAP_REFERRAL_CALLBACK = ^LdapReferralCallback;
  2123. TLDAPReferralCallback = LdapReferralCallback;
  2124. //
  2125. // Thread Safe way to get last error code returned by LDAP API is to call
  2126. // LdapGetLastError();
  2127. //
  2128. {$EXTERNALSYM LdapGetLastError}
  2129. function LdapGetLastError: ULONG; cdecl;
  2130. //
  2131. // Translate from LdapError to closest Win32 error code.
  2132. //
  2133. {$EXTERNALSYM LdapMapErrorToWin32}
  2134. function LdapMapErrorToWin32(LdapError: ULONG): ULONG; cdecl;
  2135. //
  2136. // This is an arrangement for specifying client certificates while establishing
  2137. // an SSL connection.
  2138. // Simply Call ldap_set_option( conn, LDAP_OPT_CLIENT_CERTIFICATE, &CertRoutine )
  2139. // where CertRoutine is the address of your callback routine. If it is NULL,
  2140. // we will obviously not make the call.
  2141. //
  2142. const
  2143. {$EXTERNALSYM LDAP_OPT_CLIENT_CERTIFICATE}
  2144. LDAP_OPT_CLIENT_CERTIFICATE = $80;
  2145. //
  2146. // This callback is invoked when the server demands a client certificate for
  2147. // authorization. We pass a structure containing a list of server-trusted
  2148. // Certificate Authorities. If the client has certificates to provide, it
  2149. // converts them to CERT_CONTEXTs and adds them to the given certificate
  2150. // store. LDAP subsequently passes these credentials to the SSL server as part
  2151. // of the handshake.
  2152. //
  2153. type
  2154. {$EXTERNALSYM QUERYCLIENTCERT}
  2155. QUERYCLIENTCERT = function(
  2156. Connection: PLDAP;
  2157. trusted_CAs: Pointer {PSecPkgContext_IssuerListInfoEx};
  2158. hCertStore: LongWord {HCERTSTORE};
  2159. var pcCreds: DWORD
  2160. ): ByteBool cdecl;
  2161. //
  2162. // We are also giving an opportunity for the client to verify the certificate
  2163. // of the server. The client registers a callback which is invoked after the
  2164. // secure connection is setup. The server certificate is presented to the
  2165. // client who invokes it and decides it it is acceptable. To register this
  2166. // callback, simply call ldap_set_option( conn, LDAP_OPT_SERVER_CERTIFICATE, &CertRoutine )
  2167. //
  2168. const
  2169. {$EXTERNALSYM LDAP_OPT_SERVER_CERTIFICATE}
  2170. LDAP_OPT_SERVER_CERTIFICATE = $81;
  2171. //
  2172. // This function is called after the secure connection has been established. The
  2173. // certificate of the server is supplied for examination by the client. If the
  2174. // client approves it, it returns TRUE else, it returns false and the secure
  2175. // connection is torn down.
  2176. //
  2177. type
  2178. VERIFYSERVERCERT = function(
  2179. Connection: PLDAP;
  2180. pServerCert: Pointer {PCCERT_CONTEXT}
  2181. ): ByteBool cdecl;
  2182. //
  2183. // Given an LDAP message, return the connection pointer where the message
  2184. // came from. It can return NULL if the connection has already been freed.
  2185. //
  2186. {$EXTERNALSYM ldap_conn_from_msg}
  2187. function ldap_conn_from_msg(PrimaryConn: PLDAP; res: PLDAPMessage): PLDAP; cdecl;
  2188. //
  2189. // Do we reference the connection for each message so that we can safely get
  2190. // the connection pointer back by calling ldap_conn_from_msg?
  2191. //
  2192. const
  2193. {$EXTERNALSYM LDAP_OPT_REF_DEREF_CONN_PER_MSG}
  2194. LDAP_OPT_REF_DEREF_CONN_PER_MSG = $94;
  2195. implementation
  2196. uses
  2197. JwaWinDLLNames;
  2198. function ldap_openA; external LDAPLib name 'ldap_openA';
  2199. function ldap_openW; external LDAPLib name 'ldap_openW';
  2200. function ldap_open; external LDAPLib name 'ldap_openA';
  2201. function ldap_initA; external LDAPLib name 'ldap_initA';
  2202. function ldap_initW; external LDAPLib name 'ldap_initW';
  2203. function ldap_init; external LDAPLib name 'ldap_initA';
  2204. function ldap_sslinitA; external LDAPLib name 'ldap_sslinitA';
  2205. function ldap_sslinitW; external LDAPLib name 'ldap_sslinitW';
  2206. function ldap_sslinit; external LDAPLib name 'ldap_sslinitA';
  2207. function cldap_openA; external LDAPLib name 'cldap_openA';
  2208. function cldap_openW; external LDAPLib name 'cldap_openW';
  2209. function cldap_open; external LDAPLib name 'cldap_openA';
  2210. function ldap_simple_bindA; external LDAPLib name 'ldap_simple_bindA';
  2211. function ldap_simple_bindW; external LDAPLib name 'ldap_simple_bindW';
  2212. function ldap_simple_bind; external LDAPLib name 'ldap_simple_bindA';
  2213. function ldap_simple_bind_sA; external LDAPLib name 'ldap_simple_bind_sA';
  2214. function ldap_simple_bind_sW; external LDAPLib name 'ldap_simple_bind_sW';
  2215. function ldap_simple_bind_s; external LDAPLib name 'ldap_simple_bind_sA';
  2216. function ldap_bindA; external LDAPLib name 'ldap_bindA';
  2217. function ldap_bindW; external LDAPLib name 'ldap_bindW';
  2218. function ldap_bind; external LDAPLib name 'ldap_bindA';
  2219. function ldap_bind_sA; external LDAPLib name 'ldap_bind_sA';
  2220. function ldap_bind_sW; external LDAPLib name 'ldap_bind_sW';
  2221. function ldap_bind_s; external LDAPLib name 'ldap_bind_sA';
  2222. function ldap_sasl_bindA; external LDAPLib name 'ldap_sasl_bindA';
  2223. function ldap_sasl_bindW; external LDAPLib name 'ldap_sasl_bindW';
  2224. function ldap_sasl_bind; external LDAPLib name 'ldap_sasl_bindA';
  2225. function ldap_sasl_bind_sA; external LDAPLib name 'ldap_sasl_bind_sA';
  2226. function ldap_sasl_bind_sW; external LDAPLib name 'ldap_sasl_bind_sW';
  2227. function ldap_sasl_bind_s; external LDAPLib name 'ldap_sasl_bind_sA';
  2228. function ldap_searchA; external LDAPLib name 'ldap_searchA';
  2229. function ldap_searchW; external LDAPLib name 'ldap_searchW';
  2230. function ldap_search; external LDAPLib name 'ldap_searchA';
  2231. function ldap_search_sA; external LDAPLib name 'ldap_search_sA';
  2232. function ldap_search_sW; external LDAPLib name 'ldap_search_sW';
  2233. function ldap_search_s; external LDAPLib name 'ldap_search_sA';
  2234. function ldap_search_stA; external LDAPLib name 'ldap_search_stA';
  2235. function ldap_search_stW; external LDAPLib name 'ldap_search_stW';
  2236. function ldap_search_st; external LDAPLib name 'ldap_search_stA';
  2237. function ldap_modifyA; external LDAPLib name 'ldap_modifyA';
  2238. function ldap_modifyW; external LDAPLib name 'ldap_modifyW';
  2239. function ldap_modify; external LDAPLib name 'ldap_modifyA';
  2240. function ldap_modify_sA; external LDAPLib name 'ldap_modify_sA';
  2241. function ldap_modify_sW; external LDAPLib name 'ldap_modify_sW';
  2242. function ldap_modify_s; external LDAPLib name 'ldap_modify_sA';
  2243. function ldap_modrdn2A; external LDAPLib name 'ldap_modrdn2A';
  2244. function ldap_modrdn2W; external LDAPLib name 'ldap_modrdn2W';
  2245. function ldap_modrdn2; external LDAPLib name 'ldap_modrdn2A';
  2246. function ldap_modrdnA; external LDAPLib name 'ldap_modrdnA';
  2247. function ldap_modrdnW; external LDAPLib name 'ldap_modrdnW';
  2248. function ldap_modrdn; external LDAPLib name 'ldap_modrdnA';
  2249. function ldap_modrdn2_sA; external LDAPLib name 'ldap_modrdn2_sA';
  2250. function ldap_modrdn2_sW; external LDAPLib name 'ldap_modrdn2_sW';
  2251. function ldap_modrdn2_s; external LDAPLib name 'ldap_modrdn2_sA';
  2252. function ldap_modrdn_sA; external LDAPLib name 'ldap_modrdn_sA';
  2253. function ldap_modrdn_sW; external LDAPLib name 'ldap_modrdn_sW';
  2254. function ldap_modrdn_s; external LDAPLib name 'ldap_modrdn_sA';
  2255. function ldap_addA; external LDAPLib name 'ldap_addA';
  2256. function ldap_addW; external LDAPLib name 'ldap_addW';
  2257. function ldap_add; external LDAPLib name 'ldap_addA';
  2258. function ldap_add_sA; external LDAPLib name 'ldap_add_sA';
  2259. function ldap_add_sW; external LDAPLib name 'ldap_add_sW';
  2260. function ldap_add_s; external LDAPLib name 'ldap_add_sA';
  2261. function ldap_compareA; external LDAPLib name 'ldap_compareA';
  2262. function ldap_compareW; external LDAPLib name 'ldap_compareW';
  2263. function ldap_compare; external LDAPLib name 'ldap_compareA';
  2264. function ldap_compare_sA; external LDAPLib name 'ldap_compare_sA';
  2265. function ldap_compare_sW; external LDAPLib name 'ldap_compare_sW';
  2266. function ldap_compare_s; external LDAPLib name 'ldap_compare_sA';
  2267. function ldap_deleteA; external LDAPLib name 'ldap_deleteA';
  2268. function ldap_deleteW; external LDAPLib name 'ldap_deleteW';
  2269. function ldap_delete; external LDAPLib name 'ldap_deleteA';
  2270. function ldap_delete_sA; external LDAPLib name 'ldap_delete_sA';
  2271. function ldap_delete_sW; external LDAPLib name 'ldap_delete_sW';
  2272. function ldap_delete_s; external LDAPLib name 'ldap_delete_sA';
  2273. function ldap_err2stringA; external LDAPLib name 'ldap_err2stringA';
  2274. function ldap_err2stringW; external LDAPLib name 'ldap_err2stringW';
  2275. function ldap_err2string; external LDAPLib name 'ldap_err2stringA';
  2276. function ldap_first_attributeA; external LDAPLib name 'ldap_first_attributeA';
  2277. function ldap_first_attributeW; external LDAPLib name 'ldap_first_attributeW';
  2278. function ldap_first_attribute; external LDAPLib name 'ldap_first_attributeA';
  2279. function ldap_next_attributeA; external LDAPLib name 'ldap_next_attributeA';
  2280. function ldap_next_attributeW; external LDAPLib name 'ldap_next_attributeW';
  2281. function ldap_next_attribute; external LDAPLib name 'ldap_next_attributeA';
  2282. function ldap_get_valuesA; external LDAPLib name 'ldap_get_valuesA';
  2283. function ldap_get_valuesW; external LDAPLib name 'ldap_get_valuesW';
  2284. function ldap_get_values; external LDAPLib name 'ldap_get_valuesA';
  2285. function ldap_get_values_lenA; external LDAPLib name 'ldap_get_values_lenA';
  2286. function ldap_get_values_lenW; external LDAPLib name 'ldap_get_values_lenW';
  2287. function ldap_get_values_len; external LDAPLib name 'ldap_get_values_lenA';
  2288. function ldap_count_valuesA; external LDAPLib name 'ldap_count_valuesA';
  2289. function ldap_count_valuesW; external LDAPLib name 'ldap_count_valuesW';
  2290. function ldap_count_values; external LDAPLib name 'ldap_count_valuesA';
  2291. function ldap_value_freeA; external LDAPLib name 'ldap_value_freeA';
  2292. function ldap_value_freeW; external LDAPLib name 'ldap_value_freeW';
  2293. function ldap_value_free; external LDAPLib name 'ldap_value_freeA';
  2294. function ldap_get_dnA; external LDAPLib name 'ldap_get_dnA';
  2295. function ldap_get_dnW; external LDAPLib name 'ldap_get_dnW';
  2296. function ldap_get_dn; external LDAPLib name 'ldap_get_dnA';
  2297. function ldap_explode_dnA; external LDAPLib name 'ldap_explode_dnA';
  2298. function ldap_explode_dnW; external LDAPLib name 'ldap_explode_dnW';
  2299. function ldap_explode_dn; external LDAPLib name 'ldap_explode_dnA';
  2300. function ldap_dn2ufnA; external LDAPLib name 'ldap_dn2ufnA';
  2301. function ldap_dn2ufnW; external LDAPLib name 'ldap_dn2ufnW';
  2302. function ldap_dn2ufn; external LDAPLib name 'ldap_dn2ufnA';
  2303. procedure ldap_memfreeA; external LDAPLib name 'ldap_memfreeA';
  2304. procedure ldap_memfreeW; external LDAPLib name 'ldap_memfreeW';
  2305. procedure ldap_memfree; external LDAPLib name 'ldap_memfreeA';
  2306. function ldap_ufn2dnA; external LDAPLib name 'ldap_ufn2dnA';
  2307. function ldap_ufn2dnW; external LDAPLib name 'ldap_ufn2dnW';
  2308. function ldap_ufn2dn; external LDAPLib name 'ldap_ufn2dnA';
  2309. function ldap_escape_filter_elementA; external LDAPLib name 'ldap_escape_filter_elementA';
  2310. function ldap_escape_filter_elementW; external LDAPLib name 'ldap_escape_filter_elementW';
  2311. function ldap_escape_filter_element; external LDAPLib name 'ldap_escape_filter_elementA';
  2312. function ldap_search_extA; external LDAPLib name 'ldap_search_extA';
  2313. function ldap_search_extW; external LDAPLib name 'ldap_search_extW';
  2314. function ldap_search_ext; external LDAPLib name 'ldap_search_extA';
  2315. function ldap_search_ext_sA; external LDAPLib name 'ldap_search_ext_sA';
  2316. function ldap_search_ext_sW; external LDAPLib name 'ldap_search_ext_sW';
  2317. function ldap_search_ext_s; external LDAPLib name 'ldap_search_ext_sA';
  2318. function ldap_check_filterA; EXTERNAL LDAPLib name 'ldap_check_filterA';
  2319. function ldap_check_filterW; EXTERNAL LDAPLib name 'ldap_check_filterW';
  2320. function ldap_check_filter; EXTERNAL LDAPLib name 'ldap_check_filterA';
  2321. function ldap_modify_extA; external LDAPLib name 'ldap_modify_extA';
  2322. function ldap_modify_extW; external LDAPLib name 'ldap_modify_extW';
  2323. function ldap_modify_ext; external LDAPLib name 'ldap_modify_extA';
  2324. function ldap_modify_ext_sA; external LDAPLib name 'ldap_modify_ext_sA';
  2325. function ldap_modify_ext_sW; external LDAPLib name 'ldap_modify_ext_sW';
  2326. function ldap_modify_ext_s; external LDAPLib name 'ldap_modify_ext_sA';
  2327. function ldap_rename_extA; external LDAPLib name 'ldap_rename_extA';
  2328. function ldap_rename_extW; external LDAPLib name 'ldap_rename_extW';
  2329. function ldap_rename_ext; external LDAPLib name 'ldap_rename_extA';
  2330. function ldap_rename_ext_sA; external LDAPLib name 'ldap_rename_ext_sA';
  2331. function ldap_rename_ext_sW; external LDAPLib name 'ldap_rename_ext_sW';
  2332. function ldap_rename_ext_s; external LDAPLib name 'ldap_rename_ext_sA';
  2333. function ldap_add_extA; external LDAPLib name 'ldap_add_extA';
  2334. function ldap_add_extW; external LDAPLib name 'ldap_add_extW';
  2335. function ldap_add_ext; external LDAPLib name 'ldap_add_extA';
  2336. function ldap_add_ext_sA; external LDAPLib name 'ldap_add_ext_sA';
  2337. function ldap_add_ext_sW; external LDAPLib name 'ldap_add_ext_sW';
  2338. function ldap_add_ext_s; external LDAPLib name 'ldap_add_ext_sA';
  2339. function ldap_compare_extA; external LDAPLib name 'ldap_compare_extA';
  2340. function ldap_compare_extW; external LDAPLib name 'ldap_compare_extW';
  2341. function ldap_compare_ext; external LDAPLib name 'ldap_compare_extA';
  2342. function ldap_compare_ext_sA; external LDAPLib name 'ldap_compare_ext_sA';
  2343. function ldap_compare_ext_sW; external LDAPLib name 'ldap_compare_ext_sW';
  2344. function ldap_compare_ext_s; external LDAPLib name 'ldap_compare_ext_sA';
  2345. function ldap_delete_extA; external LDAPLib name 'ldap_delete_extA';
  2346. function ldap_delete_extW; external LDAPLib name 'ldap_delete_extW';
  2347. function ldap_delete_ext; external LDAPLib name 'ldap_delete_extA';
  2348. function ldap_delete_ext_sA; external LDAPLib name 'ldap_delete_ext_sA';
  2349. function ldap_delete_ext_sW; external LDAPLib name 'ldap_delete_ext_sW';
  2350. function ldap_delete_ext_s; external LDAPLib name 'ldap_delete_ext_sA';
  2351. function ldap_parse_resultA; external LDAPLib name 'ldap_parse_resultA';
  2352. function ldap_parse_resultW; external LDAPLib name 'ldap_parse_resultW';
  2353. function ldap_parse_result; external LDAPLib name 'ldap_parse_resultA';
  2354. function ldap_controls_freeA; external LDAPLib name 'ldap_controls_freeA';
  2355. function ldap_controls_freeW; external LDAPLib name 'ldap_controls_freeW';
  2356. function ldap_controls_free; external LDAPLib name 'ldap_controls_freeA';
  2357. function ldap_parse_extended_resultA; external LDAPLib name 'ldap_parse_extended_resultA';
  2358. function ldap_parse_extended_resultW; external LDAPLib name 'ldap_parse_extended_resultW';
  2359. function ldap_parse_extended_result; external LDAPLib name 'ldap_parse_extended_resultA';
  2360. function ldap_control_freeA; external LDAPLib name 'ldap_control_freeA';
  2361. function ldap_control_freeW; external LDAPLib name 'ldap_control_freeW';
  2362. function ldap_control_free; external LDAPLib name 'ldap_control_freeA';
  2363. function ldap_free_controlsA; external LDAPLib name 'ldap_free_controlsA';
  2364. function ldap_free_controlsW; external LDAPLib name 'ldap_free_controlsW';
  2365. function ldap_free_controls; external LDAPLib name 'ldap_free_controlsA';
  2366. function ldap_create_sort_controlA; external LDAPLib name 'ldap_create_sort_controlA';
  2367. function ldap_create_sort_controlW; external LDAPLib name 'ldap_create_sort_controlW';
  2368. function ldap_create_sort_control; external LDAPLib name 'ldap_create_sort_controlA';
  2369. function ldap_parse_sort_controlA; external LDAPLib name 'ldap_parse_sort_controlA';
  2370. function ldap_parse_sort_controlW; external LDAPLib name 'ldap_parse_sort_controlW';
  2371. function ldap_parse_sort_control; external LDAPLib name 'ldap_parse_sort_controlA';
  2372. function ldap_encode_sort_controlA; external LDAPLib name 'ldap_encode_sort_controlA';
  2373. function ldap_encode_sort_controlW; external LDAPLib name 'ldap_encode_sort_controlW';
  2374. function ldap_encode_sort_control; external LDAPLib name 'ldap_encode_sort_controlA';
  2375. function ldap_create_page_controlA; external LDAPLib name 'ldap_create_page_controlA';
  2376. function ldap_create_page_controlW; external LDAPLib name 'ldap_create_page_controlW';
  2377. function ldap_create_page_control; external LDAPLib name 'ldap_create_page_controlA';
  2378. function ldap_parse_page_controlA; external LDAPLib name 'ldap_parse_page_controlA';
  2379. function ldap_parse_page_controlW; external LDAPLib name 'ldap_parse_page_controlW';
  2380. function ldap_parse_page_control; external LDAPLib name 'ldap_parse_page_controlA';
  2381. function ldap_search_init_pageA; external LDAPLib name 'ldap_search_init_pageA';
  2382. function ldap_search_init_pageW; external LDAPLib name 'ldap_search_init_pageW';
  2383. function ldap_search_init_page; external LDAPLib name 'ldap_search_init_pageA';
  2384. function ldap_parse_referenceA; external LDAPLib name 'ldap_parse_referenceA';
  2385. function ldap_parse_referenceW; external LDAPLib name 'ldap_parse_referenceW';
  2386. function ldap_parse_reference; external LDAPLib name 'ldap_parse_referenceA';
  2387. function ldap_extended_operationA; external LDAPLib name 'ldap_extended_operationA';
  2388. function ldap_extended_operationW; external LDAPLib name 'ldap_extended_operationW';
  2389. function ldap_extended_operation; external LDAPLib name 'ldap_extended_operationA';
  2390. function ldap_unbind; external LDAPLib name 'ldap_unbind';
  2391. function ldap_unbind_s; external LDAPLib name 'ldap_unbind_s';
  2392. function ldap_get_option; external LDAPLib name 'ldap_get_option';
  2393. function ldap_set_option; external LDAPLib name 'ldap_set_option';
  2394. function ldap_get_optionW; external LDAPLib name 'ldap_get_optionW';
  2395. function ldap_set_optionW; external LDAPLib name 'ldap_set_optionW';
  2396. function ldap_abandon; external LDAPLib name 'ldap_abandon';
  2397. function ldap_result; external LDAPLib name 'ldap_result';
  2398. function ldap_msgfree; external LDAPLib name 'ldap_msgfree';
  2399. function ldap_result2error; external LDAPLib name 'ldap_result2error';
  2400. procedure ldap_perror; external LDAPLib name 'ldap_perror';
  2401. function ldap_first_entry; external LDAPLib name 'ldap_first_entry';
  2402. function ldap_next_entry; external LDAPLib name 'ldap_next_entry';
  2403. function ldap_count_entries; external LDAPLib name 'ldap_count_entries';
  2404. function ldap_count_values_len; external LDAPLib name 'ldap_count_values_len';
  2405. function ldap_value_free_len; external LDAPLib name 'ldap_value_free_len';
  2406. function ldap_startup; external LDAPLib name 'ldap_startup';
  2407. function ldap_cleanup; external LDAPLib name 'ldap_cleanup';
  2408. function ldap_set_dbg_flags; external LDAPLib name 'ldap_set_dbg_flags';
  2409. function ldap_connect; external LDAPLib name 'ldap_connect';
  2410. procedure ber_bvfree; external LDAPLib name 'ber_bvfree';
  2411. procedure ldap_set_dbg_routine; external LDAPLib name 'ldap_set_dbg_routine';
  2412. function LdapUTF8ToUnicode; external LDAPLib name 'LdapUTF8ToUnicode';
  2413. function LdapUnicodeToUTF8; external LDAPLib name 'LdapUnicodeToUTF8';
  2414. function ldap_get_next_page; external LDAPLib name 'ldap_get_next_page';
  2415. function ldap_get_next_page_s; external LDAPLib name 'ldap_get_next_page_s';
  2416. function ldap_get_paged_count; external LDAPLib name 'ldap_get_paged_count';
  2417. function ldap_search_abandon_page; external LDAPLib name 'ldap_search_abandon_page';
  2418. function ldap_first_reference; external LDAPLib name 'ldap_first_reference';
  2419. function ldap_next_reference; external LDAPLib name 'ldap_next_reference';
  2420. function ldap_count_references; external LDAPLib name 'ldap_count_references';
  2421. function ldap_close_extended_op; external LDAPLib name 'ldap_close_extended_op';
  2422. function LdapGetLastError; external LDAPLib name 'LdapGetLastError';
  2423. function LdapMapErrorToWin32; external LDAPLib name 'LdapMapErrorToWin32';
  2424. function ldap_conn_from_msg; external LDAPLib name 'ldap_conn_from_msg';
  2425. // Macros.
  2426. function LDAP_IS_CLDAP(ld: PLDAP): boolean;
  2427. begin
  2428. Result :=(ld^.ld_sb.sb_naddr > 0);
  2429. end;
  2430. function NAME_ERROR(n: integer): boolean;
  2431. begin
  2432. Result :=((n and $f0) = $20);
  2433. end;
  2434. end.