Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

452 lines
15 KiB

  1. /*/////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // authif.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the interface for extensions to the Internet Authentication
  12. // Service.
  13. //
  14. /////////////////////////////////////////////////////////////////////////////*/
  15. #ifndef _AUTHIF_H_
  16. #define _AUTHIF_H_
  17. #if _MSC_VER >= 1000
  18. #pragma once
  19. #endif
  20. /*
  21. * Enumerates the attribute types that are passed to the extension DLL. The
  22. * RADIUS standard attributes are included for convenience and should not be
  23. * considered exhaustive.
  24. */
  25. typedef enum _RADIUS_ATTRIBUTE_TYPE {
  26. /* Used to terminate attribute arrays. */
  27. ratMinimum = 0,
  28. /* RADIUS standard attributes. */
  29. ratUserName = 1,
  30. ratUserPassword = 2,
  31. ratCHAPPassword = 3,
  32. ratNASIPAddress = 4,
  33. ratNASPort = 5,
  34. ratServiceType = 6,
  35. ratFramedProtocol = 7,
  36. ratFramedIPAddress = 8,
  37. ratFramedIPNetmask = 9,
  38. ratFramedRouting = 10,
  39. ratFilterId = 11,
  40. ratFramedMTU = 12,
  41. ratFramedCompression = 13,
  42. ratLoginIPHost = 14,
  43. ratLoginService = 15,
  44. ratLoginPort = 16,
  45. ratReplyMessage = 18,
  46. ratCallbackNumber = 19,
  47. ratCallbackId = 20,
  48. ratFramedRoute = 22,
  49. ratFramedIPXNetwork = 23,
  50. ratState = 24,
  51. ratClass = 25,
  52. ratVendorSpecific = 26,
  53. ratSessionTimeout = 27,
  54. ratIdleTimeout = 28,
  55. ratTerminationAction = 29,
  56. ratCalledStationId = 30,
  57. ratCallingStationId = 31,
  58. ratNASIdentifier = 32,
  59. ratProxyState = 33,
  60. ratLoginLATService = 34,
  61. ratLoginLATNode = 35,
  62. ratLoginLATGroup = 36,
  63. ratFramedAppleTalkLink = 37,
  64. ratFramedAppleTalkNetwork = 38,
  65. ratFramedAppleTalkZone = 39,
  66. ratAcctStatusType = 40,
  67. ratAcctDelayTime = 41,
  68. ratAcctInputOctets = 42,
  69. ratAcctOutputOctets = 43,
  70. ratAcctSessionId = 44,
  71. ratAcctAuthentic = 45,
  72. ratAcctSessionTime = 46,
  73. ratAcctInputPackets = 47,
  74. ratAcctOutputPackets = 48,
  75. ratAcctTerminationCause = 49,
  76. ratCHAPChallenge = 60,
  77. ratNASPortType = 61,
  78. ratPortLimit = 62,
  79. /* Extended attribute types used to pass additional information. */
  80. ratCode = 262, /* Request type code. */
  81. ratIdentifier = 263, /* Request identifier. */
  82. ratAuthenticator = 264, /* Request authenticator. */
  83. ratSrcIPAddress = 265, /* Source IP address. */
  84. ratSrcPort = 266, /* Source IP port. */
  85. ratProvider = 267, /* Authentication provider. */
  86. ratStrippedUserName = 268, /* User-Name with realm stripped. */
  87. ratFQUserName = 269, /* Fully-Qualified-User-Name. */
  88. ratPolicyName = 270, /* Remote Access Policy name. */
  89. ratUniqueId = 271, /* Unique ID identifying the request. */
  90. ratExtensionState = 272 /* Used to pass state between extensions. */
  91. } RADIUS_ATTRIBUTE_TYPE;
  92. /*
  93. * Enumerates the different RADIUS packet codes. Used for the ratCode extended
  94. * attribute.
  95. */
  96. typedef enum _RADIUS_CODE {
  97. rcUnknown = 0,
  98. rcAccessRequest = 1,
  99. rcAccessAccept = 2,
  100. rcAccessReject = 3,
  101. rcAccountingRequest = 4,
  102. rcAccountingResponse = 5,
  103. rcAccessChallenge = 11,
  104. rcDiscard = 256
  105. } RADIUS_CODE;
  106. /*
  107. * Enumerates the different authentication providers used for processing a
  108. * request. Used for the ratProvider extended attribute.
  109. */
  110. typedef enum _RADIUS_AUTHENTICATION_PROVIDER {
  111. rapUnknown,
  112. rapUsersFile,
  113. rapProxy,
  114. rapWindowsNT,
  115. rapMCIS,
  116. rapODBC,
  117. rapNone
  118. } RADIUS_AUTHENTICATION_PROVIDER;
  119. /*
  120. * Enumerates the different RADIUS data types. A type of 'rdtUnknown' means
  121. * the attribute was not recognized by the dictionary.
  122. */
  123. typedef enum _RADIUS_DATA_TYPE {
  124. rdtUnknown,
  125. rdtString,
  126. rdtAddress,
  127. rdtInteger,
  128. rdtTime
  129. } RADIUS_DATA_TYPE;
  130. /*
  131. * Struct representing a RADIUS or extended attribute.
  132. */
  133. typedef struct _RADIUS_ATTRIBUTE {
  134. DWORD dwAttrType; /* Attribute type */
  135. RADIUS_DATA_TYPE fDataType; /* RADIUS_DATA_TYPE of the value */
  136. DWORD cbDataLength; /* Length of the value (in bytes) */
  137. union {
  138. DWORD dwValue; /* For rdtAddress, rdtInteger, and rdtTime */
  139. PCSTR lpValue; /* For rdtUnknown, and rdtString */
  140. };
  141. } RADIUS_ATTRIBUTE, *PRADIUS_ATTRIBUTE;
  142. /*
  143. * Struct representing the layout of a RADIUS Vendor-Specific attribute. This
  144. * is useful when interpreting the RADIUS_ATTRIBUTE lpValue field when
  145. * dwAttrType is ratVendorSpecific.
  146. */
  147. typedef struct _RADIUS_VSA_FORMAT {
  148. BYTE VendorId[4];
  149. BYTE VendorType;
  150. BYTE VendorLength;
  151. BYTE AttributeSpecific[1];
  152. } RADIUS_VSA_FORMAT;
  153. /*
  154. * Enumerates the different actions an extension DLL can generate in
  155. * response to an Access-Request.
  156. */
  157. typedef enum _RADIUS_ACTION {
  158. raContinue,
  159. raReject,
  160. raAccept
  161. } RADIUS_ACTION, *PRADIUS_ACTION;
  162. /*
  163. * Routines exported by a RADIUS extension DLL.
  164. */
  165. /*
  166. * RadiusExtensionInit is optional. If it exists, it will be invoked prior to
  167. * the service coming on-line. A return value other than NO_ERROR prevents the
  168. * service from initializing.
  169. */
  170. #define RADIUS_EXTENSION_INIT "RadiusExtensionInit"
  171. typedef DWORD (WINAPI *PRADIUS_EXTENSION_INIT)( VOID );
  172. /*
  173. * RadiusExtensionTerm is optional. If it exists, it will be invoked prior to
  174. * unloading the DLL to give the extension a chance to clean-up.
  175. */
  176. #define RADIUS_EXTENSION_TERM "RadiusExtensionTerm"
  177. typedef VOID (WINAPI *PRADIUS_EXTENSION_TERM)( VOID );
  178. /*
  179. * RadiusExtensionProcess is mandatory for NT4. For Windows 2000, an
  180. * extension may export RadiusExtensionProcessEx (q.v.) instead.
  181. *
  182. * Parameters:
  183. * pAttrs Array of attributes from the request. It is terminated by an
  184. * attribute with dwAttrType set to ratMinimum. These attributes
  185. * should be treated as read-only and must not be referenced
  186. * after the function returns.
  187. * pfAction For Access-Requests, this parameter will be non-NULL with
  188. * *pfAction == raContinue. The extension DLL can set *pfAction
  189. * to abort further processing and force an Access-Accept or
  190. * Access-Reject. For all other request types, this parameter
  191. * will be NULL.
  192. *
  193. * Return Value:
  194. * A return value other than NO_ERROR causes the request to be discarded.
  195. */
  196. #define RADIUS_EXTENSION_PROCESS "RadiusExtensionProcess"
  197. typedef DWORD (WINAPI *PRADIUS_EXTENSION_PROCESS)(
  198. IN const RADIUS_ATTRIBUTE *pAttrs,
  199. OUT OPTIONAL PRADIUS_ACTION pfAction
  200. );
  201. /*
  202. * RadiusExtensionProcessEx is only supported on Windows 2000. If it exits,
  203. * RadiusExtensionProcess is ignored.
  204. *
  205. * Parameters:
  206. * pInAttrs Array of attributes from the request. It is terminated by an
  207. * attribute with dwAttrType set to ratMinimum. These attributes
  208. * should be treated as read-only and must not be referenced
  209. * after the function returns.
  210. * pOutAttrs Array of attributes to add to the response. It is terminated
  211. * by an attribute with dwAttrType set to ratMinimum.
  212. * *pOutAttrs may be set to NULL if no attributes are returned.
  213. * pfAction For Access-Requests, this parameter will be non-NULL with
  214. * *pfAction == raContinue. The extension DLL can set *pfAction
  215. * to abort further processing and force an Access-Accept or
  216. * Access-Reject. For all other request types, this parameter
  217. * will be NULL.
  218. *
  219. * Return Value:
  220. * A return value other than NO_ERROR causes the request to be discarded.
  221. */
  222. #define RADIUS_EXTENSION_PROCESS_EX "RadiusExtensionProcessEx"
  223. typedef DWORD (WINAPI *PRADIUS_EXTENSION_PROCESS_EX)(
  224. IN const RADIUS_ATTRIBUTE *pInAttrs,
  225. OUT PRADIUS_ATTRIBUTE *pOutAttrs,
  226. OUT OPTIONAL PRADIUS_ACTION pfAction
  227. );
  228. /*
  229. * RadiusExtensionFreeAttributes must be defined if RadiusExtensionProcessEx
  230. * is defined. It is used to free the attributes returned by
  231. * RadiusExtensionProcessEx
  232. *
  233. * Parameters:
  234. * pAttrs Array of attributes to be freed.
  235. */
  236. #define RADIUS_EXTENSION_FREE_ATTRIBUTES "RadiusExtensionFreeAttributes"
  237. typedef VOID (WINAPI *PRADIUS_EXTENSION_FREE_ATTRIBUTES)(
  238. IN PRADIUS_ATTRIBUTE pAttrs
  239. );
  240. /*
  241. * Defines used for installation of an extension DLL.
  242. * The following registry values are used for loading extensions:
  243. *
  244. * HKLM\System\CurrentControlSet\Services\AuthSrv\Parameters
  245. * ExtensionDLLs (REG_MULTI_SZ) <list of DLL paths>
  246. * AuthorizationDLLs (REG_MULTI_SZ) <list of DLL paths>
  247. *
  248. * ExtensionDLLs are invoked before any of the built-in authentication
  249. * providers. They receive all the attributes from the request plus all
  250. * the extended attribute types.
  251. *
  252. * AuthorizationDLLs are invoked after the built-in authentication and
  253. * authorization providers. They receive all the attributes from the
  254. * response plus all the extended attributes types. AuthorizationDLLs may
  255. * not return an action of raAccept.
  256. */
  257. #define AUTHSRV_PARAMETERS_KEY_W \
  258. L"System\\CurrentControlSet\\Services\\AuthSrv\\Parameters"
  259. #define AUTHSRV_EXTENSIONS_VALUE_W \
  260. L"ExtensionDLLs"
  261. #define AUTHSRV_AUTHORIZATION_VALUE_W \
  262. L"AuthorizationDLLs"
  263. #if _WIN32_WINNT >= 0x0501
  264. /* Version of this spec. */
  265. #define RADIUS_EXTENSION_VERSION (1)
  266. /*
  267. * Enumerates the different points during request processing where an
  268. * extension can be invoked.
  269. */
  270. typedef enum _RADIUS_EXTENSION_POINT {
  271. repAuthentication, /* ExtensionDLLs */
  272. repAuthorization /* AuthorizationDLLs */
  273. } RADIUS_EXTENSION_POINT;
  274. /*
  275. * Struct representing an array of RADIUS_ATTRIBUTE structs. All the functions
  276. * for adding attributes to a request copy the supplied memory, so there is no
  277. * need for the extension to export RadiusExtensionFreeAttributes. The
  278. * extension must not modify this struct. All changes must be made by using the
  279. * supplied callback functions.
  280. */
  281. typedef struct _RADIUS_ATTRIBUTE_ARRAY {
  282. /* Size of this structure in bytes. */
  283. DWORD cbSize;
  284. /* Adds a new attribute to the end of the array. */
  285. DWORD (WINAPI *Add)(
  286. IN struct _RADIUS_ATTRIBUTE_ARRAY *This,
  287. IN const RADIUS_ATTRIBUTE *pAttr
  288. );
  289. /*
  290. * Returns a const pointer to the specified attribute within the array or
  291. * NULL if the index is out of range.
  292. */
  293. const RADIUS_ATTRIBUTE * (WINAPI *AttributeAt)(
  294. IN const struct _RADIUS_ATTRIBUTE_ARRAY *This,
  295. IN DWORD dwIndex
  296. );
  297. /*
  298. * Returns the size of the array. Since indexes are zero-based, the size is
  299. * 1 greater than the largest index.
  300. */
  301. DWORD (WINAPI *GetSize)(
  302. IN const struct _RADIUS_ATTRIBUTE_ARRAY *This
  303. );
  304. /*
  305. * Inserts a new attribute at a specified index in the array. In the
  306. * process, it shifts up (by incrementing the index) the existing attribute
  307. * at this index, and it shifts up all the attributes above it. Returns
  308. * ERROR_INVALID_PARAMETER if the index is out of range.
  309. */
  310. DWORD (WINAPI *InsertAt)(
  311. IN struct _RADIUS_ATTRIBUTE_ARRAY *This,
  312. IN DWORD dwIndex,
  313. IN const RADIUS_ATTRIBUTE *pAttr
  314. );
  315. /*
  316. * Removes the attribute at the specified index in the array. In the
  317. * process, it shifts down all the attributes above the removed attribute.
  318. * Returns ERROR_ACCESS_DENIED if the specified attribute is read-only.
  319. * Returns ERROR_INVALID_PARAMETER if the index is out of range.
  320. */
  321. DWORD (WINAPI *RemoveAt)(
  322. IN struct _RADIUS_ATTRIBUTE_ARRAY *This,
  323. IN DWORD dwIndex
  324. );
  325. /*
  326. * Sets the array element at the specified index, replacing the existing
  327. * attribute. Returns ERROR_INVALID_PARAMETER if the index is out of range.
  328. */
  329. DWORD (WINAPI *SetAt)(
  330. IN struct _RADIUS_ATTRIBUTE_ARRAY *This,
  331. IN DWORD dwIndex,
  332. IN const RADIUS_ATTRIBUTE *pAttr
  333. );
  334. } RADIUS_ATTRIBUTE_ARRAY, *PRADIUS_ATTRIBUTE_ARRAY;
  335. /*
  336. * Struct used to exchange information with the extension during request
  337. * processing. The extension must not modify this struct. All changes must be
  338. * made by using the supplied callback functions.
  339. */
  340. typedef struct _RADIUS_EXTENSION_CONTROL_BLOCK {
  341. /* Size of this structure. */
  342. DWORD cbSize;
  343. /* Version info of this specification. */
  344. DWORD dwVersion;
  345. /* Point during request processing where the extension is being invoked. */
  346. RADIUS_EXTENSION_POINT repPoint;
  347. /* Type of RADIUS request being processed. */
  348. RADIUS_CODE rcRequestType;
  349. /*
  350. * Final disposition of the request. This field must not be modified
  351. * directly; use the SetResponseType callback function instead. At the
  352. * repAuthentication point, this may be set to rcUnknown to indicate that no
  353. * decision has been made yet.
  354. */
  355. RADIUS_CODE rcResponseType;
  356. /*
  357. * Returns the attributes received in the RADIUS request and any internal
  358. * attributes describing the request state. The extenstion can modify the
  359. * request attributes. For example, when IAS is acting as a RADIUS proxy, an
  360. * extension could filter which attributes are forwarded to a remote RADIUS
  361. * server.
  362. */
  363. PRADIUS_ATTRIBUTE_ARRAY (WINAPI *GetRequest)(
  364. IN struct _RADIUS_EXTENSION_CONTROL_BLOCK *This
  365. );
  366. /*
  367. * Returns the attributes that will be sent in the response if the final
  368. * outcome of request processing matches the specified response type.
  369. * Returns NULL if rcResponseType is invalid. Note that an extension may
  370. * retrieve and modify the attributes for any valid response type regardless
  371. * of the request's current disposition. For example, an extension can set
  372. * the response type to rcAccessAccept, but still add attributes to the
  373. * Access-Reject in case the response type is overridden during further
  374. * processing.
  375. */
  376. PRADIUS_ATTRIBUTE_ARRAY (WINAPI *GetResponse)(
  377. IN struct _RADIUS_EXTENSION_CONTROL_BLOCK *This,
  378. IN RADIUS_CODE rcResponseType
  379. );
  380. /*
  381. * Sets the final disposition of the request.
  382. * Returns ERROR_INVALID_PARAMETER if the specified response type is invalid
  383. * for the request type.
  384. */
  385. DWORD (WINAPI *SetResponseType)(
  386. IN struct _RADIUS_EXTENSION_CONTROL_BLOCK *This,
  387. IN RADIUS_CODE rcResponseType
  388. );
  389. } RADIUS_EXTENSION_CONTROL_BLOCK, *PRADIUS_EXTENSION_CONTROL_BLOCK;
  390. /*
  391. * If RadiusExtensionProcess2 exists, RadiusExtensionProcess and
  392. * RadiusExtensionProcessEx are ignored.
  393. *
  394. * Parameters:
  395. * pECB Info exchanged with the extension.
  396. *
  397. * Return Value:
  398. * A return value other than NO_ERROR causes the request to be discarded.
  399. */
  400. #define RADIUS_EXTENSION_PROCESS2 "RadiusExtensionProcess2"
  401. typedef DWORD (WINAPI *PRADIUS_EXTENSION_PROCESS_2)(
  402. IN OUT PRADIUS_EXTENSION_CONTROL_BLOCK pECB
  403. );
  404. #endif // _WIN32_WINNT
  405. #endif /* _AUTHIF_H_ */