IdSSPI.pas 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.1 13.1.2004 17:26:00 DBondzhev
  18. Added Domain property
  19. Rev 1.0 11/13/2002 08:01:52 AM JPMugaas
  20. }
  21. {
  22. SSPI interface and objects Unit
  23. Copyright (c) 1999-2001, Eventree Systems
  24. Translator: Eventree Systems
  25. this unit contains translation of:
  26. Security.h, sspi.h, secext.h, rpcdce.h (some of)
  27. }
  28. unit IdSSPI;
  29. {$ALIGN ON}
  30. {$MINENUMSIZE 4}
  31. interface
  32. {$i IdCompilerDefines.inc}
  33. uses
  34. IdGlobal,
  35. Windows;
  36. type
  37. PPVOID = ^PVOID;
  38. {$NODEFINE PPVOID}
  39. PVOID = Pointer;
  40. {$NODEFINE PVOID}
  41. PUSHORT = ^USHORT;
  42. {$NODEFINE PUSHORT}
  43. USHORT = Word;
  44. {$NODEFINE USHORT}
  45. PUCHAR = ^UCHAR;
  46. {$NODEFINE PUCHAR}
  47. UCHAR = Byte;
  48. {$NODEFINE UCHAR}
  49. (*$HPPEMIT '//#define SECURITY_WIN32'*)
  50. (*$HPPEMIT '#include <security.h>'*)
  51. //+-----------------------------------------------------------------------
  52. //
  53. // Microsoft Windows
  54. //
  55. // Copyright (c) Microsoft Corporation 1991-1999
  56. //
  57. // File: Security.h
  58. //
  59. // Contents: Toplevel include file for security aware components
  60. //
  61. //
  62. // History: 06 Aug 92 RichardW Created
  63. // 23 Sep 92 PeterWi Add security object include files
  64. //
  65. //------------------------------------------------------------------------
  66. //
  67. // These are name that can be used to refer to the builtin packages
  68. //
  69. const
  70. NTLMSP_NAME = 'NTLM'; {Do not Localize}
  71. {$EXTERNALSYM NTLMSP_NAME}
  72. MICROSOFT_KERBEROS_NAME = 'Kerberos'; {Do not Localize}
  73. {$EXTERNALSYM MICROSOFT_KERBEROS_NAME}
  74. NEGOSSP_NAME = 'Negotiate'; {Do not Localize}
  75. {$EXTERNALSYM NEGOSSP_NAME}
  76. //+---------------------------------------------------------------------------
  77. //
  78. // Microsoft Windows
  79. // Copyright (C) Microsoft Corporation, 1992-1997.
  80. //
  81. // File: sspi.h
  82. //
  83. // Contents: Security Support Provider Interface
  84. // Prototypes and structure definitions
  85. //
  86. // Functions: Security Support Provider API
  87. //
  88. // History: 11-24-93 RichardW Created
  89. //
  90. //----------------------------------------------------------------------------
  91. type
  92. PSEC_WCHAR = PWideChar;
  93. {$NODEFINE PSEC_WCHAR}
  94. SEC_WCHAR = WideChar;
  95. {$EXTERNALSYM SEC_WCHAR}
  96. PSEC_CHAR = PAnsiChar;
  97. {$NODEFINE PSEC_CHAR}
  98. SEC_CHAR = AnsiChar;
  99. {$EXTERNALSYM SEC_CHAR}
  100. PSECURITY_STATUS = ^SECURITY_STATUS;
  101. {$NODEFINE PSECURITY_STATUS}
  102. SECURITY_STATUS = Longint{LONG}; // LONG is not defined in Windows.pas prior to Delphi 8
  103. {$EXTERNALSYM SECURITY_STATUS}
  104. //
  105. // Decide what a string - 32 bits only since for 16 bits it is clear.
  106. //
  107. type
  108. {$IFDEF SSPI_UNICODE}
  109. SECURITY_PSTR = ^SEC_WCHAR;
  110. {$ELSE}
  111. SECURITY_PSTR = ^SEC_CHAR;
  112. {$ENDIF}
  113. {$EXTERNALSYM SECURITY_PSTR}
  114. //
  115. // Okay, security specific types:
  116. //
  117. type
  118. PSecHandle = ^SecHandle;
  119. {$EXTERNALSYM PSecHandle}
  120. //Define ULONG_PTR as PtrUInt so we can use this unit in FreePascal.
  121. SecHandle = record
  122. dwLower: PtrUInt; // ULONG_PTR
  123. dwUpper: PtrUInt; // ULONG_PTR
  124. end;
  125. {$EXTERNALSYM SecHandle}
  126. CredHandle = SecHandle;
  127. {$EXTERNALSYM CredHandle}
  128. PCredHandle = PSecHandle;
  129. {$EXTERNALSYM PCredHandle}
  130. CtxtHandle = SecHandle;
  131. {$EXTERNALSYM CtxtHandle}
  132. PCtxtHandle = PSecHandle;
  133. {$EXTERNALSYM PCtxtHandle}
  134. PSECURITY_INTEGER = ^SECURITY_INTEGER;
  135. {$EXTERNALSYM PSECURITY_INTEGER}
  136. SECURITY_INTEGER = LARGE_INTEGER;
  137. {$EXTERNALSYM SECURITY_INTEGER}
  138. PTimeStamp = ^TimeStamp;
  139. {$EXTERNALSYM PTimeStamp}
  140. TimeStamp = SECURITY_INTEGER;
  141. {$EXTERNALSYM TimeStamp}
  142. procedure SecInvalidateHandle(var x: SecHandle); {$IFDEF USE_INLINE} inline; {$ENDIF}
  143. {$EXTERNALSYM SecInvalidateHandle}
  144. function SecIsValidHandle(x : SecHandle) : Boolean; {$IFDEF USE_INLINE} inline; {$ENDIF}
  145. {$EXTERNALSYM SecIsValidHandle}
  146. function SEC_SUCCESS(Status: SECURITY_STATUS): Boolean; {$IFDEF USE_INLINE} inline; {$ENDIF}
  147. {$EXTERNALSYM SEC_SUCCESS}
  148. type
  149. //
  150. // If we are in 32 bit mode, define the SECURITY_STRING structure,
  151. // as a clone of the base UNICODE_STRING structure. This is used
  152. // internally in security components, an as the string interface
  153. // for kernel components (e.g. FSPs)
  154. //
  155. PSECURITY_STRING = ^SECURITY_STRING;
  156. {$EXTERNALSYM PSECURITY_STRING}
  157. SECURITY_STRING = record
  158. Length: USHORT;
  159. MaximumLength: USHORT;
  160. Buffer: PUSHORT;
  161. end;
  162. {$EXTERNALSYM SECURITY_STRING}
  163. //
  164. // SecPkgInfo structure
  165. //
  166. // Provides general information about a security provider
  167. //
  168. type
  169. PPSecPkgInfoW = ^PSecPkgInfoW;
  170. {$NODEFINE PPSecPkgInfoW}
  171. PSecPkgInfoW = ^SecPkgInfoW;
  172. {$EXTERNALSYM PSecPkgInfoW}
  173. SecPkgInfoW = record
  174. fCapabilities: ULONG; // Capability bitmask
  175. wVersion: USHORT; // Version of driver
  176. wRPCID: USHORT; // ID for RPC Runtime
  177. cbMaxToken: ULONG; // Size of authentication token (max)
  178. Name: PSEC_WCHAR; // Text name
  179. Comment: PSEC_WCHAR; // Comment
  180. end;
  181. {$EXTERNALSYM SecPkgInfoW}
  182. PPSecPkgInfoA = ^PSecPkgInfoA;
  183. {$NODEFINE PPSecPkgInfoA}
  184. PSecPkgInfoA = ^SecPkgInfoA;
  185. {$EXTERNALSYM PSecPkgInfoA}
  186. SecPkgInfoA = record
  187. fCapabilities: ULONG; // Capability bitmask
  188. wVersion: USHORT; // Version of driver
  189. wRPCID: USHORT; // ID for RPC Runtime
  190. cbMaxToken: ULONG; // Size of authentication token (max)
  191. Name: PSEC_CHAR; // Text name
  192. Comment: PSEC_CHAR; // Comment
  193. end;
  194. {$EXTERNALSYM SecPkgInfoA}
  195. {$IFDEF SSPI_UNICODE}
  196. SecPkgInfo = SecPkgInfoW;
  197. PSecPkgInfo = PSecPkgInfoW;
  198. {$ELSE}
  199. SecPkgInfo = SecPkgInfoA;
  200. PSecPkgInfo = PSecPkgInfoA;
  201. {$ENDIF}
  202. {$EXTERNALSYM SecPkgInfo}
  203. {$EXTERNALSYM PSecPkgInfo}
  204. //
  205. // Security Package Capabilities
  206. //
  207. const
  208. SECPKG_FLAG_INTEGRITY = $00000001; // Supports integrity on messages
  209. {$EXTERNALSYM SECPKG_FLAG_INTEGRITY}
  210. SECPKG_FLAG_PRIVACY = $00000002; // Supports privacy (confidentiality)
  211. {$EXTERNALSYM SECPKG_FLAG_PRIVACY}
  212. SECPKG_FLAG_TOKEN_ONLY = $00000004; // Only security token needed
  213. {$EXTERNALSYM SECPKG_FLAG_TOKEN_ONLY}
  214. SECPKG_FLAG_DATAGRAM = $00000008; // Datagram RPC support
  215. {$EXTERNALSYM SECPKG_FLAG_DATAGRAM}
  216. SECPKG_FLAG_CONNECTION = $00000010; // Connection oriented RPC support
  217. {$EXTERNALSYM SECPKG_FLAG_CONNECTION}
  218. SECPKG_FLAG_MULTI_REQUIRED = $00000020; // Full 3-leg required for re-auth.
  219. {$EXTERNALSYM SECPKG_FLAG_MULTI_REQUIRED}
  220. SECPKG_FLAG_CLIENT_ONLY = $00000040; // Server side functionality not available
  221. {$EXTERNALSYM SECPKG_FLAG_CLIENT_ONLY}
  222. SECPKG_FLAG_EXTENDED_ERROR = $00000080; // Supports extended error msgs
  223. {$EXTERNALSYM SECPKG_FLAG_EXTENDED_ERROR}
  224. SECPKG_FLAG_IMPERSONATION = $00000100; // Supports impersonation
  225. {$EXTERNALSYM SECPKG_FLAG_IMPERSONATION}
  226. SECPKG_FLAG_ACCEPT_WIN32_NAME = $00000200; // Accepts Win32 names
  227. {$EXTERNALSYM SECPKG_FLAG_ACCEPT_WIN32_NAME}
  228. SECPKG_FLAG_STREAM = $00000400; // Supports stream semantics
  229. {$EXTERNALSYM SECPKG_FLAG_STREAM}
  230. SECPKG_FLAG_NEGOTIABLE = $00000800; // Can be used by the negotiate package
  231. {$EXTERNALSYM SECPKG_FLAG_NEGOTIABLE}
  232. SECPKG_FLAG_GSS_COMPATIBLE = $00001000; // GSS Compatibility Available
  233. {$EXTERNALSYM SECPKG_FLAG_GSS_COMPATIBLE}
  234. SECPKG_FLAG_LOGON = $00002000; // Supports common LsaLogonUser
  235. {$EXTERNALSYM SECPKG_FLAG_LOGON}
  236. SECPKG_FLAG_ASCII_BUFFERS = $00004000; // Token Buffers are in ASCII
  237. {$EXTERNALSYM SECPKG_FLAG_ASCII_BUFFERS}
  238. SECPKG_FLAG_FRAGMENT = $00008000; // Package can fragment to fit
  239. {$EXTERNALSYM SECPKG_FLAG_FRAGMENT}
  240. SECPKG_FLAG_MUTUAL_AUTH = $00010000; // Package can perform mutual authentication
  241. {$EXTERNALSYM SECPKG_FLAG_MUTUAL_AUTH}
  242. SECPKG_FLAG_DELEGATION = $00020000; // Package can delegate
  243. {$EXTERNALSYM SECPKG_FLAG_DELEGATION}
  244. SECPKG_FLAG_READONLY_WITH_CHECKSUM = $00040000; // Package can delegate
  245. {$EXTERNALSYM SECPKG_FLAG_READONLY_WITH_CHECKSUM}
  246. SECPKG_FLAG_RESTRICTED_TOKENS = $00080000; // Package supports restricted callers
  247. {$EXTERNALSYM SECPKG_FLAG_RESTRICTED_TOKENS}
  248. SECPKG_FLAG_NEGO_EXTENDER = $00100000; // this package extends SPNEGO, there is at most one
  249. {$EXTERNALSYM SECPKG_FLAG_NEGO_EXTENDER}
  250. SECPKG_FLAG_NEGOTIABLE2 = $00200000; // this package is negotiated under the NegoExtender
  251. {$EXTERNALSYM SECPKG_FLAG_NEGOTIABLE2}
  252. SECPKG_ID_NONE = $FFFF;
  253. {$EXTERNALSYM SECPKG_ID_NONE}
  254. //
  255. // SecBuffer
  256. //
  257. // Generic memory descriptors for buffers passed in to the security
  258. // API
  259. //
  260. type
  261. PSecBuffer = ^SecBuffer;
  262. {$EXTERNALSYM PSecBuffer}
  263. SecBuffer = record
  264. cbBuffer: ULONG; // Size of the buffer, in bytes
  265. BufferType: ULONG; // Type of the buffer (below)
  266. pvBuffer: PVOID; // Pointer to the buffer
  267. end;
  268. {$EXTERNALSYM SecBuffer}
  269. PSecBufferDesc = ^SecBufferDesc;
  270. {$EXTERNALSYM PSecBufferDesc}
  271. SecBufferDesc = record
  272. ulVersion: ULONG; // Version number
  273. cBuffers: ULONG; // Number of buffers
  274. pBuffers: PSecBuffer; // Pointer to array of buffers
  275. end;
  276. {$EXTERNALSYM SecBufferDesc}
  277. const
  278. SECBUFFER_VERSION = 0;
  279. {$EXTERNALSYM SECBUFFER_VERSION}
  280. SECBUFFER_EMPTY = 0; // Undefined, replaced by provider
  281. {$EXTERNALSYM SECBUFFER_EMPTY}
  282. SECBUFFER_DATA = 1; // Packet data
  283. {$EXTERNALSYM SECBUFFER_DATA}
  284. SECBUFFER_TOKEN = 2; // Security token
  285. {$EXTERNALSYM SECBUFFER_TOKEN}
  286. SECBUFFER_PKG_PARAMS = 3; // Package specific parameters
  287. {$EXTERNALSYM SECBUFFER_PKG_PARAMS}
  288. SECBUFFER_MISSING = 4; // Missing Data indicator
  289. {$EXTERNALSYM SECBUFFER_MISSING}
  290. SECBUFFER_EXTRA = 5; // Extra data
  291. {$EXTERNALSYM SECBUFFER_EXTRA}
  292. SECBUFFER_STREAM_TRAILER = 6; // Security Trailer
  293. {$EXTERNALSYM SECBUFFER_STREAM_TRAILER}
  294. SECBUFFER_STREAM_HEADER = 7; // Security Header
  295. {$EXTERNALSYM SECBUFFER_STREAM_HEADER}
  296. SECBUFFER_NEGOTIATION_INFO = 8; // Hints from the negotiation pkg
  297. {$EXTERNALSYM SECBUFFER_NEGOTIATION_INFO}
  298. SECBUFFER_PADDING = 9; // non-data padding
  299. {$EXTERNALSYM SECBUFFER_PADDING}
  300. SECBUFFER_STREAM = 10; // whole encrypted message
  301. {$EXTERNALSYM SECBUFFER_STREAM}
  302. SECBUFFER_MECHLIST = 11;
  303. {$EXTERNALSYM SECBUFFER_MECHLIST}
  304. SECBUFFER_MECHLIST_SIGNATURE = 12;
  305. {$EXTERNALSYM SECBUFFER_MECHLIST_SIGNATURE}
  306. SECBUFFER_TARGET = 13; // obsolete
  307. {$EXTERNALSYM SECBUFFER_TARGET}
  308. SECBUFFER_CHANNEL_BINDINGS = 14;
  309. {$EXTERNALSYM SECBUFFER_CHANNEL_BINDINGS}
  310. SECBUFFER_CHANGE_PASS_RESPONSE = 15;
  311. {$EXTERNALSYM SECBUFFER_CHANGE_PASS_RESPONSE}
  312. SECBUFFER_TARGET_HOST = 16;
  313. {$EXTERNALSYM SECBUFFER_TARGET_HOST}
  314. SECBUFFER_ALERT = 17;
  315. {$EXTERNALSYM SECBUFFER_ALERT}
  316. SECBUFFER_ATTRMASK = $F0000000;
  317. {$EXTERNALSYM SECBUFFER_ATTRMASK}
  318. SECBUFFER_READONLY = $80000000; // Buffer is read-only
  319. {$EXTERNALSYM SECBUFFER_READONLY}
  320. SECBUFFER_READONLY_WITH_CHECKSUM = $10000000; // Buffer is read-only, and checksummed;
  321. {$EXTERNALSYM SECBUFFER_READONLY_WITH_CHECKSUM}
  322. SECBUFFER_RESERVED = $40000000;
  323. {$EXTERNALSYM SECBUFFER_RESERVED}
  324. type
  325. PSEC_NEGOTIATION_INFO = ^SEC_NEGOTIATION_INFO;
  326. {$EXTERNALSYM PSEC_NEGOTIATION_INFO}
  327. SEC_NEGOTIATION_INFO = record
  328. Size: ULONG; // Size of this structure
  329. NameLength: ULONG; // Length of name hint
  330. Name: PSEC_WCHAR; // Name hint
  331. Reserved: PVOID; // Reserved
  332. end;
  333. {$EXTERNALSYM SEC_NEGOTIATION_INFO}
  334. PSEC_CHANNEL_BINDINGS = ^SEC_CHANNEL_BINDINGS;
  335. {$EXTERNALSYM PSEC_CHANNEL_BINDINGS}
  336. SEC_CHANNEL_BINDINGS = record
  337. dwInitiatorAddrType: ULONG;
  338. cbInitiatorLength: ULONG;
  339. dwInitiatorOffset: ULONG;
  340. dwAcceptorAddrType: ULONG;
  341. cbAcceptorLength: ULONG;
  342. dwAcceptorOffset: ULONG;
  343. cbApplicationDataLength: ULONG;
  344. dwApplicationDataOffset: ULONG;
  345. end;
  346. {$EXTERNALSYM SEC_CHANNEL_BINDINGS}
  347. //
  348. // Data Representation Constant:
  349. //
  350. const
  351. SECURITY_NATIVE_DREP = $00000010;
  352. {$EXTERNALSYM SECURITY_NATIVE_DREP}
  353. SECURITY_NETWORK_DREP = $00000000;
  354. {$EXTERNALSYM SECURITY_NETWORK_DREP}
  355. //
  356. // Credential Use Flags
  357. //
  358. const
  359. SECPKG_CRED_INBOUND = $00000001;
  360. {$EXTERNALSYM SECPKG_CRED_INBOUND}
  361. SECPKG_CRED_OUTBOUND = $00000002;
  362. {$EXTERNALSYM SECPKG_CRED_OUTBOUND}
  363. SECPKG_CRED_BOTH = $00000003;
  364. {$EXTERNALSYM SECPKG_CRED_BOTH}
  365. SECPKG_CRED_DEFAULT = $00000004;
  366. {$EXTERNALSYM SECPKG_CRED_DEFAULT}
  367. SECPKG_CRED_RESERVED = $F0000000;
  368. {$EXTERNALSYM SECPKG_CRED_RESERVED}
  369. //
  370. // SSP SHOULD prompt the user for credentials/consent, independent
  371. // of whether credentials to be used are the 'logged on' credentials
  372. // or retrieved from credman.
  373. //
  374. // An SSP may choose not to prompt, however, in circumstances determined
  375. // by the SSP.
  376. //
  377. SECPKG_CRED_AUTOLOGON_RESTRICTED = $00000010;
  378. {$EXTERNALSYM SECPKG_CRED_AUTOLOGON_RESTRICTED}
  379. //
  380. // auth will always fail, ISC() is called to process policy data only
  381. //
  382. SECPKG_CRED_PROCESS_POLICY_ONLY = $00000020;
  383. {$EXTERNALSYM SECPKG_CRED_PROCESS_POLICY_ONLY}
  384. const
  385. //
  386. // InitializeSecurityContext Requirement and return flags:
  387. //
  388. ISC_REQ_DELEGATE = $00000001;
  389. {$EXTERNALSYM ISC_REQ_DELEGATE}
  390. ISC_REQ_MUTUAL_AUTH = $00000002;
  391. {$EXTERNALSYM ISC_REQ_MUTUAL_AUTH}
  392. ISC_REQ_REPLAY_DETECT = $00000004;
  393. {$EXTERNALSYM ISC_REQ_REPLAY_DETECT}
  394. ISC_REQ_SEQUENCE_DETECT = $00000008;
  395. {$EXTERNALSYM ISC_REQ_SEQUENCE_DETECT}
  396. ISC_REQ_CONFIDENTIALITY = $00000010;
  397. {$EXTERNALSYM ISC_REQ_CONFIDENTIALITY}
  398. ISC_REQ_USE_SESSION_KEY = $00000020;
  399. {$EXTERNALSYM ISC_REQ_USE_SESSION_KEY}
  400. ISC_REQ_PROMPT_FOR_CREDS = $00000040;
  401. {$EXTERNALSYM ISC_REQ_PROMPT_FOR_CREDS}
  402. ISC_REQ_USE_SUPPLIED_CREDS = $00000080;
  403. {$EXTERNALSYM ISC_REQ_USE_SUPPLIED_CREDS}
  404. ISC_REQ_ALLOCATE_MEMORY = $00000100;
  405. {$EXTERNALSYM ISC_REQ_ALLOCATE_MEMORY}
  406. ISC_REQ_USE_DCE_STYLE = $00000200;
  407. {$EXTERNALSYM ISC_REQ_USE_DCE_STYLE}
  408. ISC_REQ_DATAGRAM = $00000400;
  409. {$EXTERNALSYM ISC_REQ_DATAGRAM}
  410. ISC_REQ_CONNECTION = $00000800;
  411. {$EXTERNALSYM ISC_REQ_CONNECTION}
  412. ISC_REQ_CALL_LEVEL = $00001000;
  413. {$EXTERNALSYM ISC_REQ_CALL_LEVEL}
  414. ISC_REQ_FRAGMENT_SUPPLIED = $00002000;
  415. {$EXTERNALSYM ISC_REQ_FRAGMENT_SUPPLIED}
  416. ISC_REQ_EXTENDED_ERROR = $00004000;
  417. {$EXTERNALSYM ISC_REQ_EXTENDED_ERROR}
  418. ISC_REQ_STREAM = $00008000;
  419. {$EXTERNALSYM ISC_REQ_STREAM}
  420. ISC_REQ_INTEGRITY = $00010000;
  421. {$EXTERNALSYM ISC_REQ_INTEGRITY}
  422. ISC_REQ_IDENTIFY = $00020000;
  423. {$EXTERNALSYM ISC_REQ_IDENTIFY}
  424. ISC_REQ_NULL_SESSION = $00040000;
  425. {$EXTERNALSYM ISC_REQ_NULL_SESSION}
  426. ISC_REQ_MANUAL_CRED_VALIDATION = $00080000;
  427. {$EXTERNALSYM ISC_REQ_MANUAL_CRED_VALIDATION}
  428. ISC_REQ_RESERVED1 = $00100000;
  429. {$EXTERNALSYM ISC_REQ_RESERVED1}
  430. ISC_REQ_FRAGMENT_TO_FIT = $00200000;
  431. {$EXTERNALSYM ISC_REQ_FRAGMENT_TO_FIT}
  432. // This exists only in Windows Vista and greater
  433. ISC_REQ_FORWARD_CREDENTIALS = $00400000;
  434. {$EXTERNALSYM ISC_REQ_FORWARD_CREDENTIALS}
  435. ISC_REQ_NO_INTEGRITY = $00800000; // honored only by SPNEGO
  436. {$EXTERNALSYM ISC_REQ_NO_INTEGRITY}
  437. ISC_REQ_USE_HTTP_STYLE = $01000000;
  438. {$EXTERNALSYM ISC_REQ_USE_HTTP_STYLE}
  439. ISC_RET_DELEGATE = $00000001;
  440. {$EXTERNALSYM ISC_RET_DELEGATE}
  441. ISC_RET_MUTUAL_AUTH = $00000002;
  442. {$EXTERNALSYM ISC_RET_MUTUAL_AUTH}
  443. ISC_RET_REPLAY_DETECT = $00000004;
  444. {$EXTERNALSYM ISC_RET_REPLAY_DETECT}
  445. ISC_RET_SEQUENCE_DETECT = $00000008;
  446. {$EXTERNALSYM ISC_RET_SEQUENCE_DETECT}
  447. ISC_RET_CONFIDENTIALITY = $00000010;
  448. {$EXTERNALSYM ISC_RET_CONFIDENTIALITY}
  449. ISC_RET_USE_SESSION_KEY = $00000020;
  450. {$EXTERNALSYM ISC_RET_USE_SESSION_KEY}
  451. ISC_RET_USED_COLLECTED_CREDS = $00000040;
  452. {$EXTERNALSYM ISC_RET_USED_COLLECTED_CREDS}
  453. ISC_RET_USED_SUPPLIED_CREDS = $00000080;
  454. {$EXTERNALSYM ISC_RET_USED_SUPPLIED_CREDS}
  455. ISC_RET_ALLOCATED_MEMORY = $00000100;
  456. {$EXTERNALSYM ISC_RET_ALLOCATED_MEMORY}
  457. ISC_RET_USED_DCE_STYLE = $00000200;
  458. {$EXTERNALSYM ISC_RET_USED_DCE_STYLE}
  459. ISC_RET_DATAGRAM = $00000400;
  460. {$EXTERNALSYM ISC_RET_DATAGRAM}
  461. ISC_RET_CONNECTION = $00000800;
  462. {$EXTERNALSYM ISC_RET_CONNECTION}
  463. ISC_RET_INTERMEDIATE_RETURN = $00001000;
  464. {$EXTERNALSYM ISC_RET_INTERMEDIATE_RETURN}
  465. ISC_RET_CALL_LEVEL = $00002000;
  466. {$EXTERNALSYM ISC_RET_CALL_LEVEL}
  467. ISC_RET_EXTENDED_ERROR = $00004000;
  468. {$EXTERNALSYM ISC_RET_EXTENDED_ERROR}
  469. ISC_RET_STREAM = $00008000;
  470. {$EXTERNALSYM ISC_RET_STREAM}
  471. ISC_RET_INTEGRITY = $00010000;
  472. {$EXTERNALSYM ISC_RET_INTEGRITY}
  473. ISC_RET_IDENTIFY = $00020000;
  474. {$EXTERNALSYM ISC_RET_IDENTIFY}
  475. ISC_RET_NULL_SESSION = $00040000;
  476. {$EXTERNALSYM ISC_RET_NULL_SESSION}
  477. ISC_RET_MANUAL_CRED_VALIDATION = $00080000;
  478. {$EXTERNALSYM ISC_RET_MANUAL_CRED_VALIDATION}
  479. ISC_RET_RESERVED1 = $00100000;
  480. {$EXTERNALSYM ISC_RET_RESERVED1}
  481. ISC_RET_FRAGMENT_ONLY = $00200000;
  482. {$EXTERNALSYM ISC_RET_FRAGMENT_ONLY}
  483. // This exists only in Windows Vista and greater
  484. ISC_RET_FORWARD_CREDENTIALS = $00400000;
  485. {$EXTERNALSYM ISC_RET_FORWARD_CREDENTIALS}
  486. ISC_RET_USED_HTTP_STYLE = $01000000;
  487. {$EXTERNALSYM ISC_RET_USED_HTTP_STYLE}
  488. ISC_RET_NO_ADDITIONAL_TOKEN = $02000000; // *INTERNAL*
  489. {$EXTERNALSYM ISC_RET_NO_ADDITIONAL_TOKEN}
  490. ISC_RET_REAUTHENTICATION = $08000000; // *INTERNAL*
  491. {$EXTERNALSYM ISC_RET_REAUTHENTICATION}
  492. ASC_REQ_DELEGATE = $00000001;
  493. {$EXTERNALSYM ASC_REQ_DELEGATE}
  494. ASC_REQ_MUTUAL_AUTH = $00000002;
  495. {$EXTERNALSYM ASC_REQ_MUTUAL_AUTH}
  496. ASC_REQ_REPLAY_DETECT = $00000004;
  497. {$EXTERNALSYM ASC_REQ_REPLAY_DETECT}
  498. ASC_REQ_SEQUENCE_DETECT = $00000008;
  499. {$EXTERNALSYM ASC_REQ_SEQUENCE_DETECT}
  500. ASC_REQ_CONFIDENTIALITY = $00000010;
  501. {$EXTERNALSYM ASC_REQ_CONFIDENTIALITY}
  502. ASC_REQ_USE_SESSION_KEY = $00000020;
  503. {$EXTERNALSYM ASC_REQ_USE_SESSION_KEY}
  504. ASC_REQ_ALLOCATE_MEMORY = $00000100;
  505. {$EXTERNALSYM ASC_REQ_ALLOCATE_MEMORY}
  506. ASC_REQ_USE_DCE_STYLE = $00000200;
  507. {$EXTERNALSYM ASC_REQ_USE_DCE_STYLE}
  508. ASC_REQ_DATAGRAM = $00000400;
  509. {$EXTERNALSYM ASC_REQ_DATAGRAM}
  510. ASC_REQ_CONNECTION = $00000800;
  511. {$EXTERNALSYM ASC_REQ_CONNECTION}
  512. ASC_REQ_CALL_LEVEL = $00001000;
  513. {$EXTERNALSYM ASC_REQ_CALL_LEVEL}
  514. ASC_REQ_EXTENDED_ERROR = $00008000;
  515. {$EXTERNALSYM ASC_REQ_EXTENDED_ERROR}
  516. ASC_REQ_STREAM = $00010000;
  517. {$EXTERNALSYM ASC_REQ_STREAM}
  518. ASC_REQ_INTEGRITY = $00020000;
  519. {$EXTERNALSYM ASC_REQ_INTEGRITY}
  520. ASC_REQ_LICENSING = $00040000;
  521. {$EXTERNALSYM ASC_REQ_LICENSING}
  522. ASC_REQ_IDENTIFY = $00080000;
  523. {$EXTERNALSYM ASC_REQ_IDENTIFY}
  524. ASC_REQ_ALLOW_NULL_SESSION = $00100000;
  525. {$EXTERNALSYM ASC_REQ_ALLOW_NULL_SESSION}
  526. ASC_REQ_ALLOW_NON_USER_LOGONS = $00200000;
  527. {$EXTERNALSYM ASC_REQ_ALLOW_NON_USER_LOGONS}
  528. ASC_REQ_ALLOW_CONTEXT_REPLAY = $00400000;
  529. {$EXTERNALSYM ASC_REQ_ALLOW_CONTEXT_REPLAY}
  530. ASC_REQ_FRAGMENT_TO_FIT = $00800000;
  531. {$EXTERNALSYM ASC_REQ_FRAGMENT_TO_FIT}
  532. ASC_REQ_FRAGMENT_SUPPLIED = $00002000;
  533. {$EXTERNALSYM ASC_REQ_FRAGMENT_SUPPLIED}
  534. ASC_REQ_NO_TOKEN = $01000000;
  535. {$EXTERNALSYM ASC_REQ_NO_TOKEN}
  536. ASC_REQ_PROXY_BINDINGS = $04000000;
  537. {$EXTERNALSYM ASC_REQ_PROXY_BINDINGS}
  538. // SSP_RET_REAUTHENTICATION = $08000000; // *INTERNAL*
  539. {.$EXTERNALSYM SSP_RET_REAUTHENTICATION}
  540. ASC_REQ_ALLOW_MISSING_BINDINGS = $10000000;
  541. {$EXTERNALSYM ASC_REQ_ALLOW_MISSING_BINDINGS}
  542. ASC_RET_DELEGATE = $00000001;
  543. {$EXTERNALSYM ASC_RET_DELEGATE}
  544. ASC_RET_MUTUAL_AUTH = $00000002;
  545. {$EXTERNALSYM ASC_RET_MUTUAL_AUTH}
  546. ASC_RET_REPLAY_DETECT = $00000004;
  547. {$EXTERNALSYM ASC_RET_REPLAY_DETECT}
  548. ASC_RET_SEQUENCE_DETECT = $00000008;
  549. {$EXTERNALSYM ASC_RET_SEQUENCE_DETECT}
  550. ASC_RET_CONFIDENTIALITY = $00000010;
  551. {$EXTERNALSYM ASC_RET_CONFIDENTIALITY}
  552. ASC_RET_USE_SESSION_KEY = $00000020;
  553. {$EXTERNALSYM ASC_RET_USE_SESSION_KEY}
  554. ASC_RET_ALLOCATED_MEMORY = $00000100;
  555. {$EXTERNALSYM ASC_RET_ALLOCATED_MEMORY}
  556. ASC_RET_USED_DCE_STYLE = $00000200;
  557. {$EXTERNALSYM ASC_RET_USED_DCE_STYLE}
  558. ASC_RET_DATAGRAM = $00000400;
  559. {$EXTERNALSYM ASC_RET_DATAGRAM}
  560. ASC_RET_CONNECTION = $00000800;
  561. {$EXTERNALSYM ASC_RET_CONNECTION}
  562. ASC_RET_CALL_LEVEL = $00002000; // skipped 1000 to be like ISC_
  563. {$EXTERNALSYM ASC_RET_CALL_LEVEL}
  564. ASC_RET_THIRD_LEG_FAILED = $00004000;
  565. {$EXTERNALSYM ASC_RET_THIRD_LEG_FAILED}
  566. ASC_RET_EXTENDED_ERROR = $00008000;
  567. {$EXTERNALSYM ASC_RET_EXTENDED_ERROR}
  568. ASC_RET_STREAM = $00010000;
  569. {$EXTERNALSYM ASC_RET_STREAM}
  570. ASC_RET_INTEGRITY = $00020000;
  571. {$EXTERNALSYM ASC_RET_INTEGRITY}
  572. ASC_RET_LICENSING = $00040000;
  573. {$EXTERNALSYM ASC_RET_LICENSING}
  574. ASC_RET_IDENTIFY = $00080000;
  575. {$EXTERNALSYM ASC_RET_IDENTIFY}
  576. ASC_RET_NULL_SESSION = $00100000;
  577. {$EXTERNALSYM ASC_RET_NULL_SESSION}
  578. ASC_RET_ALLOW_NON_USER_LOGONS = $00200000;
  579. {$EXTERNALSYM ASC_RET_ALLOW_NON_USER_LOGONS}
  580. ASC_RET_ALLOW_CONTEXT_REPLAY = $00400000;
  581. {$EXTERNALSYM ASC_RET_ALLOW_CONTEXT_REPLAY}
  582. ASC_RET_FRAGMENT_ONLY = $00800000;
  583. {$EXTERNALSYM ASC_RET_FRAGMENT_ONLY}
  584. ASC_RET_NO_TOKEN = $01000000;
  585. {$EXTERNALSYM ASC_RET_NO_TOKEN}
  586. ASC_RET_NO_ADDITIONAL_TOKEN = $02000000; // *INTERNAL*
  587. {$EXTERNALSYM ASC_RET_NO_ADDITIONAL_TOKEN}
  588. ASC_RET_NO_PROXY_BINDINGS = $04000000;
  589. {$EXTERNALSYM ASC_RET_NO_PROXY_BINDINGS}
  590. // SSP_RET_REAUTHENTICATION = $08000000; // *INTERNAL*
  591. {.$EXTERNALSYM SSP_RET_REAUTHENTICATION}
  592. ASC_RET_MISSING_BINDINGS = $10000000;
  593. {$EXTERNALSYM ASC_RET_MISSING_BINDINGS}
  594. //
  595. // Security Credentials Attributes:
  596. //
  597. const
  598. SECPKG_CRED_ATTR_NAMES = 1;
  599. {$EXTERNALSYM SECPKG_CRED_ATTR_NAMES}
  600. SECPKG_CRED_ATTR_SSI_PROVIDER = 2;
  601. {$EXTERNALSYM SECPKG_CRED_ATTR_SSI_PROVIDER}
  602. type
  603. PSecPkgCredentials_NamesW = ^SecPkgCredentials_NamesW;
  604. {$EXTERNALSYM PSecPkgCredentials_NamesW}
  605. SecPkgCredentials_NamesW = record
  606. sUserName: PSEC_WCHAR;
  607. end;
  608. {$EXTERNALSYM SecPkgCredentials_NamesW}
  609. PSecPkgCredentials_NamesA = ^SecPkgCredentials_NamesA;
  610. {$EXTERNALSYM PSecPkgCredentials_NamesA}
  611. SecPkgCredentials_NamesA = record
  612. sUserName: PSEC_CHAR;
  613. end;
  614. {$EXTERNALSYM SecPkgCredentials_NamesA}
  615. {$IFDEF SSPI_UNICODE}
  616. SecPkgCredentials_Names = SecPkgCredentials_NamesW;
  617. PSecPkgCredentials_Names = PSecPkgCredentials_NamesW;
  618. {$ELSE}
  619. SecPkgCredentials_Names = SecPkgCredentials_NamesA;
  620. PSecPkgCredentials_Names = PSecPkgCredentials_NamesA;
  621. {$ENDIF}
  622. {$EXTERNALSYM SecPkgCredentials_Names}
  623. {$EXTERNALSYM PSecPkgCredentials_Names}
  624. PSecPkgCredentials_SSIProviderW = ^SecPkgCredentials_SSIProviderW;
  625. {$EXTERNALSYM PSecPkgCredentials_SSIProviderW}
  626. SecPkgCredentials_SSIProviderW = record
  627. sProviderName: PSEC_WCHAR;
  628. ProviderInfoLength: ULONG;
  629. ProviderInfo: PAnsiChar;
  630. end;
  631. {$EXTERNALSYM SecPkgCredentials_SSIProviderW}
  632. PSecPkgCredentials_SSIProviderA = ^SecPkgCredentials_SSIProviderA;
  633. {$EXTERNALSYM PSecPkgCredentials_SSIProviderA}
  634. SecPkgCredentials_SSIProviderA = record
  635. sProviderName: PSEC_CHAR;
  636. ProviderInfoLength: ULONG;
  637. ProviderInfo: PAnsiChar;
  638. end;
  639. {$EXTERNALSYM SecPkgCredentials_SSIProviderA}
  640. {$IFDEF SSPI_UNICODE}
  641. SecPkgCredentials_SSIProvider = SecPkgCredentials_SSIProviderW;
  642. PSecPkgCredentials_SSIProvider = PSecPkgCredentials_SSIProviderW;
  643. {$ELSE}
  644. SecPkgCredentials_SSIProvider = SecPkgCredentials_SSIProviderA;
  645. PSecPkgCredentials_SSIProvider = PSecPkgCredentials_SSIProviderA;
  646. {$ENDIF}
  647. {$EXTERNALSYM SecPkgCredentials_SSIProvider}
  648. {$EXTERNALSYM PSecPkgCredentials_SSIProvider}
  649. //
  650. // Security Context Attributes:
  651. //
  652. const
  653. SECPKG_ATTR_SIZES = 0;
  654. {$EXTERNALSYM SECPKG_ATTR_SIZES}
  655. SECPKG_ATTR_NAMES = 1;
  656. {$EXTERNALSYM SECPKG_ATTR_NAMES}
  657. SECPKG_ATTR_LIFESPAN = 2;
  658. {$EXTERNALSYM SECPKG_ATTR_LIFESPAN}
  659. SECPKG_ATTR_DCE_INFO = 3;
  660. {$EXTERNALSYM SECPKG_ATTR_DCE_INFO}
  661. SECPKG_ATTR_STREAM_SIZES = 4;
  662. {$EXTERNALSYM SECPKG_ATTR_STREAM_SIZES}
  663. SECPKG_ATTR_KEY_INFO = 5;
  664. {$EXTERNALSYM SECPKG_ATTR_KEY_INFO}
  665. SECPKG_ATTR_AUTHORITY = 6;
  666. {$EXTERNALSYM SECPKG_ATTR_AUTHORITY}
  667. SECPKG_ATTR_PROTO_INFO = 7;
  668. {$EXTERNALSYM SECPKG_ATTR_PROTO_INFO}
  669. SECPKG_ATTR_PASSWORD_EXPIRY = 8;
  670. {$EXTERNALSYM SECPKG_ATTR_PASSWORD_EXPIRY}
  671. SECPKG_ATTR_SESSION_KEY = 9;
  672. {$EXTERNALSYM SECPKG_ATTR_SESSION_KEY}
  673. SECPKG_ATTR_PACKAGE_INFO = 10;
  674. {$EXTERNALSYM SECPKG_ATTR_PACKAGE_INFO}
  675. SECPKG_ATTR_USER_FLAGS = 11;
  676. {$EXTERNALSYM SECPKG_ATTR_USER_FLAGS}
  677. SECPKG_ATTR_NEGOTIATION_INFO = 12;
  678. {$EXTERNALSYM SECPKG_ATTR_NEGOTIATION_INFO}
  679. SECPKG_ATTR_NATIVE_NAMES = 13;
  680. {$EXTERNALSYM SECPKG_ATTR_NATIVE_NAMES}
  681. SECPKG_ATTR_FLAGS = 14;
  682. {$EXTERNALSYM SECPKG_ATTR_FLAGS}
  683. // These attributes exist only in Win XP and greater
  684. SECPKG_ATTR_USE_VALIDATED = 15;
  685. {$EXTERNALSYM SECPKG_ATTR_USE_VALIDATED}
  686. SECPKG_ATTR_CREDENTIAL_NAME = 16;
  687. {$EXTERNALSYM SECPKG_ATTR_CREDENTIAL_NAME}
  688. SECPKG_ATTR_TARGET_INFORMATION = 17;
  689. {$EXTERNALSYM SECPKG_ATTR_TARGET_INFORMATION}
  690. SECPKG_ATTR_ACCESS_TOKEN = 18;
  691. {$EXTERNALSYM SECPKG_ATTR_ACCESS_TOKEN}
  692. // These attributes exist only in Win2K3 and greater
  693. SECPKG_ATTR_TARGET = 19;
  694. {$EXTERNALSYM SECPKG_ATTR_TARGET}
  695. SECPKG_ATTR_AUTHENTICATION_ID = 20;
  696. {$EXTERNALSYM SECPKG_ATTR_AUTHENTICATION_ID}
  697. // These attributes exist only in Win2K3SP1 and greater
  698. SECPKG_ATTR_LOGOFF_TIME = 21;
  699. {$EXTERNALSYM SECPKG_ATTR_LOGOFF_TIME}
  700. //
  701. // win7 or greater
  702. //
  703. SECPKG_ATTR_NEGO_KEYS = 22;
  704. {$EXTERNALSYM SECPKG_ATTR_NEGO_KEYS}
  705. SECPKG_ATTR_PROMPTING_NEEDED = 24;
  706. {$EXTERNALSYM SECPKG_ATTR_PROMPTING_NEEDED}
  707. SECPKG_ATTR_UNIQUE_BINDINGS = 25;
  708. {$EXTERNALSYM SECPKG_ATTR_UNIQUE_BINDINGS}
  709. SECPKG_ATTR_ENDPOINT_BINDINGS = 26;
  710. {$EXTERNALSYM SECPKG_ATTR_ENDPOINT_BINDINGS}
  711. SECPKG_ATTR_CLIENT_SPECIFIED_TARGET = 27;
  712. {$EXTERNALSYM SECPKG_ATTR_CLIENT_SPECIFIED_TARGET}
  713. SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS = 30;
  714. {$EXTERNALSYM SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS}
  715. SECPKG_ATTR_NEGO_PKG_INFO = 31; // contains nego info of packages
  716. {$EXTERNALSYM SECPKG_ATTR_NEGO_PKG_INFO}
  717. SECPKG_ATTR_NEGO_STATUS = 32; // contains the last error
  718. {$EXTERNALSYM SECPKG_ATTR_NEGO_STATUS}
  719. SECPKG_ATTR_CONTEXT_DELETED = 33; // a context has been deleted
  720. {$EXTERNALSYM SECPKG_ATTR_CONTEXT_DELETED}
  721. SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES = 128;
  722. {$EXTERNALSYM SECPKG_ATTR_SUBJECT_SECURITY_ATTRIBUTES}
  723. type
  724. PSecPkgContext_SubjectAttributes = ^SecPkgContext_SubjectAttributes;
  725. {$EXTERNALSYM PSecPkgContext_SubjectAttributes}
  726. SecPkgContext_SubjectAttributes = record
  727. AttributeInfo: PVOID; // contains a PAUTHZ_SECURITY_ATTRIBUTES_INFORMATION structure
  728. end;
  729. {$EXTERNALSYM SecPkgContext_SubjectAttributes}
  730. const
  731. SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS = $1;
  732. {$EXTERNALSYM SECPKG_ATTR_NEGO_INFO_FLAG_NO_KERBEROS}
  733. SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM = $2;
  734. {$EXTERNALSYM SECPKG_ATTR_NEGO_INFO_FLAG_NO_NTLM}
  735. type
  736. //
  737. // types of credentials, used by SECPKG_ATTR_PROMPTING_NEEDED
  738. //
  739. PSECPKG_CRED_CLASS = ^SECPKG_CRED_CLASS;
  740. {$EXTERNALSYM PSECPKG_CRED_CLASS}
  741. SECPKG_CRED_CLASS = ULONG;
  742. {$EXTERNALSYM SECPKG_CRED_CLASS}
  743. const
  744. SecPkgCredClass_None = 0; // no creds
  745. {$EXTERNALSYM SecPkgCredClass_None}
  746. SecPkgCredClass_Ephemeral = 10; // logon creds
  747. {$EXTERNALSYM SecPkgCredClass_Ephemeral}
  748. SecPkgCredClass_PersistedGeneric = 20; // saved creds, not target specific
  749. {$EXTERNALSYM SecPkgCredClass_PersistedGeneric}
  750. SecPkgCredClass_PersistedSpecific = 30; // saved creds, target specific
  751. {$EXTERNALSYM SecPkgCredClass_PersistedSpecific}
  752. SecPkgCredClass_Explicit = 40; // explicitly supplied creds
  753. {$EXTERNALSYM SecPkgCredClass_Explicit}
  754. type
  755. PSecPkgContext_CredInfo = ^SecPkgContext_CredInfo;
  756. {$EXTERNALSYM PSecPkgContext_CredInfo}
  757. SecPkgContext_CredInfo = record
  758. CredClass: SECPKG_CRED_CLASS;
  759. IsPromptingNeeded: ULONG;
  760. end;
  761. {$EXTERNALSYM SecPkgContext_CredInfo}
  762. PSecPkgContext_NegoPackageInfo = ^SecPkgContext_NegoPackageInfo;
  763. {$EXTERNALSYM PSecPkgContext_NegoPackageInfo}
  764. SecPkgContext_NegoPackageInfo = record
  765. PackageMask: ULONG;
  766. end;
  767. {$EXTERNALSYM SecPkgContext_NegoPackageInfo}
  768. PSecPkgContext_NegoStatus = ^SecPkgContext_NegoStatus;
  769. {$EXTERNALSYM PSecPkgContext_NegoStatus}
  770. SecPkgContext_NegoStatus = record
  771. LastStatus: ULONG;
  772. end;
  773. {$EXTERNALSYM SecPkgContext_NegoStatus}
  774. PSecPkgContext_Sizes = ^SecPkgContext_Sizes;
  775. {$EXTERNALSYM PSecPkgContext_Sizes}
  776. SecPkgContext_Sizes = record
  777. cbMaxToken: ULONG;
  778. cbMaxSignature: ULONG;
  779. cbBlockSize: ULONG;
  780. cbSecurityTrailer: ULONG;
  781. end;
  782. {$EXTERNALSYM SecPkgContext_Sizes}
  783. PSecPkgContext_StreamSizes = ^SecPkgContext_StreamSizes;
  784. {$EXTERNALSYM PSecPkgContext_StreamSizes}
  785. SecPkgContext_StreamSizes = record
  786. cbHeader: ULONG;
  787. cbTrailer: ULONG;
  788. cbMaximumMessage: ULONG;
  789. cBuffers: ULONG;
  790. cbBlockSize: ULONG;
  791. end;
  792. {$EXTERNALSYM SecPkgContext_StreamSizes}
  793. PSecPkgContext_NamesW = ^SecPkgContext_NamesW;
  794. {$EXTERNALSYM PSecPkgContext_NamesW}
  795. SecPkgContext_NamesW = record
  796. sUserName: PSEC_WCHAR;
  797. end;
  798. {$EXTERNALSYM SecPkgContext_NamesW}
  799. PSECPKG_ATTR_LCT_STATUS = ^SECPKG_ATTR_LCT_STATUS;
  800. {$EXTERNALSYM PSECPKG_ATTR_LCT_STATUS}
  801. SECPKG_ATTR_LCT_STATUS = (
  802. SecPkgAttrLastClientTokenYes,
  803. SecPkgAttrLastClientTokenNo,
  804. SecPkgAttrLastClientTokenMaybe
  805. );
  806. {$EXTERNALSYM SECPKG_ATTR_LCT_STATUS}
  807. PSecPkgContext_LastClientTokenStatus = ^SecPkgContext_LastClientTokenStatus;
  808. {$EXTERNALSYM PSecPkgContext_LastClientTokenStatus}
  809. SecPkgContext_LastClientTokenStatus = record
  810. LastClientTokenStatus: SECPKG_ATTR_LCT_STATUS;
  811. end;
  812. {$EXTERNALSYM SecPkgContext_LastClientTokenStatus}
  813. PSecPkgContext_NamesA = ^SecPkgContext_NamesA;
  814. {$EXTERNALSYM PSecPkgContext_NamesA}
  815. SecPkgContext_NamesA = record
  816. sUserName: PSEC_CHAR;
  817. end;
  818. {$EXTERNALSYM SecPkgContext_NamesA}
  819. {$IFDEF SSPI_UNICODE}
  820. SecPkgContext_Names = SecPkgContext_NamesW;
  821. PSecPkgContext_Names = PSecPkgContext_NamesW;
  822. {$ELSE}
  823. SecPkgContext_Names = SecPkgContext_NamesA;
  824. PSecPkgContext_Names = PSecPkgContext_NamesA;
  825. {$ENDIF}
  826. {$EXTERNALSYM SecPkgContext_Names}
  827. {$EXTERNALSYM PSecPkgContext_Names}
  828. PSecPkgContext_Lifespan = ^SecPkgContext_Lifespan;
  829. {$EXTERNALSYM PSecPkgContext_Lifespan}
  830. SecPkgContext_Lifespan = record
  831. tsStart: TimeStamp;
  832. tsExpiry: TimeStamp;
  833. end;
  834. {$EXTERNALSYM SecPkgContext_Lifespan}
  835. PSecPkgContext_DceInfo = ^SecPkgContext_DceInfo;
  836. {$EXTERNALSYM PSecPkgContext_DceInfo}
  837. SecPkgContext_DceInfo = record
  838. AuthzSvc: ULONG;
  839. pPac: PVOID;
  840. end;
  841. {$EXTERNALSYM SecPkgContext_DceInfo}
  842. PSecPkgContext_KeyInfoA = ^SecPkgContext_KeyInfoA;
  843. {$EXTERNALSYM PSecPkgContext_KeyInfoA}
  844. SecPkgContext_KeyInfoA = record
  845. sSignatureAlgorithmName: PSEC_CHAR;
  846. sEncryptAlgorithmName: PSEC_CHAR;
  847. KeySize: ULONG;
  848. SignatureAlgorithm: ULONG;
  849. EncryptAlgorithm: ULONG;
  850. end;
  851. {$EXTERNALSYM SecPkgContext_KeyInfoA}
  852. PSecPkgContext_KeyInfoW = ^SecPkgContext_KeyInfoW;
  853. {$EXTERNALSYM PSecPkgContext_KeyInfoW}
  854. SecPkgContext_KeyInfoW = record
  855. sSignatureAlgorithmName: PSEC_WCHAR;
  856. sEncryptAlgorithmName: PSEC_WCHAR;
  857. KeySize: ULONG;
  858. SignatureAlgorithm: ULONG;
  859. EncryptAlgorithm: ULONG;
  860. end;
  861. {$EXTERNALSYM SecPkgContext_KeyInfoW}
  862. {$IFDEF SSPI_UNICODE}
  863. SecPkgContext_KeyInfo = SecPkgContext_KeyInfoW;
  864. PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoW;
  865. {$ELSE}
  866. SecPkgContext_KeyInfo = SecPkgContext_KeyInfoA;
  867. PSecPkgContext_KeyInfo = PSecPkgContext_KeyInfoA;
  868. {$ENDIF}
  869. {$EXTERNALSYM SecPkgContext_KeyInfo}
  870. {$EXTERNALSYM PSecPkgContext_KeyInfo}
  871. PSecPkgContext_AuthorityA = ^SecPkgContext_AuthorityA;
  872. {$EXTERNALSYM PSecPkgContext_AuthorityA}
  873. SecPkgContext_AuthorityA = record
  874. sAuthorityName: PSEC_CHAR;
  875. end;
  876. {$EXTERNALSYM SecPkgContext_AuthorityA}
  877. PSecPkgContext_AuthorityW = ^SecPkgContext_AuthorityW;
  878. {$EXTERNALSYM PSecPkgContext_AuthorityW}
  879. SecPkgContext_AuthorityW = record
  880. sAuthorityName: PSEC_WCHAR;
  881. end;
  882. {$EXTERNALSYM SecPkgContext_AuthorityW}
  883. {$IFDEF SSPI_UNICODE}
  884. SecPkgContext_Authority = SecPkgContext_AuthorityW;
  885. PSecPkgContext_Authority = PSecPkgContext_AuthorityW;
  886. {$ELSE}
  887. SecPkgContext_Authority = SecPkgContext_AuthorityA;
  888. PSecPkgContext_Authority = PSecPkgContext_AuthorityA;
  889. {$ENDIF}
  890. {$EXTERNALSYM SecPkgContext_Authority}
  891. {$EXTERNALSYM PSecPkgContext_Authority}
  892. PSecPkgContext_ProtoInfoA = ^SecPkgContext_ProtoInfoA;
  893. {$EXTERNALSYM PSecPkgContext_ProtoInfoA}
  894. SecPkgContext_ProtoInfoA = record
  895. sProtocolName: PSEC_CHAR;
  896. majorVersion: ULONG;
  897. minorVersion: ULONG;
  898. end;
  899. {$EXTERNALSYM SecPkgContext_ProtoInfoA}
  900. PSecPkgContext_ProtoInfoW = ^SecPkgContext_ProtoInfoW;
  901. {$EXTERNALSYM PSecPkgContext_ProtoInfoW}
  902. SecPkgContext_ProtoInfoW = record
  903. sProtocolName: PSEC_WCHAR;
  904. majorVersion: ULONG;
  905. minorVersion: ULONG;
  906. end;
  907. {$EXTERNALSYM SecPkgContext_ProtoInfoW}
  908. {$IFDEF SSPI_UNICODE}
  909. SecPkgContext_ProtoInfo = SecPkgContext_ProtoInfoW;
  910. PSecPkgContext_ProtoInfo = PSecPkgContext_ProtoInfoW;
  911. {$ELSE}
  912. SecPkgContext_ProtoInfo = SecPkgContext_ProtoInfoA;
  913. PSecPkgContext_ProtoInfo = PSecPkgContext_ProtoInfoA;
  914. {$ENDIF}
  915. {$EXTERNALSYM SecPkgContext_ProtoInfo}
  916. {$EXTERNALSYM PSecPkgContext_ProtoInfo}
  917. PSecPkgContext_PasswordExpiry = ^SecPkgContext_PasswordExpiry;
  918. {$EXTERNALSYM PSecPkgContext_PasswordExpiry}
  919. SecPkgContext_PasswordExpiry = record
  920. tsPasswordExpires: TimeStamp;
  921. end;
  922. {$EXTERNALSYM SecPkgContext_PasswordExpiry}
  923. PSecPkgContext_LogoffTime = ^SecPkgContext_LogoffTime;
  924. {$EXTERNALSYM PSecPkgContext_LogoffTime}
  925. SecPkgContext_LogoffTime = record
  926. tsLogoffTime: TimeStamp;
  927. end;
  928. {$EXTERNALSYM SecPkgContext_LogoffTime}
  929. PSecPkgContext_SessionKey = ^SecPkgContext_SessionKey;
  930. {$EXTERNALSYM PSecPkgContext_SessionKey}
  931. SecPkgContext_SessionKey = record
  932. SessionKeyLength: ULONG;
  933. SessionKey: PUCHAR;
  934. end;
  935. {$EXTERNALSYM SecPkgContext_SessionKey}
  936. // used by nego2
  937. PSecPkgContext_NegoKeys = ^SecPkgContext_NegoKeys;
  938. {$EXTERNALSYM PSecPkgContext_NegoKeys}
  939. SecPkgContext_NegoKeys = record
  940. KeyType: ULONG;
  941. KeyLength: USHORT;
  942. KeyValue: PUCHAR;
  943. VerifyKeyType: ULONG;
  944. VerifyKeyLength: USHORT;
  945. VerifyKeyValue: PUCHAR;
  946. end;
  947. {$EXTERNALSYM SecPkgContext_NegoKeys}
  948. PSecPkgContext_PackageInfoW = ^SecPkgContext_PackageInfoW;
  949. {$EXTERNALSYM PSecPkgContext_PackageInfoW}
  950. SecPkgContext_PackageInfoW = record
  951. PackageInfo: PSecPkgInfoW;
  952. end;
  953. {$EXTERNALSYM SecPkgContext_PackageInfoW}
  954. PSecPkgContext_PackageInfoA = ^SecPkgContext_PackageInfoA;
  955. {$EXTERNALSYM PSecPkgContext_PackageInfoA}
  956. SecPkgContext_PackageInfoA = record
  957. PackageInfo: PSecPkgInfoA;
  958. end;
  959. {$EXTERNALSYM SecPkgContext_PackageInfoA}
  960. PSecPkgContext_UserFlags = ^SecPkgContext_UserFlags;
  961. {$EXTERNALSYM PSecPkgContext_UserFlags}
  962. SecPkgContext_UserFlags = record
  963. UserFlags: ULONG;
  964. end;
  965. {$EXTERNALSYM SecPkgContext_UserFlags}
  966. PSecPkgContext_Flags = ^SecPkgContext_Flags;
  967. {$EXTERNALSYM PSecPkgContext_Flags}
  968. SecPkgContext_Flags = record
  969. Flags: ULONG;
  970. end;
  971. {$EXTERNALSYM SecPkgContext_Flags}
  972. {$IFDEF SSPI_UNICODE}
  973. SecPkgContext_PackageInfo = SecPkgContext_PackageInfoW;
  974. PSecPkgContext_PackageInfo = PSecPkgContext_PackageInfoW;
  975. {$ELSE}
  976. SecPkgContext_PackageInfo = SecPkgContext_PackageInfoA;
  977. PSecPkgContext_PackageInfo = PSecPkgContext_PackageInfoA;
  978. {$ENDIF}
  979. {$EXTERNALSYM SecPkgContext_PackageInfo}
  980. {$EXTERNALSYM PSecPkgContext_PackageInfo}
  981. PSecPkgContext_NegotiationInfoA = ^SecPkgContext_NegotiationInfoA;
  982. {$EXTERNALSYM PSecPkgContext_NegotiationInfoA}
  983. SecPkgContext_NegotiationInfoA = record
  984. PackageInfo: PSecPkgInfoA;
  985. NegotiationState: ULONG;
  986. end;
  987. {$EXTERNALSYM SecPkgContext_NegotiationInfoA}
  988. PSecPkgContext_NegotiationInfoW = ^SecPkgContext_NegotiationInfoW;
  989. {$EXTERNALSYM PSecPkgContext_NegotiationInfoW}
  990. SecPkgContext_NegotiationInfoW = record
  991. PackageInfo: PSecPkgInfoW;
  992. NegotiationState: ULONG;
  993. end;
  994. {$EXTERNALSYM SecPkgContext_NegotiationInfoW}
  995. {$IFDEF SSPI_UNICODE}
  996. SecPkgContext_NegotiationInfo = SecPkgContext_NegotiationInfoW;
  997. PSecPkgContext_NegotiationInfo = PSecPkgContext_NegotiationInfoW;
  998. {$ELSE}
  999. SecPkgContext_NegotiationInfo = SecPkgContext_NegotiationInfoA;
  1000. PSecPkgContext_NegotiationInfo = PSecPkgContext_NegotiationInfoA;
  1001. {$ENDIF}
  1002. {$EXTERNALSYM SecPkgContext_NegotiationInfo}
  1003. {$EXTERNALSYM PSecPkgContext_NegotiationInfo}
  1004. const
  1005. SECPKG_NEGOTIATION_COMPLETE = 0;
  1006. {$EXTERNALSYM SECPKG_NEGOTIATION_COMPLETE}
  1007. SECPKG_NEGOTIATION_OPTIMISTIC = 1;
  1008. {$EXTERNALSYM SECPKG_NEGOTIATION_OPTIMISTIC}
  1009. SECPKG_NEGOTIATION_IN_PROGRESS = 2;
  1010. {$EXTERNALSYM SECPKG_NEGOTIATION_IN_PROGRESS}
  1011. SECPKG_NEGOTIATION_DIRECT = 3;
  1012. {$EXTERNALSYM SECPKG_NEGOTIATION_DIRECT}
  1013. SECPKG_NEGOTIATION_TRY_MULTICRED = 4;
  1014. {$EXTERNALSYM SECPKG_NEGOTIATION_TRY_MULTICRED}
  1015. type
  1016. PSecPkgContext_NativeNamesW = ^SecPkgContext_NativeNamesW;
  1017. {$EXTERNALSYM PSecPkgContext_NativeNamesW}
  1018. SecPkgContext_NativeNamesW = record
  1019. sClientName: PSEC_WCHAR;
  1020. sServerName: PSEC_WCHAR;
  1021. end;
  1022. {$EXTERNALSYM SecPkgContext_NativeNamesW}
  1023. PSecPkgContext_NativeNamesA = ^SecPkgContext_NativeNamesA;
  1024. {$EXTERNALSYM PSecPkgContext_NativeNamesA}
  1025. SecPkgContext_NativeNamesA = record
  1026. sClientName: PSEC_CHAR;
  1027. sServerName: PSEC_CHAR;
  1028. end;
  1029. {$EXTERNALSYM SecPkgContext_NativeNamesA}
  1030. {$IFDEF SSPI_UNICODE}
  1031. SecPkgContext_NativeNames = SecPkgContext_NativeNamesW;
  1032. PSecPkgContext_NativeNames = PSecPkgContext_NativeNamesW;
  1033. {$ELSE}
  1034. SecPkgContext_NativeNames = SecPkgContext_NativeNamesA;
  1035. PSecPkgContext_NativeNames = PSecPkgContext_NativeNamesA;
  1036. {$ENDIF}
  1037. {$EXTERNALSYM SecPkgContext_NativeNames}
  1038. {$EXTERNALSYM PSecPkgContext_NativeNames}
  1039. PSecPkgContext_CredentialNameW = ^SecPkgContext_CredentialNameW;
  1040. {$EXTERNALSYM PSecPkgContext_CredentialNameW}
  1041. SecPkgContext_CredentialNameW = record
  1042. CredentialType: ULONG;
  1043. sCredentialName: PSEC_WCHAR;
  1044. end;
  1045. {$EXTERNALSYM SecPkgContext_CredentialNameW}
  1046. PSecPkgContext_CredentialNameA = ^SecPkgContext_CredentialNameA;
  1047. {$EXTERNALSYM PSecPkgContext_CredentialNameA}
  1048. SecPkgContext_CredentialNameA = record
  1049. CredentialType: ULONG;
  1050. sCredentialName: PSEC_CHAR;
  1051. end;
  1052. {$EXTERNALSYM SecPkgContext_CredentialNameA}
  1053. {$IFDEF SSPI_UNICODE}
  1054. SecPkgContext_CredentialName = SecPkgContext_CredentialNameW;
  1055. PSecPkgContext_CredentialName = PSecPkgContext_CredentialNameW;
  1056. {$ELSE}
  1057. SecPkgContext_CredentialName = SecPkgContext_CredentialNameA;
  1058. PSecPkgContext_CredentialName = PSecPkgContext_CredentialNameA;
  1059. {$ENDIF}
  1060. {$EXTERNALSYM SecPkgContext_CredentialName}
  1061. {$EXTERNALSYM PSecPkgContext_CredentialName}
  1062. PSecPkgContext_AccessToken = ^SecPkgContext_AccessToken;
  1063. {$EXTERNALSYM PSecPkgContext_AccessToken}
  1064. SecPkgContext_AccessToken = record
  1065. AccessToken: PVOID;
  1066. end;
  1067. {$EXTERNALSYM SecPkgContext_AccessToken}
  1068. PSecPkgContext_TargetInformation = ^SecPkgContext_TargetInformation;
  1069. {$EXTERNALSYM PSecPkgContext_TargetInformation}
  1070. SecPkgContext_TargetInformation = record
  1071. MarshalledTargetInfoLength: ULONG;
  1072. MarshalledTargetInfo: PUCHAR;
  1073. end;
  1074. {$EXTERNALSYM SecPkgContext_TargetInformation}
  1075. PSecPkgContext_AuthzID = ^SecPkgContext_AuthzID;
  1076. {$EXTERNALSYM PSecPkgContext_AuthzID}
  1077. SecPkgContext_AuthzID = record
  1078. AuthzIDLength: ULONG;
  1079. AuthzID: PAnsiChar;
  1080. end;
  1081. {$EXTERNALSYM SecPkgContext_AuthzID}
  1082. PSecPkgContext_Target = ^SecPkgContext_Target;
  1083. {$EXTERNALSYM PSecPkgContext_Target}
  1084. SecPkgContext_Target = record
  1085. TargetLength: ULONG;
  1086. Target: PAnsiChar;
  1087. end;
  1088. {$EXTERNALSYM SecPkgContext_Target}
  1089. PSecPkgContext_ClientSpecifiedTarget = ^SecPkgContext_ClientSpecifiedTarget;
  1090. {$EXTERNALSYM PSecPkgContext_ClientSpecifiedTarget}
  1091. SecPkgContext_ClientSpecifiedTarget = record
  1092. sTargetName: PSEC_WCHAR;
  1093. end;
  1094. {$EXTERNALSYM SecPkgContext_ClientSpecifiedTarget}
  1095. PSecPkgContext_Bindings = ^SecPkgContext_Bindings;
  1096. {$EXTERNALSYM PSecPkgContext_Bindings}
  1097. SecPkgContext_Bindings = record
  1098. BindingsLength: ULONG;
  1099. Bindings: PSEC_CHANNEL_BINDINGS;
  1100. end;
  1101. {$EXTERNALSYM SecPkgContext_Bindings}
  1102. SEC_GET_KEY_FN = procedure(
  1103. Arg: PVOID; // Argument passed in
  1104. Principal: PVOID; // Principal ID
  1105. KeyVer: ULONG; // Key Version
  1106. Key: PPVOID; // Returned ptr to key
  1107. Status: PSECURITY_STATUS // returned status
  1108. ); stdcall;
  1109. {$EXTERNALSYM SEC_GET_KEY_FN}
  1110. //
  1111. // Flags for ExportSecurityContext
  1112. //
  1113. const
  1114. SECPKG_CONTEXT_EXPORT_RESET_NEW = $00000001; // New context is reset to initial state
  1115. {$EXTERNALSYM SECPKG_CONTEXT_EXPORT_RESET_NEW}
  1116. SECPKG_CONTEXT_EXPORT_DELETE_OLD = $00000002; // Old context is deleted during export
  1117. {$EXTERNALSYM SECPKG_CONTEXT_EXPORT_DELETE_OLD}
  1118. // This is only valid in W2K3SP1 and greater
  1119. SECPKG_CONTEXT_EXPORT_TO_KERNEL = $00000004; // Context is to be transferred to the kernel
  1120. {$EXTERNALSYM SECPKG_CONTEXT_EXPORT_TO_KERNEL}
  1121. type
  1122. ACQUIRE_CREDENTIALS_HANDLE_FN_W = function( // AcquireCredentialsHandleW
  1123. pszPrincipal: PSEC_WCHAR; // Name of principal
  1124. pszPackage: PSEC_WCHAR; // Name of package
  1125. fCredentialUse: ULONG; // Flags indicating use
  1126. pvLogonId: PVOID; // Pointer to logon ID
  1127. pAuthData: PVOID; // Package specific data
  1128. pGetKeyFn: SEC_GET_KEY_FN; // Pointer to GetKey() func
  1129. pvGetKeyArgument: PVOID; // Value to pass to GetKey()
  1130. phCredential: PCredHandle; // (out) Cred Handle
  1131. ptsExpiry: PTimeStamp // (out) Lifetime (optional)
  1132. ): SECURITY_STATUS; stdcall;
  1133. {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN_W}
  1134. ACQUIRE_CREDENTIALS_HANDLE_FN_A = function( // AcquireCredentialsHandleW
  1135. pszPrincipal: PSEC_CHAR; // Name of principal
  1136. pszPackage: PSEC_CHAR; // Name of package
  1137. fCredentialUse: ULONG; // Flags indicating use
  1138. pvLogonId: PVOID; // Pointer to logon ID
  1139. pAuthData: PVOID; // Package specific data
  1140. pGetKeyFn: SEC_GET_KEY_FN; // Pointer to GetKey() func
  1141. pvGetKeyArgument: PVOID; // Value to pass to GetKey()
  1142. phCredential: PCredHandle; // (out) Cred Handle
  1143. ptsExpiry: PTimeStamp // (out) Lifetime (optional)
  1144. ): SECURITY_STATUS; stdcall;
  1145. {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN_A}
  1146. {$IFDEF SSPI_UNICODE}
  1147. ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_W;
  1148. {$ELSE}
  1149. ACQUIRE_CREDENTIALS_HANDLE_FN = ACQUIRE_CREDENTIALS_HANDLE_FN_A;
  1150. {$ENDIF}
  1151. {$EXTERNALSYM ACQUIRE_CREDENTIALS_HANDLE_FN}
  1152. FREE_CREDENTIALS_HANDLE_FN = function( // FreeCredentialsHandle
  1153. phCredential: PCredHandle // Handle to free
  1154. ): SECURITY_STATUS; stdcall;
  1155. {$EXTERNALSYM FREE_CREDENTIALS_HANDLE_FN}
  1156. ADD_CREDENTIALS_FN_W = function( // AddCredentialsW
  1157. hCredentials: PCredHandle;
  1158. pszPrincipal: PSEC_WCHAR; // Name of principal
  1159. pszPackage: PSEC_WCHAR; // Name of package
  1160. fCredentialUse: ULONG; // Flags indicating use
  1161. pAuthData: PVOID; // Package specific data
  1162. pGetKeyFn: SEC_GET_KEY_FN; // Pointer to GetKey() func
  1163. pvGetKeyArgument: PVOID; // Value to pass to GetKey()
  1164. ptsExpiry: PTimeStamp // (out) Lifetime (optional)
  1165. ): SECURITY_STATUS; stdcall;
  1166. {$EXTERNALSYM ADD_CREDENTIALS_FN_W}
  1167. ADD_CREDENTIALS_FN_A = function( // AddCredentialsA
  1168. hCredentials: PCredHandle;
  1169. pszPrincipal: PSEC_CHAR; // Name of principal
  1170. pszPackage: PSEC_CHAR; // Name of package
  1171. fCredentialUse: ULONG; // Flags indicating use
  1172. pAuthData: PVOID; // Package specific data
  1173. pGetKeyFn: SEC_GET_KEY_FN; // Pointer to GetKey() func
  1174. pvGetKeyArgument: PVOID; // Value to pass to GetKey()
  1175. ptsExpiry: PTimeStamp // (out) Lifetime (optional)
  1176. ): SECURITY_STATUS; stdcall;
  1177. {$EXTERNALSYM ADD_CREDENTIALS_FN_A}
  1178. {$IFDEF SSPI_UNICODE}
  1179. ADD_CREDENTIALS_FN = ADD_CREDENTIALS_FN_W;
  1180. {$ELSE}
  1181. ADD_CREDENTIALS_FN = ADD_CREDENTIALS_FN_A;
  1182. {$ENDIF}
  1183. {$EXTERNALSYM ADD_CREDENTIALS_FN}
  1184. (*
  1185. #ifdef WIN32_CHICAGO
  1186. SECURITY_STATUS SEC_ENTRY
  1187. SspiLogonUserW(
  1188. SEC_WCHAR SEC_FAR * pszPackage, // Name of package
  1189. SEC_WCHAR SEC_FAR * pszUserName, // Name of package
  1190. SEC_WCHAR SEC_FAR * pszDomainName, // Name of package
  1191. SEC_WCHAR SEC_FAR * pszPassword // Name of package
  1192. );
  1193. typedef SECURITY_STATUS
  1194. (SEC_ENTRY * SSPI_LOGON_USER_FN_W)(
  1195. SEC_CHAR SEC_FAR *,
  1196. SEC_CHAR SEC_FAR *,
  1197. SEC_CHAR SEC_FAR *,
  1198. SEC_CHAR SEC_FAR * );
  1199. SECURITY_STATUS SEC_ENTRY
  1200. SspiLogonUserA(
  1201. SEC_CHAR SEC_FAR * pszPackage, // Name of package
  1202. SEC_CHAR SEC_FAR * pszUserName, // Name of package
  1203. SEC_CHAR SEC_FAR * pszDomainName, // Name of package
  1204. SEC_CHAR SEC_FAR * pszPassword // Name of package
  1205. );
  1206. typedef SECURITY_STATUS
  1207. (SEC_ENTRY * SSPI_LOGON_USER_FN_A)(
  1208. SEC_CHAR SEC_FAR *,
  1209. SEC_CHAR SEC_FAR *,
  1210. SEC_CHAR SEC_FAR *,
  1211. SEC_CHAR SEC_FAR * );
  1212. #ifdef UNICODE
  1213. #define SspiLogonUser SspiLogonUserW // ntifs
  1214. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_W
  1215. #else
  1216. #define SspiLogonUser SspiLogonUserA
  1217. #define SSPI_LOGON_USER_FN SSPI_LOGON_USER_FN_A
  1218. #endif // !UNICODE
  1219. #endif // WIN32_CHICAGO
  1220. *)
  1221. ////////////////////////////////////////////////////////////////////////
  1222. ///
  1223. /// Password Change Functions
  1224. ///
  1225. ////////////////////////////////////////////////////////////////////////
  1226. CHANGE_PASSWORD_FN_W = function( // ChangeAccountPasswordW
  1227. pszPackageName: PSEC_WCHAR;
  1228. pszDomainName: PSEC_WCHAR;
  1229. pszAccountName: PSEC_WCHAR;
  1230. pszOldPassword: PSEC_WCHAR;
  1231. pszNewPassword: PSEC_WCHAR;
  1232. bImpersonating: BOOLEAN;
  1233. dwReserved: ULONG;
  1234. pOutput: PSecBufferDesc
  1235. ): SECURITY_STATUS; stdcall;
  1236. {$EXTERNALSYM CHANGE_PASSWORD_FN_W}
  1237. CHANGE_PASSWORD_FN_A = function( // ChangeAccountPasswordA
  1238. pszPackageName: PSEC_CHAR;
  1239. pszDomainName: PSEC_CHAR;
  1240. pszAccountName: PSEC_CHAR;
  1241. pszOldPassword: PSEC_CHAR;
  1242. pszNewPassword: PSEC_CHAR;
  1243. bImpersonating: BOOLEAN;
  1244. dwReserved: ULONG;
  1245. pOutput: PSecBufferDesc
  1246. ): SECURITY_STATUS; stdcall;
  1247. {$EXTERNALSYM CHANGE_PASSWORD_FN_A}
  1248. {$IFDEF SSPI_UNICODE}
  1249. CHANGE_PASSWORD_FN = CHANGE_PASSWORD_FN_W;
  1250. {$ELSE}
  1251. CHANGE_PASSWORD_FN = CHANGE_PASSWORD_FN_A;
  1252. {$ENDIF}
  1253. {$EXTERNALSYM CHANGE_PASSWORD_FN}
  1254. ////////////////////////////////////////////////////////////////////////
  1255. ///
  1256. /// Context Management Functions
  1257. ///
  1258. ////////////////////////////////////////////////////////////////////////
  1259. INITIALIZE_SECURITY_CONTEXT_FN_W = function( // InitializeSecurityContextW
  1260. phCredential: PCredHandle; // Cred to base context
  1261. phContext: PCtxtHandle; // Existing context (OPT)
  1262. pszTargetName: PSEC_WCHAR; // Name of target
  1263. fContextReq: ULONG; // Context Requirements
  1264. Reserved1: ULONG; // Reserved, MBZ
  1265. TargetDataRep: ULONG; // Data rep of target
  1266. pInput: PSecBufferDesc; // Input Buffers
  1267. Reserved2: ULONG; // Reserved, MBZ
  1268. phNewContext: PCtxtHandle; // (out) New Context handle
  1269. pOutput: PSecBufferDesc; // (inout) Output Buffers
  1270. pfContextAttr: PULONG; // (out) Context attrs
  1271. ptsExpiry: PTimeStamp // (out) Life span (OPT)
  1272. ): SECURITY_STATUS; stdcall;
  1273. {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN_W}
  1274. INITIALIZE_SECURITY_CONTEXT_FN_A = function( // InitializeSecurityContextA
  1275. phCredential: PCredHandle; // Cred to base context
  1276. phContext: PCtxtHandle; // Existing context (OPT)
  1277. pszTargetName: PSEC_CHAR; // Name of target
  1278. fContextReq: ULONG; // Context Requirements
  1279. Reserved1: ULONG; // Reserved, MBZ
  1280. TargetDataRep: ULONG; // Data rep of target
  1281. pInput: PSecBufferDesc; // Input Buffers
  1282. Reserved2: ULONG; // Reserved, MBZ
  1283. phNewContext: PCtxtHandle; // (out) New Context handle
  1284. pOutput: PSecBufferDesc; // (inout) Output Buffers
  1285. pfContextAttr: PULONG; // (out) Context attrs
  1286. ptsExpiry: PTimeStamp // (out) Life span (OPT)
  1287. ): SECURITY_STATUS; stdcall;
  1288. {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN_A}
  1289. {$IFDEF SSPI_UNICODE}
  1290. INITIALIZE_SECURITY_CONTEXT_FN = INITIALIZE_SECURITY_CONTEXT_FN_W;
  1291. {$ELSE}
  1292. INITIALIZE_SECURITY_CONTEXT_FN = INITIALIZE_SECURITY_CONTEXT_FN_A;
  1293. {$ENDIF}
  1294. {$EXTERNALSYM INITIALIZE_SECURITY_CONTEXT_FN}
  1295. ACCEPT_SECURITY_CONTEXT_FN = function( // AcceptSecurityContext
  1296. phCredential: PCredHandle; // Cred to base context
  1297. phContext: PCtxtHandle; // Existing context (OPT)
  1298. pInput: PSecBufferDesc; // Input buffer
  1299. fContextReq: ULONG; // Context Requirements
  1300. TargetDataRep: ULONG; // Target Data Rep
  1301. phNewContext: PCtxtHandle; // (out) New context handle
  1302. pOutput: PSecBufferDesc; // (inout) Output buffers
  1303. pfContextAttr: PULONG; // (out) Context attributes
  1304. ptsExpiry: PTimeStamp // (out) Life span (OPT)
  1305. ): SECURITY_STATUS; stdcall;
  1306. {$EXTERNALSYM ACCEPT_SECURITY_CONTEXT_FN}
  1307. COMPLETE_AUTH_TOKEN_FN = function( // CompleteAuthToken
  1308. phContext: PCtxtHandle; // Context to complete
  1309. pToken: PSecBufferDesc // Token to complete
  1310. ): SECURITY_STATUS; stdcall;
  1311. {$EXTERNALSYM COMPLETE_AUTH_TOKEN_FN}
  1312. IMPERSONATE_SECURITY_CONTEXT_FN = function( // ImpersonateSecurityContext
  1313. phContext: PCtxtHandle
  1314. ): SECURITY_STATUS; stdcall;
  1315. {$EXTERNALSYM IMPERSONATE_SECURITY_CONTEXT_FN}
  1316. REVERT_SECURITY_CONTEXT_FN = function( // RevertSecurityContext
  1317. phContext: PCtxtHandle
  1318. ): SECURITY_STATUS; stdcall;
  1319. {$EXTERNALSYM REVERT_SECURITY_CONTEXT_FN}
  1320. QUERY_SECURITY_CONTEXT_TOKEN_FN = function( // QuerySecurityContextToken
  1321. phContext: PCtxtHandle;
  1322. Token: PPVOID
  1323. ): SECURITY_STATUS; stdcall;
  1324. {$EXTERNALSYM QUERY_SECURITY_CONTEXT_TOKEN_FN}
  1325. DELETE_SECURITY_CONTEXT_FN = function( // DeleteSecurityContext
  1326. phContext: PCtxtHandle
  1327. ): SECURITY_STATUS; stdcall;
  1328. {$EXTERNALSYM DELETE_SECURITY_CONTEXT_FN}
  1329. APPLY_CONTROL_TOKEN_FN = function( // ApplyControlToken
  1330. phContext: PCtxtHandle; // Context to modify
  1331. pInput: PSecBufferDesc // Input token to apply
  1332. ): SECURITY_STATUS; stdcall;
  1333. {$EXTERNALSYM APPLY_CONTROL_TOKEN_FN}
  1334. QUERY_CONTEXT_ATTRIBUTES_FN_W = function( // QueryContextAttributesW
  1335. phContext: PCtxtHandle; // Context to query
  1336. ulAttribute: ULONG; // Attribute to query
  1337. pBuffer: PVOID // Buffer for attributes
  1338. ): SECURITY_STATUS; stdcall;
  1339. {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN_W}
  1340. QUERY_CONTEXT_ATTRIBUTES_FN_A = function( // QueryContextAttributesA
  1341. phContext: PCtxtHandle; // Context to query
  1342. ulAttribute: ULONG; // Attribute to query
  1343. pBuffer: PVOID // Buffer for attributes
  1344. ): SECURITY_STATUS; stdcall;
  1345. {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN_A}
  1346. {$IFDEF SSPI_UNICODE}
  1347. QUERY_CONTEXT_ATTRIBUTES_FN = QUERY_CONTEXT_ATTRIBUTES_FN_W;
  1348. {$ELSE}
  1349. QUERY_CONTEXT_ATTRIBUTES_FN = QUERY_CONTEXT_ATTRIBUTES_FN_A;
  1350. {$ENDIF}
  1351. {$EXTERNALSYM QUERY_CONTEXT_ATTRIBUTES_FN}
  1352. SET_CONTEXT_ATTRIBUTES_FN_W = function( // SetContextAttributesW
  1353. phContext: PCtxtHandle; // Context to Set
  1354. ulAttribute: ULONG; // Attribute to Set
  1355. pBuffer: PVOID; // Buffer for attributes
  1356. cbBuffer: ULONG // Size (in bytes) of Buffer
  1357. ): SECURITY_STATUS; stdcall;
  1358. {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN_W}
  1359. SET_CONTEXT_ATTRIBUTES_FN_A = function( // SetContextAttributesA
  1360. phContext: PCtxtHandle; // Context to Set
  1361. ulAttribute: ULONG; // Attribute to Set
  1362. pBuffer: PVOID; // Buffer for attributes
  1363. cbBuffer: ULONG // Size (in bytes) of Buffer
  1364. ): SECURITY_STATUS; stdcall;
  1365. {$EXTERNALSYM SET_CONTEXT_ATTRIBUTES_FN_A}
  1366. QUERY_CREDENTIALS_ATTRIBUTES_FN_W = function( // QueryCredentialsAttributesW
  1367. phCredential: PCredHandle; // Credential to query
  1368. ulAttribute: ULONG; // Attribute to query
  1369. pBuffer: PVOID // Buffer for attributes
  1370. ): SECURITY_STATUS; stdcall;
  1371. {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN_W}
  1372. QUERY_CREDENTIALS_ATTRIBUTES_FN_A = function( // QueryCredentialsAttributesA
  1373. phCredential: PCredHandle; // Credential to query
  1374. ulAttribute: ULONG; // Attribute to query
  1375. pBuffer: PVOID // Buffer for attributes
  1376. ): SECURITY_STATUS; stdcall;
  1377. {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN_A}
  1378. {$IFDEF SSPI_UNICODE}
  1379. QUERY_CREDENTIALS_ATTRIBUTES_FN = QUERY_CREDENTIALS_ATTRIBUTES_FN_W;
  1380. {$ELSE}
  1381. QUERY_CREDENTIALS_ATTRIBUTES_FN = QUERY_CREDENTIALS_ATTRIBUTES_FN_A;
  1382. {$ENDIF}
  1383. {$EXTERNALSYM QUERY_CREDENTIALS_ATTRIBUTES_FN}
  1384. SET_CREDENTIALS_ATTRIBUTES_FN_W = function( // SetCredentialsAttributesW
  1385. phCredential: PCredHandle; // Credential to Set
  1386. ulAttribute: ULONG; // Attribute to Set
  1387. pBuffer: PVOID; // Buffer for attributes
  1388. cbBuffer: ULONG // Size (in bytes) of Buffer
  1389. ): SECURITY_STATUS; stdcall;
  1390. {$EXTERNALSYM SET_CREDENTIALS_ATTRIBUTES_FN_W}
  1391. SET_CREDENTIALS_ATTRIBUTES_FN_A = function( // SetCredentialsAttributesA
  1392. phCredential: PCredHandle; // Credential to Set
  1393. ulAttribute: ULONG; // Attribute to Set
  1394. pBuffer: PVOID; // Buffer for attributes
  1395. cbBuffer: ULONG // Size (in bytes) of Buffer
  1396. ): SECURITY_STATUS; stdcall;
  1397. {$EXTERNALSYM SET_CREDENTIALS_ATTRIBUTES_FN_A}
  1398. FREE_CONTEXT_BUFFER_FN = function( // FreeContextBuffer
  1399. pvContextBuffer: PVOID // buffer to free
  1400. ): SECURITY_STATUS; stdcall;
  1401. {$EXTERNALSYM FREE_CONTEXT_BUFFER_FN}
  1402. ///////////////////////////////////////////////////////////////////
  1403. ////
  1404. //// Message Support API
  1405. ////
  1406. //////////////////////////////////////////////////////////////////
  1407. type
  1408. MAKE_SIGNATURE_FN = function( // MakeSignature
  1409. phContext: PCtxtHandle; // Context to use
  1410. fQOP: ULONG; // Quality of Protection
  1411. pMessage: PSecBufferDesc; // Message to sign
  1412. MessageSeqNo: ULONG // Message Sequence Num.
  1413. ): SECURITY_STATUS; stdcall;
  1414. {$EXTERNALSYM MAKE_SIGNATURE_FN}
  1415. VERIFY_SIGNATURE_FN = function( // VerifySignature
  1416. phContext: PCtxtHandle; // Context to use
  1417. pMessage: PSecBufferDesc; // Message to verify
  1418. MessageSeqNo: ULONG; // Sequence Num.
  1419. pfQOP: PULONG // QOP used
  1420. ): SECURITY_STATUS; stdcall;
  1421. {$EXTERNALSYM VERIFY_SIGNATURE_FN}
  1422. ENCRYPT_MESSAGE_FN = function( // EncryptMessage
  1423. phContext: PCtxtHandle;
  1424. fQOP: ULONG;
  1425. pMessage: PSecBufferDesc;
  1426. MessageSeqNo: ULONG
  1427. ): SECURITY_STATUS; stdcall;
  1428. {$EXTERNALSYM ENCRYPT_MESSAGE_FN}
  1429. DECRYPT_MESSAGE_FN = function( // DecryptMessage
  1430. phContext: PCtxtHandle;
  1431. pMessage: PSecBufferDesc;
  1432. MessageSeqNo: ULONG;
  1433. pfQOP: PULONG
  1434. ): SECURITY_STATUS; stdcall;
  1435. {$EXTERNALSYM DECRYPT_MESSAGE_FN}
  1436. ///////////////////////////////////////////////////////////////////////////
  1437. ////
  1438. //// Misc.
  1439. ////
  1440. ///////////////////////////////////////////////////////////////////////////
  1441. type
  1442. ENUMERATE_SECURITY_PACKAGES_FN_W = function( // EnumerateSecurityPackagesW
  1443. pcPackages: PULONG; // Receives num. packages
  1444. ppPackageInfo: PPSecPkgInfoW // Receives array of info
  1445. ): SECURITY_STATUS; stdcall;
  1446. {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN_W}
  1447. ENUMERATE_SECURITY_PACKAGES_FN_A = function( // EnumerateSecurityPackagesA
  1448. pcPackages: PULONG; // Receives num. packages
  1449. ppPackageInfo: PPSecPkgInfoA // Receives array of info
  1450. ): SECURITY_STATUS; stdcall;
  1451. {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN_A}
  1452. {$IFDEF SSPI_UNICODE}
  1453. ENUMERATE_SECURITY_PACKAGES_FN = ENUMERATE_SECURITY_PACKAGES_FN_W;
  1454. {$ELSE}
  1455. ENUMERATE_SECURITY_PACKAGES_FN = ENUMERATE_SECURITY_PACKAGES_FN_A;
  1456. {$ENDIF}
  1457. {$EXTERNALSYM ENUMERATE_SECURITY_PACKAGES_FN}
  1458. QUERY_SECURITY_PACKAGE_INFO_FN_W = function( // QuerySecurityPackageInfoW
  1459. pszPackageName: PSEC_WCHAR; // Name of package
  1460. ppPackageInfo: PPSecPkgInfoW // Receives package info
  1461. ): SECURITY_STATUS; stdcall;
  1462. {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN_W}
  1463. QUERY_SECURITY_PACKAGE_INFO_FN_A = function( // QuerySecurityPackageInfoA
  1464. pszPackageName: PSEC_CHAR; // Name of package
  1465. ppPackageInfo: PPSecPkgInfoA // Receives package info
  1466. ): SECURITY_STATUS; stdcall;
  1467. {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN_A}
  1468. {$IFDEF SSPI_UNICODE}
  1469. QUERY_SECURITY_PACKAGE_INFO_FN = QUERY_SECURITY_PACKAGE_INFO_FN_W;
  1470. {$ELSE}
  1471. QUERY_SECURITY_PACKAGE_INFO_FN = QUERY_SECURITY_PACKAGE_INFO_FN_A;
  1472. {$ENDIF}
  1473. {$EXTERNALSYM QUERY_SECURITY_PACKAGE_INFO_FN}
  1474. PSecDelegationType = ^SecDelegationType;
  1475. {$EXTERNALSYM PSecDelegationType}
  1476. SecDelegationType = (
  1477. SecFull,
  1478. SecService,
  1479. SecTree,
  1480. SecDirectory,
  1481. SecObject
  1482. );
  1483. {$EXTERNALSYM SecDelegationType}
  1484. DELEGATE_SECURITY_CONTEXT_FN = function( // DelegateSecurityContext
  1485. phContext: PCtxtHandle; // IN Active context to delegate
  1486. pszTarget: PSEC_CHAR;
  1487. DelegationType: SecDelegationType; // IN Type of delegation
  1488. pExpiry: PTimeStamp; // IN OPTIONAL time limit
  1489. pPackageParameters: PSecBuffer; // IN OPTIONAL package specific
  1490. pOutput: PSecBufferDesc // OUT Token for applycontroltoken.
  1491. ): SECURITY_STATUS; stdcall;
  1492. {$EXTERNALSYM DELEGATE_SECURITY_CONTEXT_FN}
  1493. ///////////////////////////////////////////////////////////////////////////
  1494. ////
  1495. //// Proxies
  1496. ////
  1497. ///////////////////////////////////////////////////////////////////////////
  1498. //
  1499. // Proxies are only available on NT platforms
  1500. //
  1501. ///////////////////////////////////////////////////////////////////////////
  1502. ////
  1503. //// Context export/import
  1504. ////
  1505. ///////////////////////////////////////////////////////////////////////////
  1506. type
  1507. EXPORT_SECURITY_CONTEXT_FN = function( // ExportSecurityContext
  1508. phContext: PCtxtHandle; // (in) context to export
  1509. fFlags: ULONG; // (in) option flags
  1510. pPackedContext: PSecBuffer; // (out) marshalled context
  1511. pToken: PPVOID // (out, optional) token handle for impersonation
  1512. ): SECURITY_STATUS; stdcall;
  1513. {$EXTERNALSYM EXPORT_SECURITY_CONTEXT_FN}
  1514. IMPORT_SECURITY_CONTEXT_FN_W = function( // ImportSecurityContextW
  1515. pszPackage: PSEC_WCHAR;
  1516. pPackedContext: PSecBuffer; // (in) marshalled context
  1517. Token: PVOID; // (in, optional) handle to token for context
  1518. phContext: PCtxtHandle // (out) new context handle
  1519. ): SECURITY_STATUS; stdcall;
  1520. {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN_W}
  1521. IMPORT_SECURITY_CONTEXT_FN_A = function( // ImportSecurityContextA
  1522. pszPackage: PSEC_CHAR;
  1523. pPackedContext: PSecBuffer; // (in) marshalled context
  1524. Token: PVOID; // (in, optional) handle to token for context
  1525. phContext: PCtxtHandle // (out) new context handle
  1526. ): SECURITY_STATUS; stdcall;
  1527. {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN_A}
  1528. {$IFDEF SSPI_UNICODE}
  1529. IMPORT_SECURITY_CONTEXT_FN = IMPORT_SECURITY_CONTEXT_FN_W;
  1530. {$ELSE}
  1531. IMPORT_SECURITY_CONTEXT_FN = IMPORT_SECURITY_CONTEXT_FN_A;
  1532. {$ENDIF}
  1533. {$EXTERNALSYM IMPORT_SECURITY_CONTEXT_FN}
  1534. ///////////////////////////////////////////////////////////////////////////////
  1535. ////
  1536. //// Fast access for RPC:
  1537. ////
  1538. ///////////////////////////////////////////////////////////////////////////////
  1539. const
  1540. SECURITY_ENTRYPOINT_ANSIW = 'InitSecurityInterfaceW'; {Do not Localize}
  1541. {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSIW}
  1542. SECURITY_ENTRYPOINT_ANSIA = 'InitSecurityInterfaceA'; {Do not Localize}
  1543. {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSIA}
  1544. SECURITY_ENTRYPOINTW = 'InitSecurityInterfaceW'; {Do not Localize}
  1545. {$EXTERNALSYM SECURITY_ENTRYPOINTW}
  1546. SECURITY_ENTRYPOINTA = 'InitSecurityInterfaceA'; {Do not Localize}
  1547. {$EXTERNALSYM SECURITY_ENTRYPOINTA}
  1548. SECURITY_ENTRYPOINT16 = 'INITSECURITYINTERFACEA'; {Do not Localize}
  1549. {$EXTERNALSYM SECURITY_ENTRYPOINT16}
  1550. {$IFDEF SSPI_UNICODE}
  1551. SECURITY_ENTRYPOINT = SECURITY_ENTRYPOINTW;
  1552. SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINTW;
  1553. {$ELSE}
  1554. SECURITY_ENTRYPOINT = SECURITY_ENTRYPOINTA;
  1555. SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINTA;
  1556. {$ENDIF}
  1557. {$EXTERNALSYM SECURITY_ENTRYPOINT}
  1558. {$EXTERNALSYM SECURITY_ENTRYPOINT_ANSI}
  1559. type
  1560. PSecurityFunctionTableW = ^SecurityFunctionTableW;
  1561. {$EXTERNALSYM PSecurityFunctionTableW}
  1562. SecurityFunctionTableW = record
  1563. dwVersion: ULONG;
  1564. EnumerateSecurityPackagesW: ENUMERATE_SECURITY_PACKAGES_FN_W;
  1565. QueryCredentialsAttributesW: QUERY_CREDENTIALS_ATTRIBUTES_FN_W;
  1566. AcquireCredentialsHandleW: ACQUIRE_CREDENTIALS_HANDLE_FN_W;
  1567. FreeCredentialsHandle: FREE_CREDENTIALS_HANDLE_FN;
  1568. Reserved2: PVOID;
  1569. InitializeSecurityContextW: INITIALIZE_SECURITY_CONTEXT_FN_W;
  1570. AcceptSecurityContext: ACCEPT_SECURITY_CONTEXT_FN;
  1571. CompleteAuthToken: COMPLETE_AUTH_TOKEN_FN;
  1572. DeleteSecurityContext: DELETE_SECURITY_CONTEXT_FN;
  1573. ApplyControlToken: APPLY_CONTROL_TOKEN_FN;
  1574. QueryContextAttributesW: QUERY_CONTEXT_ATTRIBUTES_FN_W;
  1575. ImpersonateSecurityContext: IMPERSONATE_SECURITY_CONTEXT_FN;
  1576. RevertSecurityContext: REVERT_SECURITY_CONTEXT_FN;
  1577. MakeSignature: MAKE_SIGNATURE_FN;
  1578. VerifySignature: VERIFY_SIGNATURE_FN;
  1579. FreeContextBuffer: FREE_CONTEXT_BUFFER_FN;
  1580. QuerySecurityPackageInfoW: QUERY_SECURITY_PACKAGE_INFO_FN_W;
  1581. Reserved3: PVOID;
  1582. Reserved4: PVOID;
  1583. ExportSecurityContext: EXPORT_SECURITY_CONTEXT_FN;
  1584. ImportSecurityContextW: IMPORT_SECURITY_CONTEXT_FN_W;
  1585. AddCredentialsW: ADD_CREDENTIALS_FN_W;
  1586. Reserved8: PVOID;
  1587. QuerySecurityContextToken: QUERY_SECURITY_CONTEXT_TOKEN_FN;
  1588. EncryptMessage: ENCRYPT_MESSAGE_FN;
  1589. DecryptMessage: DECRYPT_MESSAGE_FN;
  1590. // Fields below this are available in OSes after w2k
  1591. SetContextAttributesW: SET_CONTEXT_ATTRIBUTES_FN_W;
  1592. // Fields below this are available in OSes after W2k3SP1
  1593. SetCredentialsAttributesW: SET_CREDENTIALS_ATTRIBUTES_FN_W;
  1594. ChangeAccountPasswordW: CHANGE_PASSWORD_FN_W;
  1595. end;
  1596. {$EXTERNALSYM SecurityFunctionTableW}
  1597. PSecurityFunctionTableA = ^SecurityFunctionTableA;
  1598. {$EXTERNALSYM PSecurityFunctionTableA}
  1599. SecurityFunctionTableA = record
  1600. dwVersion: ULONG;
  1601. EnumerateSecurityPackagesA: ENUMERATE_SECURITY_PACKAGES_FN_A;
  1602. QueryCredentialsAttributesA: QUERY_CREDENTIALS_ATTRIBUTES_FN_A;
  1603. AcquireCredentialsHandleA: ACQUIRE_CREDENTIALS_HANDLE_FN_A;
  1604. FreeCredentialsHandle: FREE_CREDENTIALS_HANDLE_FN;
  1605. Reserved2: PVOID;
  1606. InitializeSecurityContextA: INITIALIZE_SECURITY_CONTEXT_FN_A;
  1607. AcceptSecurityContext: ACCEPT_SECURITY_CONTEXT_FN;
  1608. CompleteAuthToken: COMPLETE_AUTH_TOKEN_FN;
  1609. DeleteSecurityContext: DELETE_SECURITY_CONTEXT_FN;
  1610. ApplyControlToken: APPLY_CONTROL_TOKEN_FN;
  1611. QueryContextAttributesA: QUERY_CONTEXT_ATTRIBUTES_FN_A;
  1612. ImpersonateSecurityContext: IMPERSONATE_SECURITY_CONTEXT_FN;
  1613. RevertSecurityContext: REVERT_SECURITY_CONTEXT_FN;
  1614. MakeSignature: MAKE_SIGNATURE_FN;
  1615. VerifySignature: VERIFY_SIGNATURE_FN;
  1616. FreeContextBuffer: FREE_CONTEXT_BUFFER_FN;
  1617. QuerySecurityPackageInfoA: QUERY_SECURITY_PACKAGE_INFO_FN_A;
  1618. Reserved3: PVOID;
  1619. Reserved4: PVOID;
  1620. ExportSecurityContext: EXPORT_SECURITY_CONTEXT_FN;
  1621. ImportSecurityContextA: IMPORT_SECURITY_CONTEXT_FN_A;
  1622. AddCredentialsA: ADD_CREDENTIALS_FN_A;
  1623. Reserved8: PVOID;
  1624. QuerySecurityContextToken: QUERY_SECURITY_CONTEXT_TOKEN_FN;
  1625. EncryptMessage: ENCRYPT_MESSAGE_FN;
  1626. DecryptMessage: DECRYPT_MESSAGE_FN;
  1627. SetContextAttributesA: SET_CONTEXT_ATTRIBUTES_FN_A;
  1628. SetCredentialsAttributesA: SET_CREDENTIALS_ATTRIBUTES_FN_A;
  1629. ChangeAccountPasswordA: CHANGE_PASSWORD_FN_A;
  1630. end;
  1631. {$EXTERNALSYM SecurityFunctionTableA}
  1632. {$IFDEF SSPI_UNICODE}
  1633. SecurityFunctionTable = SecurityFunctionTableW;
  1634. PSecurityFunctionTable = PSecurityFunctionTableW;
  1635. {$ELSE}
  1636. SecurityFunctionTable = SecurityFunctionTableA;
  1637. PSecurityFunctionTable = PSecurityFunctionTableA;
  1638. {$ENDIF}
  1639. {$EXTERNALSYM SecurityFunctionTable}
  1640. {$EXTERNALSYM PSecurityFunctionTable}
  1641. const
  1642. // Function table has all routines through DecryptMessage
  1643. SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION = 1;
  1644. {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION}
  1645. // Function table has all routines through SetContextAttributes
  1646. SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 = 2;
  1647. {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2}
  1648. // Function table has all routines through SetCredentialsAttributes
  1649. SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3 = 3;
  1650. {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3}
  1651. // Function table has all routines through ChangeAccountPassword
  1652. SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_4 = 4;
  1653. {$EXTERNALSYM SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_4}
  1654. type
  1655. INIT_SECURITY_INTERFACE_A = function // InitSecurityInterfaceA
  1656. : PSecurityFunctionTableA; stdcall;
  1657. {$EXTERNALSYM INIT_SECURITY_INTERFACE_A}
  1658. INIT_SECURITY_INTERFACE_W = function // InitSecurityInterfaceW
  1659. : PSecurityFunctionTableW; stdcall;
  1660. {$EXTERNALSYM INIT_SECURITY_INTERFACE_W}
  1661. {$IFDEF SSPI_UNICODE}
  1662. INIT_SECURITY_INTERFACE = INIT_SECURITY_INTERFACE_W;
  1663. {$ELSE}
  1664. INIT_SECURITY_INTERFACE = INIT_SECURITY_INTERFACE_A;
  1665. {$ENDIF}
  1666. {$EXTERNALSYM INIT_SECURITY_INTERFACE}
  1667. (* TODO
  1668. //
  1669. // SASL Profile Support
  1670. //
  1671. SECURITY_STATUS
  1672. SEC_ENTRY
  1673. SaslEnumerateProfilesA(
  1674. OUT LPSTR * ProfileList,
  1675. OUT ULONG * ProfileCount
  1676. );
  1677. SECURITY_STATUS
  1678. SEC_ENTRY
  1679. SaslEnumerateProfilesW(
  1680. OUT LPWSTR * ProfileList,
  1681. OUT ULONG * ProfileCount
  1682. );
  1683. #ifdef UNICODE
  1684. #define SaslEnumerateProfiles SaslEnumerateProfilesW
  1685. #else
  1686. #define SaslEnumerateProfiles SaslEnumerateProfilesA
  1687. #endif
  1688. SECURITY_STATUS
  1689. SEC_ENTRY
  1690. SaslGetProfilePackageA(
  1691. IN LPSTR ProfileName,
  1692. OUT PSecPkgInfoA * PackageInfo
  1693. );
  1694. SECURITY_STATUS
  1695. SEC_ENTRY
  1696. SaslGetProfilePackageW(
  1697. IN LPWSTR ProfileName,
  1698. OUT PSecPkgInfoW * PackageInfo
  1699. );
  1700. #ifdef UNICODE
  1701. #define SaslGetProfilePackage SaslGetProfilePackageW
  1702. #else
  1703. #define SaslGetProfilePackage SaslGetProfilePackageA
  1704. #endif
  1705. SECURITY_STATUS
  1706. SEC_ENTRY
  1707. SaslIdentifyPackageA(
  1708. IN PSecBufferDesc pInput,
  1709. OUT PSecPkgInfoA * PackageInfo
  1710. );
  1711. SECURITY_STATUS
  1712. SEC_ENTRY
  1713. SaslIdentifyPackageW(
  1714. IN PSecBufferDesc pInput,
  1715. OUT PSecPkgInfoW * PackageInfo
  1716. );
  1717. #ifdef UNICODE
  1718. #define SaslIdentifyPackage SaslIdentifyPackageW
  1719. #else
  1720. #define SaslIdentifyPackage SaslIdentifyPackageA
  1721. #endif
  1722. SECURITY_STATUS
  1723. SEC_ENTRY
  1724. SaslInitializeSecurityContextW(
  1725. PCredHandle phCredential, // Cred to base context
  1726. PCtxtHandle phContext, // Existing context (OPT)
  1727. LPWSTR pszTargetName, // Name of target
  1728. unsigned long fContextReq, // Context Requirements
  1729. unsigned long Reserved1, // Reserved, MBZ
  1730. unsigned long TargetDataRep, // Data rep of target
  1731. PSecBufferDesc pInput, // Input Buffers
  1732. unsigned long Reserved2, // Reserved, MBZ
  1733. PCtxtHandle phNewContext, // (out) New Context handle
  1734. PSecBufferDesc pOutput, // (inout) Output Buffers
  1735. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  1736. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1737. );
  1738. SECURITY_STATUS
  1739. SEC_ENTRY
  1740. SaslInitializeSecurityContextA(
  1741. PCredHandle phCredential, // Cred to base context
  1742. PCtxtHandle phContext, // Existing context (OPT)
  1743. LPSTR pszTargetName, // Name of target
  1744. unsigned long fContextReq, // Context Requirements
  1745. unsigned long Reserved1, // Reserved, MBZ
  1746. unsigned long TargetDataRep, // Data rep of target
  1747. PSecBufferDesc pInput, // Input Buffers
  1748. unsigned long Reserved2, // Reserved, MBZ
  1749. PCtxtHandle phNewContext, // (out) New Context handle
  1750. PSecBufferDesc pOutput, // (inout) Output Buffers
  1751. unsigned long SEC_FAR * pfContextAttr, // (out) Context attrs
  1752. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1753. );
  1754. #ifdef UNICODE
  1755. #define SaslInitializeSecurityContext SaslInitializeSecurityContextW
  1756. #else
  1757. #define SaslInitializeSecurityContext SaslInitializeSecurityContextA
  1758. #endif
  1759. SECURITY_STATUS
  1760. SEC_ENTRY
  1761. SaslAcceptSecurityContext(
  1762. PCredHandle phCredential, // Cred to base context
  1763. PCtxtHandle phContext, // Existing context (OPT)
  1764. PSecBufferDesc pInput, // Input buffer
  1765. unsigned long fContextReq, // Context Requirements
  1766. unsigned long TargetDataRep, // Target Data Rep
  1767. PCtxtHandle phNewContext, // (out) New context handle
  1768. PSecBufferDesc pOutput, // (inout) Output buffers
  1769. unsigned long SEC_FAR * pfContextAttr, // (out) Context attributes
  1770. PTimeStamp ptsExpiry // (out) Life span (OPT)
  1771. );
  1772. #define SASL_OPTION_SEND_SIZE 1 // Maximum size to send to peer
  1773. #define SASL_OPTION_RECV_SIZE 2 // Maximum size willing to receive
  1774. #define SASL_OPTION_AUTHZ_STRING 3 // Authorization string
  1775. #define SASL_OPTION_AUTHZ_PROCESSING 4 // Authorization string processing
  1776. typedef enum _SASL_AUTHZID_STATE {
  1777. Sasl_AuthZIDForbidden, // allow no AuthZID strings to be specified - error out (default)
  1778. Sasl_AuthZIDProcessed // AuthZID Strings processed by Application or SSP
  1779. } SASL_AUTHZID_STATE ;
  1780. SECURITY_STATUS
  1781. SEC_ENTRY
  1782. SaslSetContextOption(
  1783. __in PCtxtHandle ContextHandle,
  1784. __in ULONG Option,
  1785. __in PVOID Value,
  1786. __in ULONG Size
  1787. );
  1788. SECURITY_STATUS
  1789. SEC_ENTRY
  1790. SaslGetContextOption(
  1791. __in PCtxtHandle ContextHandle,
  1792. __in ULONG Option,
  1793. __out PVOID Value,
  1794. __in ULONG Size,
  1795. __out_opt PULONG Needed OPTIONAL
  1796. );
  1797. *)
  1798. //
  1799. // This is the legacy credentials structure.
  1800. // The EX version below is preferred.
  1801. const
  1802. SEC_WINNT_AUTH_IDENTITY_VERSION_2 = $201;
  1803. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_VERSION_2}
  1804. type
  1805. PSEC_WINNT_AUTH_IDENTITY_EX2 = ^SEC_WINNT_AUTH_IDENTITY_EX2;
  1806. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EX2}
  1807. SEC_WINNT_AUTH_IDENTITY_EX2 = record
  1808. Version: ULONG; // contains SEC_WINNT_AUTH_IDENTITY_VERSION_2
  1809. cbHeaderLength: USHORT;
  1810. cbStructureLength: ULONG;
  1811. UserOffset: ULONG; // Non-NULL terminated string, unicode only
  1812. UserLength: USHORT; // # of bytes (NOT WCHARs), not including NULL.
  1813. DomainOffset: ULONG; // Non-NULL terminated string, unicode only
  1814. DomainLength: USHORT; // # of bytes (NOT WCHARs), not including NULL.
  1815. PackedCredentialsOffset: ULONG; // Non-NULL terminated string, unicode only
  1816. PackedCredentialsLength: USHORT; // # of bytes (NOT WCHARs), not including NULL.
  1817. Flags: ULONG;
  1818. PackageListOffset: ULONG; // Non-NULL terminated string, unicode only
  1819. PackageListLength: USHORT;
  1820. end;
  1821. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EX2}
  1822. //
  1823. // This was not defined in NTIFS.h for windows 2000 however
  1824. // this struct has always been there and are safe to use
  1825. // in windows 2000 and above.
  1826. //
  1827. const
  1828. SEC_WINNT_AUTH_IDENTITY_ANSI = $1;
  1829. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_ANSI}
  1830. SEC_WINNT_AUTH_IDENTITY_UNICODE = $2;
  1831. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_UNICODE}
  1832. type
  1833. PSEC_WINNT_AUTH_IDENTITY_W = ^SEC_WINNT_AUTH_IDENTITY_W;
  1834. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_W}
  1835. SEC_WINNT_AUTH_IDENTITY_W = record
  1836. User: PUSHORT; // Non-NULL terminated string.
  1837. UserLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1838. Domain: PUSHORT; // Non-NULL terminated string.
  1839. DomainLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1840. Password: PUSHORT; // Non-NULL terminated string.
  1841. PasswordLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1842. Flags: ULONG;
  1843. end;
  1844. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_W}
  1845. PSEC_WINNT_AUTH_IDENTITY_A = ^SEC_WINNT_AUTH_IDENTITY_A;
  1846. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_A}
  1847. SEC_WINNT_AUTH_IDENTITY_A = record
  1848. User: PUCHAR; // Non-NULL terminated string.
  1849. UserLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1850. Domain: PUCHAR; // Non-NULL terminated string.
  1851. DomainLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1852. Password: PUCHAR; // Non-NULL terminated string.
  1853. PasswordLength: ULONG; // # of characters (NOT bytes), not including NULL.
  1854. Flags: ULONG;
  1855. end;
  1856. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_A}
  1857. {$IFDEF SSPI_UNICODE}
  1858. SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_W;
  1859. PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_W;
  1860. {$ELSE}
  1861. SEC_WINNT_AUTH_IDENTITY = SEC_WINNT_AUTH_IDENTITY_A;
  1862. PSEC_WINNT_AUTH_IDENTITY = PSEC_WINNT_AUTH_IDENTITY_A;
  1863. {$ENDIF}
  1864. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY}
  1865. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY}
  1866. //
  1867. // This is the combined authentication identity structure that may be
  1868. // used with the negotiate package, NTLM, Kerberos, or SCHANNEL
  1869. //
  1870. const
  1871. SEC_WINNT_AUTH_IDENTITY_VERSION = $200;
  1872. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_VERSION}
  1873. type
  1874. PSEC_WINNT_AUTH_IDENTITY_EXW = ^SEC_WINNT_AUTH_IDENTITY_EXW;
  1875. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EXW}
  1876. SEC_WINNT_AUTH_IDENTITY_EXW = record
  1877. Version: ULONG;
  1878. Length: ULONG;
  1879. User: PUSHORT;
  1880. UserLength: ULONG;
  1881. Domain: PUSHORT;
  1882. DomainLength: ULONG;
  1883. Password: PUSHORT;
  1884. PasswordLength: ULONG;
  1885. Flags: ULONG;
  1886. PackageList: PUSHORT;
  1887. PackageListLength: ULONG;
  1888. end;
  1889. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EXW}
  1890. PSEC_WINNT_AUTH_IDENTITY_EXA = ^SEC_WINNT_AUTH_IDENTITY_EXA;
  1891. {$EXTERNALSYM PSEC_WINNT_AUTH_IDENTITY_EXA}
  1892. SEC_WINNT_AUTH_IDENTITY_EXA = record
  1893. Version: ULONG;
  1894. Length: ULONG;
  1895. User: PUCHAR;
  1896. UserLength: ULONG;
  1897. Domain: PUCHAR;
  1898. DomainLength: ULONG;
  1899. Password: PUCHAR;
  1900. PasswordLength: ULONG;
  1901. Flags: ULONG;
  1902. PackageList: PUCHAR;
  1903. PackageListLength: ULONG;
  1904. end;
  1905. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EXA}
  1906. {$IFDEF SSPI_UNICODE}
  1907. SEC_WINNT_AUTH_IDENTITY_EX = SEC_WINNT_AUTH_IDENTITY_EXW;
  1908. {$ELSE}
  1909. SEC_WINNT_AUTH_IDENTITY_EX = SEC_WINNT_AUTH_IDENTITY_EXA;
  1910. {$ENDIF}
  1911. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_EX}
  1912. (* TODO
  1913. //
  1914. // the procedure for how to parse a SEC_WINNT_AUTH_IDENTITY_INFO structure:
  1915. //
  1916. // 1) First check the first DWORD of SEC_WINNT_AUTH_IDENTITY_INFO, if the first
  1917. // DWORD is 0x200, it is either an AuthIdExw or AuthIdExA, otherwise if the first
  1918. // DWORD is 0x201, the structure is an AuthIdEx2 structure. Otherwise the structure
  1919. // is either an AuthId_a or an AuthId_w.
  1920. //
  1921. // 2) Secondly check the flags for SEC_WINNT_AUTH_IDENTITY_ANSI or
  1922. // SEC_WINNT_AUTH_IDENTITY_UNICODE, the presence of the former means the structure
  1923. // is an ANSI structure. Otherwise, the structure is the wide version. Note that
  1924. // AuthIdEx2 does not have an ANSI version so this check does not apply to it.
  1925. //
  1926. typedef union _SEC_WINNT_AUTH_IDENTITY_INFO {
  1927. SEC_WINNT_AUTH_IDENTITY_EXW AuthIdExw;
  1928. SEC_WINNT_AUTH_IDENTITY_EXA AuthIdExa;
  1929. SEC_WINNT_AUTH_IDENTITY_A AuthId_a;
  1930. SEC_WINNT_AUTH_IDENTITY_W AuthId_w;
  1931. SEC_WINNT_AUTH_IDENTITY_EX2 AuthIdEx2;
  1932. } SEC_WINNT_AUTH_IDENTITY_INFO, *PSEC_WINNT_AUTH_IDENTITY_INFO;
  1933. // the credential structure is encrypted via
  1934. // RtlEncryptMemory(OptionFlags = 0)
  1935. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_PROCESS_ENCRYPTED 0x10
  1936. // the credential structure is protected by local system via
  1937. // RtlEncryptMemory(OptionFlags =
  1938. // IOCTL_KSEC_ENCRYPT_MEMORY_SAME_LOGON)
  1939. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_SYSTEM_PROTECTED 0x20
  1940. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_RESERVED 0x10000
  1941. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_NULL_USER 0x20000
  1942. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_NULL_DOMAIN 0x40000
  1943. //
  1944. // These bits are for communication between SspiPromptForCredentials()
  1945. // and the credential providers. Do not use these bits for any other
  1946. // purpose.
  1947. //
  1948. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_USE_MASK 0xFF000000
  1949. //
  1950. // Instructs the credential provider to not save credentials itself
  1951. // when caller selects the "Remember my credential" checkbox.
  1952. //
  1953. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_BY_CALLER 0x80000000
  1954. //
  1955. // State of the "Remember my credentials" checkbox.
  1956. // When set, indicates checked; when cleared, indicates unchecked.
  1957. //
  1958. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_CHECKED 0x40000000
  1959. #define SEC_WINNT_AUTH_IDENTITY_FLAGS_VALID_SSPIPFC_FLAGS \
  1960. (SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_BY_CALLER | \
  1961. SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_CHECKED)
  1962. #endif // _AUTH_IDENTITY_INFO_DEFINED
  1963. #ifndef _SSPIPFC_NONE_ // the public view
  1964. // begin_ntifs
  1965. typedef PVOID PSEC_WINNT_AUTH_IDENTITY_OPAQUE; // the credential structure is opaque
  1966. // end_ntifs
  1967. #else // the internal view
  1968. typedef PSEC_WINNT_AUTH_IDENTITY_INFO PSEC_WINNT_AUTH_IDENTITY_OPAQUE;
  1969. #endif // _SSPIPFC_NONE_
  1970. //
  1971. // dwFlags parameter of SspiPromptForCredentials():
  1972. //
  1973. //
  1974. // Indicates that the credentials should not be saved if
  1975. // the user selects the 'save' (or 'remember my password')
  1976. // checkbox in the credential dialog box. The location pointed
  1977. // to by the pfSave parameter indicates whether or not the user
  1978. // selected the checkbox.
  1979. //
  1980. // Note that some credential providers won't honour this flag and
  1981. // may save the credentials in a persistent manner anyway if the
  1982. // user selects the 'save' checbox.
  1983. //
  1984. #define SSPIPFC_SAVE_CRED_BY_CALLER 0x00000001
  1985. #define SSPIPFC_VALID_FLAGS (SSPIPFC_SAVE_CRED_BY_CALLER)
  1986. #ifndef _SSPIPFC_NONE_ // the public view
  1987. // Use SspiFreeAuthIdentity() to free the buffer returned
  1988. // in ppAuthIdentity.
  1989. unsigned long
  1990. SEC_ENTRY
  1991. SspiPromptForCredentialsW(
  1992. __in PCWSTR pszTargetName,
  1993. #ifdef _CREDUI_INFO_DEFINED
  1994. __in_opt PCREDUI_INFOW pUiInfo,
  1995. #else
  1996. __in_opt PVOID pUiInfo,
  1997. #endif // _CREDUI_INFO_DEFINED
  1998. __in unsigned long dwAuthError,
  1999. __in PCWSTR pszPackage,
  2000. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE pInputAuthIdentity,
  2001. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* ppAuthIdentity,
  2002. __inout_opt int* pfSave,
  2003. __in unsigned long dwFlags
  2004. );
  2005. // Use SspiFreeAuthIdentity() to free the buffer returned
  2006. // in ppAuthIdentity.
  2007. unsigned long
  2008. SEC_ENTRY
  2009. SspiPromptForCredentialsA(
  2010. __in PCSTR pszTargetName,
  2011. #ifdef _CREDUI_INFO_DEFINED
  2012. __in_opt PCREDUI_INFOA pUiInfo,
  2013. #else
  2014. __in_opt PVOID pUiInfo,
  2015. #endif // _CREDUI_INFO_DEFINED
  2016. __in unsigned long dwAuthError,
  2017. __in PCSTR pszPackage,
  2018. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE pInputAuthIdentity,
  2019. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* ppAuthIdentity,
  2020. __inout_opt int* pfSave,
  2021. __in unsigned long dwFlags
  2022. );
  2023. #endif // _SSPIPFC_NONE_
  2024. #ifdef UNICODE
  2025. #define SspiPromptForCredentials SspiPromptForCredentialsW
  2026. #else
  2027. #define SspiPromptForCredentials SspiPromptForCredentialsA
  2028. #endif
  2029. #ifdef _SEC_WINNT_AUTH_TYPES
  2030. typedef struct _SEC_WINNT_AUTH_BYTE_VECTOR {
  2031. unsigned long ByteArrayOffset; // each element is a byte
  2032. unsigned short ByteArrayLength; //
  2033. } SEC_WINNT_AUTH_BYTE_VECTOR, *PSEC_WINNT_AUTH_BYTE_VECTOR;
  2034. typedef struct _SEC_WINNT_AUTH_DATA {
  2035. GUID CredType;
  2036. SEC_WINNT_AUTH_BYTE_VECTOR CredData;
  2037. } SEC_WINNT_AUTH_DATA, *PSEC_WINNT_AUTH_DATA;
  2038. typedef struct _SEC_WINNT_AUTH_PACKED_CREDENTIALS {
  2039. unsigned short cbHeaderLength; // the length of the header
  2040. unsigned short cbStructureLength; // pay load length including the header
  2041. SEC_WINNT_AUTH_DATA AuthData;
  2042. } SEC_WINNT_AUTH_PACKED_CREDENTIALS, *PSEC_WINNT_AUTH_PACKED_CREDENTIALS;
  2043. // {28BFC32F-10F6-4738-98D1-1AC061DF716A}
  2044. static const GUID SEC_WINNT_AUTH_DATA_TYPE_PASSWORD =
  2045. { 0x28bfc32f, 0x10f6, 0x4738, { 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a } };
  2046. // {235F69AD-73FB-4dbc-8203-0629E739339B}
  2047. static const GUID SEC_WINNT_AUTH_DATA_TYPE_CERT =
  2048. { 0x235f69ad, 0x73fb, 0x4dbc, { 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b } };
  2049. typedef struct _SEC_WINNT_AUTH_DATA_PASSWORD {
  2050. SEC_WINNT_AUTH_BYTE_VECTOR UnicodePassword;
  2051. } SEC_WINNT_AUTH_DATA_PASSWORD, PSEC_WINNT_AUTH_DATA_PASSWORD;
  2052. //
  2053. // smartcard cred data
  2054. //
  2055. // {68FD9879-079C-4dfe-8281-578AADC1C100}
  2056. static const GUID SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA =
  2057. { 0x68fd9879, 0x79c, 0x4dfe, { 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0 } };
  2058. typedef struct _SEC_WINNT_AUTH_CERTIFICATE_DATA {
  2059. unsigned short cbHeaderLength;
  2060. unsigned short cbStructureLength;
  2061. SEC_WINNT_AUTH_BYTE_VECTOR Certificate;
  2062. } SEC_WINNT_AUTH_CERTIFICATE_DATA, *PSEC_WINNT_AUTH_CERTIFICATE_DATA;
  2063. typedef struct _SEC_WINNT_CREDUI_CONTEXT_VECTOR
  2064. {
  2065. ULONG CredUIContextArrayOffset; // offset starts at the beginning of
  2066. // this structure, and each element is a SEC_WINNT_AUTH_BYTE_VECTOR that
  2067. // describes the flat CredUI context returned by SpGetCredUIContext()
  2068. USHORT CredUIContextCount;
  2069. } SEC_WINNT_CREDUI_CONTEXT_VECTOR, *PSEC_WINNT_CREDUI_CONTEXT_VECTOR;
  2070. typedef struct _SEC_WINNT_AUTH_SHORT_VECTOR
  2071. {
  2072. ULONG ShortArrayOffset; // each element is a short
  2073. USHORT ShortArrayCount; // number of characters
  2074. } SEC_WINNT_AUTH_SHORT_VECTOR, *PSEC_WINNT_AUTH_SHORT_VECTOR;
  2075. // free the returned memory using SspiLocalFree
  2076. SECURITY_STATUS
  2077. SEC_ENTRY
  2078. SspiGetCredUIContext(
  2079. __in HANDLE ContextHandle,
  2080. __in GUID* CredType,
  2081. __in_opt LUID* LogonId, // use this LogonId, the caller must be localsystem to supply a logon id
  2082. __deref_out PSEC_WINNT_CREDUI_CONTEXT_VECTOR* CredUIContexts,
  2083. __out_opt HANDLE* TokenHandle
  2084. );
  2085. SECURITY_STATUS
  2086. SEC_ENTRY
  2087. SspiUpdateCredentials(
  2088. __in HANDLE ContextHandle,
  2089. __in GUID* CredType,
  2090. __in ULONG FlatCredUIContextLength,
  2091. __in_bcount(FlatCredUIContextLength) PUCHAR FlatCredUIContext
  2092. );
  2093. typedef struct _CREDUIWIN_MARSHALED_CONTEXT
  2094. {
  2095. GUID StructureType;
  2096. USHORT cbHeaderLength;
  2097. LUID LogonId; // user's logon id
  2098. GUID MarshaledDataType;
  2099. ULONG MarshaledDataOffset;
  2100. USHORT MarshaledDataLength;
  2101. } CREDUIWIN_MARSHALED_CONTEXT, *PCREDUIWIN_MARSHALED_CONTEXT;
  2102. typedef struct _SEC_WINNT_CREDUI_CONTEXT
  2103. {
  2104. USHORT cbHeaderLength;
  2105. HANDLE CredUIContextHandle; // the handle to call SspiGetCredUIContext()
  2106. #ifdef _CREDUI_INFO_DEFINED
  2107. PCREDUI_INFOW UIInfo; // input from SspiPromptForCredentials()
  2108. #else
  2109. PVOID UIInfo;
  2110. #endif // _CREDUI_INFO_DEFINED
  2111. ULONG dwAuthError; // the authentication error
  2112. PSEC_WINNT_AUTH_IDENTITY_OPAQUE pInputAuthIdentity;
  2113. PUNICODE_STRING TargetName;
  2114. } SEC_WINNT_CREDUI_CONTEXT, *PSEC_WINNT_CREDUI_CONTEXT;
  2115. // {3C3E93D9-D96B-49b5-94A7-458592088337}
  2116. static const GUID CREDUIWIN_STRUCTURE_TYPE_SSPIPFC =
  2117. { 0x3c3e93d9, 0xd96b, 0x49b5, { 0x94, 0xa7, 0x45, 0x85, 0x92, 0x8, 0x83, 0x37 } };
  2118. // {C2FFFE6F-503D-4c3d-A95E-BCE821213D44}
  2119. static const GUID SSPIPFC_STRUCTURE_TYPE_CREDUI_CONTEXT =
  2120. { 0xc2fffe6f, 0x503d, 0x4c3d, { 0xa9, 0x5e, 0xbc, 0xe8, 0x21, 0x21, 0x3d, 0x44 } };
  2121. typedef struct _SEC_WINNT_AUTH_PACKED_CREDENTIALS_EX {
  2122. unsigned short cbHeaderLength;
  2123. unsigned long Flags; // contains the Flags field in
  2124. // SEC_WINNT_AUTH_IDENTITY_EX
  2125. SEC_WINNT_AUTH_BYTE_VECTOR PackedCredentials;
  2126. SEC_WINNT_AUTH_SHORT_VECTOR PackageList;
  2127. } SEC_WINNT_AUTH_PACKED_CREDENTIALS_EX, *PSEC_WINNT_AUTH_PACKED_CREDENTIALS_EX;
  2128. //
  2129. // free the returned memory using SspiLocalFree
  2130. //
  2131. SECURITY_STATUS
  2132. SEC_ENTRY
  2133. SspiUnmarshalCredUIContext(
  2134. __in_bcount(MarshaledCredUIContextLength) PUCHAR MarshaledCredUIContext,
  2135. __in ULONG MarshaledCredUIContextLength,
  2136. __deref_out PSEC_WINNT_CREDUI_CONTEXT* CredUIContext
  2137. );
  2138. #endif // _SEC_WINNT_AUTH_TYPES
  2139. SECURITY_STATUS
  2140. SEC_ENTRY
  2141. SspiPrepareForCredRead(
  2142. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity,
  2143. __in PCWSTR pszTargetName,
  2144. __out PULONG pCredmanCredentialType,
  2145. __deref_out PCWSTR* ppszCredmanTargetName
  2146. );
  2147. SECURITY_STATUS
  2148. SEC_ENTRY
  2149. SspiPrepareForCredWrite(
  2150. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity,
  2151. __in_opt PCWSTR pszTargetName, // supply NULL for username-target credentials
  2152. __out PULONG pCredmanCredentialType,
  2153. __deref_out PCWSTR* ppszCredmanTargetName,
  2154. __deref_out PCWSTR* ppszCredmanUserName,
  2155. __deref_out_bcount(*pCredentialBlobSize) PUCHAR *ppCredentialBlob,
  2156. __out PULONG pCredentialBlobSize
  2157. );
  2158. SECURITY_STATUS
  2159. SEC_ENTRY
  2160. SspiEncryptAuthIdentity(
  2161. __inout PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthData
  2162. );
  2163. SECURITY_STATUS
  2164. SEC_ENTRY
  2165. SspiDecryptAuthIdentity(
  2166. __inout PSEC_WINNT_AUTH_IDENTITY_OPAQUE EncryptedAuthData
  2167. );
  2168. BOOLEAN
  2169. SEC_ENTRY
  2170. SspiIsAuthIdentityEncrypted(
  2171. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE EncryptedAuthData
  2172. );
  2173. // begin_ntifs
  2174. #if (NTDDI_VERSION >= NTDDI_WIN7)
  2175. //
  2176. // Convert the _OPAQUE structure passed in to the
  2177. // 3 tuple <username, domainname, 'password'>.
  2178. //
  2179. // Note: The 'strings' returned need not necessarily be
  2180. // in user recognisable form. The purpose of this API
  2181. // is to 'flatten' the _OPAQUE structure into the 3 tuple.
  2182. // User recognisable <username, domainname> can always be
  2183. // obtained by passing NULL to the pszPackedCredentialsString
  2184. // parameter.
  2185. //
  2186. // zero out the pszPackedCredentialsString then
  2187. // free the returned memory using SspiLocalFree()
  2188. //
  2189. SECURITY_STATUS
  2190. SEC_ENTRY
  2191. SspiEncodeAuthIdentityAsStrings(
  2192. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE pAuthIdentity,
  2193. __deref_out_opt PCWSTR* ppszUserName,
  2194. __deref_out_opt PCWSTR* ppszDomainName,
  2195. __deref_opt_out_opt PCWSTR* ppszPackedCredentialsString
  2196. );
  2197. SECURITY_STATUS
  2198. SEC_ENTRY
  2199. SspiValidateAuthIdentity(
  2200. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthData
  2201. );
  2202. //
  2203. // free the returned memory using SspiFreeAuthIdentity()
  2204. //
  2205. SECURITY_STATUS
  2206. SEC_ENTRY
  2207. SspiCopyAuthIdentity(
  2208. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthData,
  2209. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* AuthDataCopy
  2210. );
  2211. //
  2212. // use only for the memory returned by SspiCopyAuthIdentity().
  2213. // Internally calls SspiZeroAuthIdentity().
  2214. //
  2215. VOID
  2216. SEC_ENTRY
  2217. SspiFreeAuthIdentity(
  2218. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthData
  2219. );
  2220. VOID
  2221. SEC_ENTRY
  2222. SspiZeroAuthIdentity(
  2223. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthData
  2224. );
  2225. VOID
  2226. SEC_ENTRY
  2227. SspiLocalFree(
  2228. __in_opt PVOID DataBuffer
  2229. );
  2230. //
  2231. // call SspiFreeAuthIdentity to free the returned AuthIdentity
  2232. // which zeroes out the credentials blob before freeing it
  2233. //
  2234. SECURITY_STATUS
  2235. SEC_ENTRY
  2236. SspiEncodeStringsAsAuthIdentity(
  2237. __in_opt PCWSTR pszUserName,
  2238. __in_opt PCWSTR pszDomainName,
  2239. __in_opt PCWSTR pszPackedCredentialsString,
  2240. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* ppAuthIdentity
  2241. );
  2242. SECURITY_STATUS
  2243. SEC_ENTRY
  2244. SspiCompareAuthIdentities(
  2245. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity1,
  2246. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity2,
  2247. __out_opt PBOOLEAN SameSuppliedUser,
  2248. __out_opt PBOOLEAN SameSuppliedIdentity
  2249. );
  2250. //
  2251. // zero out the returned AuthIdentityByteArray then
  2252. // free the returned memory using SspiLocalFree()
  2253. //
  2254. SECURITY_STATUS
  2255. SEC_ENTRY
  2256. SspiMarshalAuthIdentity(
  2257. __in PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity,
  2258. __out unsigned long* AuthIdentityLength,
  2259. __deref_out_bcount(*AuthIdentityLength) char** AuthIdentityByteArray
  2260. );
  2261. //
  2262. // free the returned auth identity using SspiFreeAuthIdentity()
  2263. //
  2264. SECURITY_STATUS
  2265. SEC_ENTRY
  2266. SspiUnmarshalAuthIdentity(
  2267. __in unsigned long AuthIdentityLength,
  2268. __in_bcount(AuthIdentityLength) char* AuthIdentityByteArray,
  2269. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* ppAuthIdentity
  2270. );
  2271. BOOLEAN
  2272. SEC_ENTRY
  2273. SspiIsPromptingNeeded(
  2274. __in unsigned long ErrorOrNtStatus
  2275. );
  2276. SECURITY_STATUS
  2277. SEC_ENTRY
  2278. SspiGetTargetHostName(
  2279. __in PCWSTR pszTargetName,
  2280. __deref_out PWSTR* pszHostName
  2281. );
  2282. SECURITY_STATUS
  2283. SEC_ENTRY
  2284. SspiExcludePackage(
  2285. __in_opt PSEC_WINNT_AUTH_IDENTITY_OPAQUE AuthIdentity,
  2286. __in PCWSTR pszPackageName,
  2287. __deref_out PSEC_WINNT_AUTH_IDENTITY_OPAQUE* ppNewAuthIdentity
  2288. );
  2289. *)
  2290. //
  2291. // Common types used by negotiable security packages
  2292. //
  2293. const
  2294. SEC_WINNT_AUTH_IDENTITY_MARSHALLED = $4; // all data is in one buffer
  2295. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_MARSHALLED}
  2296. SEC_WINNT_AUTH_IDENTITY_ONLY = $8; // these credentials are for identity only - no PAC needed
  2297. {$EXTERNALSYM SEC_WINNT_AUTH_IDENTITY_ONLY}
  2298. (* TODO
  2299. //
  2300. // Routines for manipulating packages
  2301. //
  2302. typedef struct _SECURITY_PACKAGE_OPTIONS {
  2303. unsigned long Size;
  2304. unsigned long Type;
  2305. unsigned long Flags;
  2306. unsigned long SignatureSize;
  2307. void SEC_FAR * Signature;
  2308. } SECURITY_PACKAGE_OPTIONS, SEC_FAR * PSECURITY_PACKAGE_OPTIONS;
  2309. #define SECPKG_OPTIONS_TYPE_UNKNOWN 0
  2310. #define SECPKG_OPTIONS_TYPE_LSA 1
  2311. #define SECPKG_OPTIONS_TYPE_SSPI 2
  2312. #define SECPKG_OPTIONS_PERMANENT 0x00000001
  2313. SECURITY_STATUS
  2314. SEC_ENTRY
  2315. AddSecurityPackageA(
  2316. SEC_CHAR SEC_FAR * pszPackageName,
  2317. SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  2318. );
  2319. SECURITY_STATUS
  2320. SEC_ENTRY
  2321. AddSecurityPackageW(
  2322. SEC_WCHAR SEC_FAR * pszPackageName,
  2323. SECURITY_PACKAGE_OPTIONS SEC_FAR * Options
  2324. );
  2325. #ifdef UNICODE
  2326. #define AddSecurityPackage AddSecurityPackageW
  2327. #else
  2328. #define AddSecurityPackage AddSecurityPackageA
  2329. #endif
  2330. SECURITY_STATUS
  2331. SEC_ENTRY
  2332. DeleteSecurityPackageA(
  2333. SEC_CHAR SEC_FAR * pszPackageName );
  2334. SECURITY_STATUS
  2335. SEC_ENTRY
  2336. DeleteSecurityPackageW(
  2337. SEC_WCHAR SEC_FAR * pszPackageName );
  2338. #ifdef UNICODE
  2339. #define DeleteSecurityPackage DeleteSecurityPackageW
  2340. #else
  2341. #define DeleteSecurityPackage DeleteSecurityPackageA
  2342. #endif
  2343. //+-----------------------------------------------------------------------
  2344. //
  2345. // Microsoft Windows
  2346. //
  2347. // Copyright (c) Microsoft Corporation 1991-1999
  2348. //
  2349. // File: secext.h
  2350. //
  2351. // Contents: Security function prototypes for functions not part of
  2352. // the SSPI interface. This file should not be directly
  2353. // included - include security.h instead.
  2354. //
  2355. //
  2356. // History: 22 Dec 92 RichardW Created
  2357. //
  2358. //------------------------------------------------------------------------
  2359. //
  2360. // Extended Name APIs for ADS
  2361. //
  2362. typedef enum
  2363. {
  2364. // Examples for the following formats assume a fictitous company
  2365. // which hooks into the global X.500 and DNS name spaces as follows.
  2366. //
  2367. // Enterprise root domain in DNS is
  2368. //
  2369. // widget.com
  2370. //
  2371. // Enterprise root domain in X.500 (RFC 1779 format) is
  2372. //
  2373. // O=Widget, C=US
  2374. //
  2375. // There exists the child domain
  2376. //
  2377. // engineering.widget.com
  2378. //
  2379. // equivalent to
  2380. //
  2381. // OU=Engineering, O=Widget, C=US
  2382. //
  2383. // There exists a container within the Engineering domain
  2384. //
  2385. // OU=Software, OU=Engineering, O=Widget, C=US
  2386. //
  2387. // There exists the user
  2388. //
  2389. // CN=John Doe, OU=Software, OU=Engineering, O=Widget, C=US
  2390. //
  2391. // And this user's downlevel (pre-ADS) user name is {Do not Localize}
  2392. //
  2393. // Engineering\JohnDoe
  2394. // unknown name type
  2395. NameUnknown = 0,
  2396. // CN=John Doe, OU=Software, OU=Engineering, O=Widget, C=US
  2397. NameFullyQualifiedDN = 1,
  2398. // Engineering\JohnDoe
  2399. NameSamCompatible = 2,
  2400. // Probably "John Doe" but could be something else. I.e. The
  2401. // display name is not necessarily the defining RDN.
  2402. NameDisplay = 3,
  2403. // String-ized GUID as returned by IIDFromString().
  2404. // eg: {4fa050f0-f561-11cf-bdd9-00aa003a77b6}
  2405. NameUniqueId = 6,
  2406. // engineering.widget.com/software/John Doe
  2407. NameCanonical = 7,
  2408. // [email protected]
  2409. NameUserPrincipal = 8,
  2410. // Same as NameCanonical except that rightmost '/' is {Do not Localize}
  2411. // replaced with '\n' - even in domain-only case. {Do not Localize}
  2412. // eg: engineering.widget.com/software\nJohn Doe
  2413. NameCanonicalEx = 9,
  2414. // www/srv.engineering.com/engineering.com
  2415. NameServicePrincipal = 10
  2416. } EXTENDED_NAME_FORMAT, * PEXTENDED_NAME_FORMAT ;
  2417. BOOLEAN
  2418. SEC_ENTRY
  2419. GetUserNameExA(
  2420. EXTENDED_NAME_FORMAT NameFormat,
  2421. LPSTR lpNameBuffer,
  2422. PULONG nSize
  2423. );
  2424. BOOLEAN
  2425. SEC_ENTRY
  2426. GetUserNameExW(
  2427. EXTENDED_NAME_FORMAT NameFormat,
  2428. LPWSTR lpNameBuffer,
  2429. PULONG nSize
  2430. );
  2431. #ifdef UNICODE
  2432. #define GetUserNameEx GetUserNameExW
  2433. #else
  2434. #define GetUserNameEx GetUserNameExA
  2435. #endif
  2436. BOOLEAN
  2437. SEC_ENTRY
  2438. GetComputerObjectNameA(
  2439. EXTENDED_NAME_FORMAT NameFormat,
  2440. LPSTR lpNameBuffer,
  2441. PULONG nSize
  2442. );
  2443. BOOLEAN
  2444. SEC_ENTRY
  2445. GetComputerObjectNameW(
  2446. EXTENDED_NAME_FORMAT NameFormat,
  2447. LPWSTR lpNameBuffer,
  2448. PULONG nSize
  2449. );
  2450. #ifdef UNICODE
  2451. #define GetComputerObjectName GetComputerObjectNameW
  2452. #else
  2453. #define GetComputerObjectName GetComputerObjectNameA
  2454. #endif
  2455. BOOLEAN
  2456. SEC_ENTRY
  2457. TranslateNameA(
  2458. LPCSTR lpAccountName,
  2459. EXTENDED_NAME_FORMAT AccountNameFormat,
  2460. EXTENDED_NAME_FORMAT DesiredNameFormat,
  2461. LPSTR lpTranslatedName,
  2462. PULONG nSize
  2463. );
  2464. BOOLEAN
  2465. SEC_ENTRY
  2466. TranslateNameW(
  2467. LPCWSTR lpAccountName,
  2468. EXTENDED_NAME_FORMAT AccountNameFormat,
  2469. EXTENDED_NAME_FORMAT DesiredNameFormat,
  2470. LPWSTR lpTranslatedName,
  2471. PULONG nSize
  2472. );
  2473. #ifdef UNICODE
  2474. #define TranslateName TranslateNameW
  2475. #else
  2476. #define TranslateName TranslateNameA
  2477. #endif
  2478. *)
  2479. implementation
  2480. procedure SecInvalidateHandle(var x: SecHandle);
  2481. begin
  2482. x.dwLower := PtrUInt(-1);
  2483. x.dwUpper := PtrUInt(-1);
  2484. end;
  2485. function SecIsValidHandle(x : SecHandle) : Boolean;
  2486. begin
  2487. // RLebeau: workaround for a bug in D2009. Comparing PtrUInt values does not always work correctly.
  2488. // Sometimes it causes "W1023 Comparing signed and unsigned types" warnings, other times it causes
  2489. // "F2084 Internal Error: C12079" errors
  2490. {$IFDEF VCL_2009}
  2491. Result := (Integer(x.dwLower) <> Integer(PtrUInt(-1))) and
  2492. (Integer(x.dwUpper) <> Integer(PtrUInt(-1)));
  2493. {$ELSE}
  2494. Result := (x.dwLower <> PtrUInt(-1)) and (x.dwUpper <> PtrUInt(-1));
  2495. {$ENDIF}
  2496. end;
  2497. function SEC_SUCCESS(Status: SECURITY_STATUS): Boolean;
  2498. begin
  2499. Result := Status >= 0;
  2500. end;
  2501. end.