Source code of Windows XP (NT5)
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.

1006 lines
24 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. wincred.h
  5. Abstract:
  6. This module contains the public data structures and API definitions
  7. needed for the Credential Manager.
  8. Author:
  9. Cliff Van Dyke (CliffV) 11-January-2000
  10. Revision History:
  11. --*/
  12. #ifndef _WINCRED_H_
  13. #define _WINCRED_H_
  14. #if !defined(_ADVAPI32_)
  15. #define WINADVAPI DECLSPEC_IMPORT
  16. #else
  17. #define WINADVAPI
  18. #endif
  19. #if !defined(CREDUIAPI)
  20. #if !defined(_CREDUI_)
  21. #define CREDUIAPI DECLSPEC_IMPORT
  22. #else
  23. #define CREDUIAPI
  24. #endif
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. //
  30. // Ensure PCtxtHandle is defined
  31. //
  32. #ifndef __SECHANDLE_DEFINED__
  33. typedef struct _SecHandle
  34. {
  35. ULONG_PTR dwLower ;
  36. ULONG_PTR dwUpper ;
  37. } SecHandle, * PSecHandle ;
  38. #define __SECHANDLE_DEFINED__
  39. #endif // __SECHANDLE_DEFINED__
  40. typedef PSecHandle PCtxtHandle;
  41. //
  42. // Ensure FILETIME is defined
  43. //
  44. #ifndef _WINBASE_
  45. #ifndef _FILETIME_
  46. #define _FILETIME_
  47. typedef struct _FILETIME
  48. {
  49. DWORD dwLowDateTime;
  50. DWORD dwHighDateTime;
  51. } FILETIME;
  52. typedef struct _FILETIME *PFILETIME;
  53. typedef struct _FILETIME *LPFILETIME;
  54. #endif // !_FILETIME
  55. #endif // _WINBASE_
  56. //
  57. // Ensure NTSTATUS is defined
  58. //
  59. #ifndef _NTDEF_
  60. typedef LONG NTSTATUS, *PNTSTATUS;
  61. #endif
  62. //-----------------------------------------------------------------------------
  63. // Macros
  64. //-----------------------------------------------------------------------------
  65. //
  66. // Macro to determine whether CredUIPromptForCredentials should be called upon a failed
  67. // authentication attempt.
  68. //
  69. // Implemented as a macro so that the caller can delay load credui.dll only if this
  70. // macro returns TRUE.
  71. //
  72. // Include only status codes that imply the username/password are wrong or that the
  73. // password is expired. In the former case, asking for a another username or password
  74. // is appropriate. In the later case, we put up a different dialog asking the
  75. // user to change the password on the server.
  76. //
  77. // Don't include status codes such as ERROR_ACCOUNT_DISABLED, ERROR_ACCOUNT_RESTRICTION,
  78. // ERROR_ACCOUNT_LOCKED_OUT, ERROR_ACCOUNT_EXPIRED, ERROR_LOGON_TYPE_NOT_GRANTED.
  79. // For those, the user isn't going to have another account so prompting him
  80. // won't help.
  81. //
  82. // STATUS_DOWNGRADE_DETECTED is included to handle the case where a corporate laptop
  83. // is brought to another LAN. A downgrade attack will indeed be detected,
  84. // but we want to popup UI to allow the user to connect to resources in the
  85. // other LAN.
  86. //
  87. // Don't use the CREDUIP_* macros directly. Their definition is private to credui.dll.
  88. //
  89. // Don't require ntstatus.h
  90. #define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006DL) // ntsubauth
  91. #define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006AL) // ntsubauth
  92. #define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L) // ntsubauth
  93. #define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS)0xC0000224L) // ntsubauth
  94. #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
  95. #define STATUS_DOWNGRADE_DETECTED ((NTSTATUS)0xC0000388L)
  96. // Don't require lmerr.h
  97. #define NERR_BASE 2100
  98. #define NERR_PasswordExpired (NERR_BASE+142) /* The password of this user has expired. */
  99. #define CREDUIP_IS_USER_PASSWORD_ERROR( _Status ) ( \
  100. (_Status) == ERROR_LOGON_FAILURE || \
  101. (_Status) == HRESULT_FROM_WIN32( ERROR_LOGON_FAILURE ) || \
  102. (_Status) == STATUS_LOGON_FAILURE || \
  103. (_Status) == HRESULT_FROM_NT( STATUS_LOGON_FAILURE ) || \
  104. (_Status) == ERROR_ACCESS_DENIED || \
  105. (_Status) == HRESULT_FROM_WIN32( ERROR_ACCESS_DENIED ) || \
  106. (_Status) == STATUS_ACCESS_DENIED || \
  107. (_Status) == HRESULT_FROM_NT( STATUS_ACCESS_DENIED ) || \
  108. (_Status) == ERROR_INVALID_PASSWORD || \
  109. (_Status) == HRESULT_FROM_WIN32( ERROR_INVALID_PASSWORD ) || \
  110. (_Status) == STATUS_WRONG_PASSWORD || \
  111. (_Status) == HRESULT_FROM_NT( STATUS_WRONG_PASSWORD ) || \
  112. (_Status) == SEC_E_NO_CREDENTIALS || \
  113. (_Status) == SEC_E_LOGON_DENIED \
  114. )
  115. #define CREDUIP_IS_DOWNGRADE_ERROR( _Status ) ( \
  116. (_Status) == ERROR_DOWNGRADE_DETECTED || \
  117. (_Status) == HRESULT_FROM_WIN32( ERROR_DOWNGRADE_DETECTED ) || \
  118. (_Status) == STATUS_DOWNGRADE_DETECTED || \
  119. (_Status) == HRESULT_FROM_NT( STATUS_DOWNGRADE_DETECTED ) \
  120. )
  121. #define CREDUIP_IS_EXPIRED_ERROR( _Status ) ( \
  122. (_Status) == ERROR_PASSWORD_EXPIRED || \
  123. (_Status) == HRESULT_FROM_WIN32( ERROR_PASSWORD_EXPIRED ) || \
  124. (_Status) == STATUS_PASSWORD_EXPIRED || \
  125. (_Status) == HRESULT_FROM_NT( STATUS_PASSWORD_EXPIRED ) || \
  126. (_Status) == ERROR_PASSWORD_MUST_CHANGE || \
  127. (_Status) == HRESULT_FROM_WIN32( ERROR_PASSWORD_MUST_CHANGE ) || \
  128. (_Status) == STATUS_PASSWORD_MUST_CHANGE || \
  129. (_Status) == HRESULT_FROM_NT( STATUS_PASSWORD_MUST_CHANGE ) || \
  130. (_Status) == NERR_PasswordExpired || \
  131. (_Status) == HRESULT_FROM_WIN32( NERR_PasswordExpired ) \
  132. )
  133. #define CREDUI_IS_AUTHENTICATION_ERROR( _Status ) ( \
  134. CREDUIP_IS_USER_PASSWORD_ERROR( _Status ) || \
  135. CREDUIP_IS_DOWNGRADE_ERROR( _Status ) || \
  136. CREDUIP_IS_EXPIRED_ERROR( _Status ) \
  137. )
  138. //-----------------------------------------------------------------------------
  139. // Structures
  140. //-----------------------------------------------------------------------------
  141. //
  142. // Credential Attribute
  143. //
  144. // Maximum length of the various credential string fields (in characters)
  145. #define CRED_MAX_STRING_LENGTH 256
  146. // Maximum length of the UserName field. The worst case is <User>@<DnsDomain>
  147. #define CRED_MAX_USERNAME_LENGTH (256+1+256)
  148. // Maximum length of the TargetName field for CRED_TYPE_GENERIC (in characters)
  149. #define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767
  150. // Maximum length of the TargetName field for CRED_TYPE_DOMAIN_* (in characters)
  151. // Largest one is <DfsRoot>\<DfsShare>
  152. #define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH (256+1+80)
  153. // Maximum size of the Credential Attribute Value field (in bytes)
  154. #define CRED_MAX_VALUE_SIZE 256
  155. // Maximum number of attributes per credential
  156. #define CRED_MAX_ATTRIBUTES 64
  157. typedef struct _CREDENTIAL_ATTRIBUTEA {
  158. LPSTR Keyword;
  159. DWORD Flags;
  160. DWORD ValueSize;
  161. LPBYTE Value;
  162. } CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA;
  163. typedef struct _CREDENTIAL_ATTRIBUTEW {
  164. #ifdef MIDL_PASS
  165. [string] wchar_t * Keyword;
  166. #else // MIDL_PASS
  167. LPWSTR Keyword;
  168. #endif // MIDL_PASS
  169. DWORD Flags;
  170. DWORD ValueSize;
  171. #ifdef MIDL_PASS
  172. [size_is(ValueSize)]
  173. #endif // MIDL_PASS
  174. LPBYTE Value;
  175. } CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
  176. #ifdef UNICODE
  177. typedef CREDENTIAL_ATTRIBUTEW CREDENTIAL_ATTRIBUTE;
  178. typedef PCREDENTIAL_ATTRIBUTEW PCREDENTIAL_ATTRIBUTE;
  179. #else
  180. typedef CREDENTIAL_ATTRIBUTEA CREDENTIAL_ATTRIBUTE;
  181. typedef PCREDENTIAL_ATTRIBUTEA PCREDENTIAL_ATTRIBUTE;
  182. #endif // UNICODE
  183. //
  184. // Special values of the TargetName field
  185. //
  186. #define CRED_SESSION_WILDCARD_NAME_W L"*Session"
  187. #define CRED_SESSION_WILDCARD_NAME_A "*Session"
  188. #define CRED_SESSION_WILDCARD_NAME_LENGTH (sizeof(CRED_SESSION_WILDCARD_NAME_A)-1)
  189. #ifdef UNICODE
  190. #define CRED_SESSION_WILDCARD_NAME CRED_SESSION_WILDCARD_NAME_W
  191. #else
  192. #define CRED_SESSION_WILDCARD_NAME CRED_SESSION_WILDCARD_NAME_A
  193. #endif // UNICODE
  194. //
  195. // Values of the Credential Flags field.
  196. //
  197. #define CRED_FLAGS_PROMPT_NOW 0x0002
  198. #define CRED_FLAGS_USERNAME_TARGET 0x0004
  199. #define CRED_FLAGS_PERSIST_CRED_BLOB 0x0008
  200. #define CRED_FLAGS_VALID_FLAGS 0x000E // Mask of all valid flags
  201. //
  202. // Values of the Credential Type field.
  203. //
  204. #define CRED_TYPE_GENERIC 1
  205. #define CRED_TYPE_DOMAIN_PASSWORD 2
  206. #define CRED_TYPE_DOMAIN_CERTIFICATE 3
  207. #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4
  208. #define CRED_TYPE_MAXIMUM 5 // Maximum supported cred type
  209. //
  210. // Maximum size of the CredBlob field (in bytes)
  211. //
  212. #define CRED_MAX_CREDENTIAL_BLOB_SIZE 512
  213. //
  214. // Values of the Credential Persist field
  215. //
  216. #define CRED_PERSIST_NONE 0
  217. #define CRED_PERSIST_SESSION 1
  218. #define CRED_PERSIST_LOCAL_MACHINE 2
  219. #define CRED_PERSIST_ENTERPRISE 3
  220. //
  221. // A credential
  222. //
  223. typedef struct _CREDENTIALA {
  224. DWORD Flags;
  225. DWORD Type;
  226. LPSTR TargetName;
  227. LPSTR Comment;
  228. FILETIME LastWritten;
  229. DWORD CredentialBlobSize;
  230. LPBYTE CredentialBlob;
  231. DWORD Persist;
  232. DWORD AttributeCount;
  233. PCREDENTIAL_ATTRIBUTEA Attributes;
  234. LPSTR TargetAlias;
  235. LPSTR UserName;
  236. } CREDENTIALA, *PCREDENTIALA;
  237. typedef struct _CREDENTIALW {
  238. DWORD Flags;
  239. DWORD Type;
  240. #ifdef MIDL_PASS
  241. [string] wchar_t *TargetName;
  242. #else // MIDL_PASS
  243. LPWSTR TargetName;
  244. #endif // MIDL_PASS
  245. #ifdef MIDL_PASS
  246. [string] wchar_t *Comment;
  247. #else // MIDL_PASS
  248. LPWSTR Comment;
  249. #endif // MIDL_PASS
  250. FILETIME LastWritten;
  251. DWORD CredentialBlobSize;
  252. #ifdef MIDL_PASS
  253. [size_is(CredentialBlobSize)]
  254. #endif // MIDL_PASS
  255. LPBYTE CredentialBlob;
  256. DWORD Persist;
  257. DWORD AttributeCount;
  258. #ifdef MIDL_PASS
  259. [size_is(AttributeCount)]
  260. #endif // MIDL_PASS
  261. PCREDENTIAL_ATTRIBUTEW Attributes;
  262. #ifdef MIDL_PASS
  263. [string] wchar_t *TargetAlias;
  264. #else // MIDL_PASS
  265. LPWSTR TargetAlias;
  266. #endif // MIDL_PASS
  267. #ifdef MIDL_PASS
  268. [string] wchar_t *UserName;
  269. #else // MIDL_PASS
  270. LPWSTR UserName;
  271. #endif // MIDL_PASS
  272. } CREDENTIALW, *PCREDENTIALW;
  273. #ifdef UNICODE
  274. typedef CREDENTIALW CREDENTIAL;
  275. typedef PCREDENTIALW PCREDENTIAL;
  276. #else
  277. typedef CREDENTIALA CREDENTIAL;
  278. typedef PCREDENTIALA PCREDENTIAL;
  279. #endif // UNICODE
  280. //
  281. // Value of the Flags field in CREDENTIAL_TARGET_INFORMATION
  282. //
  283. #define CRED_TI_SERVER_FORMAT_UNKNOWN 0x0001 // Don't know if server name is DNS or netbios format
  284. #define CRED_TI_DOMAIN_FORMAT_UNKNOWN 0x0002 // Don't know if domain name is DNS or netbios format
  285. #define CRED_TI_ONLY_PASSWORD_REQUIRED 0x0004 // Server only requires a password and not a username
  286. #define CRED_TI_USERNAME_TARGET 0x0008 // TargetName is username
  287. #define CRED_TI_CREATE_EXPLICIT_CRED 0x0010 // When creating a cred, create one named TargetInfo->TargetName
  288. #define CRED_TI_WORKGROUP_MEMBER 0x0020 // Indicates the machine is a member of a workgroup
  289. #define CRED_TI_VALID_FLAGS 0x003F
  290. //
  291. // A credential target
  292. //
  293. typedef struct _CREDENTIAL_TARGET_INFORMATIONA {
  294. LPSTR TargetName;
  295. LPSTR NetbiosServerName;
  296. LPSTR DnsServerName;
  297. LPSTR NetbiosDomainName;
  298. LPSTR DnsDomainName;
  299. LPSTR DnsTreeName;
  300. LPSTR PackageName;
  301. ULONG Flags;
  302. DWORD CredTypeCount;
  303. LPDWORD CredTypes;
  304. } CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA;
  305. typedef struct _CREDENTIAL_TARGET_INFORMATIONW {
  306. #ifdef MIDL_PASS
  307. [string] wchar_t *TargetName;
  308. [string] wchar_t *NetbiosServerName;
  309. [string] wchar_t *DnsServerName;
  310. [string] wchar_t *NetbiosDomainName;
  311. [string] wchar_t *DnsDomainName;
  312. [string] wchar_t *DnsTreeName;
  313. [string] wchar_t *PackageName;
  314. #else // MIDL_PASS
  315. LPWSTR TargetName;
  316. LPWSTR NetbiosServerName;
  317. LPWSTR DnsServerName;
  318. LPWSTR NetbiosDomainName;
  319. LPWSTR DnsDomainName;
  320. LPWSTR DnsTreeName;
  321. LPWSTR PackageName;
  322. #endif // MIDL_PASS
  323. ULONG Flags;
  324. DWORD CredTypeCount;
  325. LPDWORD CredTypes;
  326. } CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW;
  327. #ifdef UNICODE
  328. typedef CREDENTIAL_TARGET_INFORMATIONW CREDENTIAL_TARGET_INFORMATION;
  329. typedef PCREDENTIAL_TARGET_INFORMATIONW PCREDENTIAL_TARGET_INFORMATION;
  330. #else
  331. typedef CREDENTIAL_TARGET_INFORMATIONA CREDENTIAL_TARGET_INFORMATION;
  332. typedef PCREDENTIAL_TARGET_INFORMATIONA PCREDENTIAL_TARGET_INFORMATION;
  333. #endif // UNICODE
  334. //
  335. // Certificate credential information
  336. //
  337. // The cbSize should be the size of the structure, sizeof(CERT_CREDENTIAL_INFO),
  338. // rgbHashofCert is the hash of the cert which is to be used as the credential.
  339. //
  340. #define CERT_HASH_LENGTH 20 // SHA1 hashes are used for cert hashes
  341. typedef struct _CERT_CREDENTIAL_INFO {
  342. ULONG cbSize;
  343. UCHAR rgbHashOfCert[CERT_HASH_LENGTH];
  344. } CERT_CREDENTIAL_INFO, *PCERT_CREDENTIAL_INFO;
  345. //
  346. // Username Target credential information
  347. //
  348. // This credential can be pass to LsaLogonUser to ask it to find a credential with a
  349. // TargetName of UserName.
  350. //
  351. typedef struct _USERNAME_TARGET_CREDENTIAL_INFO {
  352. LPWSTR UserName;
  353. } USERNAME_TARGET_CREDENTIAL_INFO, *PUSERNAME_TARGET_CREDENTIAL_INFO;
  354. //
  355. // Credential type for credential marshaling routines
  356. //
  357. typedef enum _CRED_MARSHAL_TYPE {
  358. CertCredential = 1,
  359. UsernameTargetCredential
  360. } CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE;
  361. //
  362. // Credential UI info
  363. //
  364. typedef struct _CREDUI_INFOA
  365. {
  366. DWORD cbSize;
  367. HWND hwndParent;
  368. PCSTR pszMessageText;
  369. PCSTR pszCaptionText;
  370. HBITMAP hbmBanner;
  371. } CREDUI_INFOA, *PCREDUI_INFOA;
  372. typedef struct _CREDUI_INFOW
  373. {
  374. DWORD cbSize;
  375. HWND hwndParent;
  376. PCWSTR pszMessageText;
  377. PCWSTR pszCaptionText;
  378. HBITMAP hbmBanner;
  379. } CREDUI_INFOW, *PCREDUI_INFOW;
  380. #ifdef UNICODE
  381. typedef CREDUI_INFOW CREDUI_INFO;
  382. typedef PCREDUI_INFOW PCREDUI_INFO;
  383. #else
  384. typedef CREDUI_INFOA CREDUI_INFO;
  385. typedef PCREDUI_INFOA PCREDUI_INFO;
  386. #endif
  387. //-----------------------------------------------------------------------------
  388. // Values
  389. //-----------------------------------------------------------------------------
  390. // String length limits:
  391. #define CREDUI_MAX_MESSAGE_LENGTH 32767
  392. #define CREDUI_MAX_CAPTION_LENGTH 128
  393. #define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH
  394. #define CREDUI_MAX_DOMAIN_TARGET_LENGTH (CRED_MAX_STRING_LENGTH + NNLEN)
  395. #define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH
  396. #define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2)
  397. //
  398. // Flags for CredUIPromptForCredentials and/or CredUICmdLinePromptForCredentials
  399. //
  400. #define CREDUI_FLAGS_INCORRECT_PASSWORD 0x00001 // indicates the username is valid, but password is not
  401. #define CREDUI_FLAGS_DO_NOT_PERSIST 0x00002 // Do not show "Save" checkbox, and do not persist credentials
  402. #define CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00004 // Populate list box with admin accounts
  403. #define CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00008 // do not include certificates in the drop list
  404. #define CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00010
  405. #define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00040
  406. #define CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00080
  407. #define CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00100
  408. #define CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00200
  409. #define CREDUI_FLAGS_VALIDATE_USERNAME 0x00400
  410. #define CREDUI_FLAGS_COMPLETE_USERNAME 0x00800 //
  411. #define CREDUI_FLAGS_PERSIST 0x01000 // Do not show "Save" checkbox, but persist credentials anyway
  412. #define CREDUI_FLAGS_SERVER_CREDENTIAL 0x04000
  413. #define CREDUI_FLAGS_EXPECT_CONFIRMATION 0x20000 // do not persist unless caller later confirms credential via CredUIConfirmCredential() api
  414. #define CREDUI_FLAGS_GENERIC_CREDENTIALS 0x40000 // Credential is a generic credential
  415. #define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x80000 // Credential has a username as the target
  416. #define CREDUI_FLAGS_KEEP_USERNAME 0x100000 // don't allow the user to change the supplied username
  417. //
  418. // Mask of flags valid for CredUIPromptForCredentials
  419. //
  420. #define CREDUI_FLAGS_PROMPT_VALID ( \
  421. CREDUI_FLAGS_INCORRECT_PASSWORD | \
  422. CREDUI_FLAGS_DO_NOT_PERSIST | \
  423. CREDUI_FLAGS_REQUEST_ADMINISTRATOR | \
  424. CREDUI_FLAGS_EXCLUDE_CERTIFICATES | \
  425. CREDUI_FLAGS_REQUIRE_CERTIFICATE | \
  426. CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX | \
  427. CREDUI_FLAGS_ALWAYS_SHOW_UI | \
  428. CREDUI_FLAGS_REQUIRE_SMARTCARD | \
  429. CREDUI_FLAGS_PASSWORD_ONLY_OK | \
  430. CREDUI_FLAGS_VALIDATE_USERNAME | \
  431. CREDUI_FLAGS_COMPLETE_USERNAME | \
  432. CREDUI_FLAGS_PERSIST | \
  433. CREDUI_FLAGS_SERVER_CREDENTIAL | \
  434. CREDUI_FLAGS_EXPECT_CONFIRMATION | \
  435. CREDUI_FLAGS_GENERIC_CREDENTIALS | \
  436. CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS | \
  437. CREDUI_FLAGS_KEEP_USERNAME )
  438. //-----------------------------------------------------------------------------
  439. // Functions
  440. //-----------------------------------------------------------------------------
  441. //
  442. // Values of flags to CredWrite and CredWriteDomainCredentials
  443. //
  444. #define CRED_PRESERVE_CREDENTIAL_BLOB 0x1
  445. WINADVAPI
  446. BOOL
  447. WINAPI
  448. CredWriteW (
  449. IN PCREDENTIALW Credential,
  450. IN DWORD Flags
  451. );
  452. WINADVAPI
  453. BOOL
  454. WINAPI
  455. CredWriteA (
  456. IN PCREDENTIALA Credential,
  457. IN DWORD Flags
  458. );
  459. #ifdef UNICODE
  460. #define CredWrite CredWriteW
  461. #else
  462. #define CredWrite CredWriteA
  463. #endif // UNICODE
  464. WINADVAPI
  465. BOOL
  466. WINAPI
  467. CredReadW (
  468. IN LPCWSTR TargetName,
  469. IN DWORD Type,
  470. IN DWORD Flags,
  471. OUT PCREDENTIALW *Credential
  472. );
  473. WINADVAPI
  474. BOOL
  475. WINAPI
  476. CredReadA (
  477. IN LPCSTR TargetName,
  478. IN DWORD Type,
  479. IN DWORD Flags,
  480. OUT PCREDENTIALA *Credential
  481. );
  482. #ifdef UNICODE
  483. #define CredRead CredReadW
  484. #else
  485. #define CredRead CredReadA
  486. #endif // UNICODE
  487. WINADVAPI
  488. BOOL
  489. WINAPI
  490. CredEnumerateW (
  491. IN LPCWSTR Filter,
  492. IN DWORD Flags,
  493. OUT DWORD *Count,
  494. OUT PCREDENTIALW **Credential
  495. );
  496. WINADVAPI
  497. BOOL
  498. WINAPI
  499. CredEnumerateA (
  500. IN LPCSTR Filter,
  501. IN DWORD Flags,
  502. OUT DWORD *Count,
  503. OUT PCREDENTIALA **Credential
  504. );
  505. #ifdef UNICODE
  506. #define CredEnumerate CredEnumerateW
  507. #else
  508. #define CredEnumerate CredEnumerateA
  509. #endif // UNICODE
  510. WINADVAPI
  511. BOOL
  512. WINAPI
  513. CredWriteDomainCredentialsW (
  514. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  515. IN PCREDENTIALW Credential,
  516. IN DWORD Flags
  517. );
  518. WINADVAPI
  519. BOOL
  520. WINAPI
  521. CredWriteDomainCredentialsA (
  522. IN PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,
  523. IN PCREDENTIALA Credential,
  524. IN DWORD Flags
  525. );
  526. #ifdef UNICODE
  527. #define CredWriteDomainCredentials CredWriteDomainCredentialsW
  528. #else
  529. #define CredWriteDomainCredentials CredWriteDomainCredentialsA
  530. #endif // UNICODE
  531. //
  532. // Values of flags to CredReadDomainCredentials
  533. //
  534. #define CRED_CACHE_TARGET_INFORMATION 0x1
  535. WINADVAPI
  536. BOOL
  537. WINAPI
  538. CredReadDomainCredentialsW (
  539. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  540. IN DWORD Flags,
  541. OUT DWORD *Count,
  542. OUT PCREDENTIALW **Credential
  543. );
  544. WINADVAPI
  545. BOOL
  546. WINAPI
  547. CredReadDomainCredentialsA (
  548. IN PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,
  549. IN DWORD Flags,
  550. OUT DWORD *Count,
  551. OUT PCREDENTIALA **Credential
  552. );
  553. #ifdef UNICODE
  554. #define CredReadDomainCredentials CredReadDomainCredentialsW
  555. #else
  556. #define CredReadDomainCredentials CredReadDomainCredentialsA
  557. #endif // UNICODE
  558. WINADVAPI
  559. BOOL
  560. WINAPI
  561. CredDeleteW (
  562. IN LPCWSTR TargetName,
  563. IN DWORD Type,
  564. IN DWORD Flags
  565. );
  566. WINADVAPI
  567. BOOL
  568. WINAPI
  569. CredDeleteA (
  570. IN LPCSTR TargetName,
  571. IN DWORD Type,
  572. IN DWORD Flags
  573. );
  574. #ifdef UNICODE
  575. #define CredDelete CredDeleteW
  576. #else
  577. #define CredDelete CredDeleteA
  578. #endif // UNICODE
  579. WINADVAPI
  580. BOOL
  581. WINAPI
  582. CredRenameW (
  583. IN LPCWSTR OldTargetName,
  584. IN LPCWSTR NewTargetName,
  585. IN DWORD Type,
  586. IN DWORD Flags
  587. );
  588. WINADVAPI
  589. BOOL
  590. WINAPI
  591. CredRenameA (
  592. IN LPCSTR OldTargetName,
  593. IN LPCSTR NewTargetName,
  594. IN DWORD Type,
  595. IN DWORD Flags
  596. );
  597. #ifdef UNICODE
  598. #define CredRename CredRenameW
  599. #else
  600. #define CredRename CredRenameA
  601. #endif // UNICODE
  602. //
  603. // Values of flags to CredGetTargetInfo
  604. //
  605. #define CRED_ALLOW_NAME_RESOLUTION 0x1
  606. WINADVAPI
  607. BOOL
  608. WINAPI
  609. CredGetTargetInfoW (
  610. IN LPCWSTR TargetName,
  611. IN DWORD Flags,
  612. OUT PCREDENTIAL_TARGET_INFORMATIONW *TargetInfo
  613. );
  614. WINADVAPI
  615. BOOL
  616. WINAPI
  617. CredGetTargetInfoA (
  618. IN LPCSTR TargetName,
  619. IN DWORD Flags,
  620. OUT PCREDENTIAL_TARGET_INFORMATIONA *TargetInfo
  621. );
  622. #ifdef UNICODE
  623. #define CredGetTargetInfo CredGetTargetInfoW
  624. #else
  625. #define CredGetTargetInfo CredGetTargetInfoA
  626. #endif // UNICODE
  627. WINADVAPI
  628. BOOL
  629. WINAPI
  630. CredMarshalCredentialW(
  631. IN CRED_MARSHAL_TYPE CredType,
  632. IN PVOID Credential,
  633. OUT LPWSTR *MarshaledCredential
  634. );
  635. WINADVAPI
  636. BOOL
  637. WINAPI
  638. CredMarshalCredentialA(
  639. IN CRED_MARSHAL_TYPE CredType,
  640. IN PVOID Credential,
  641. OUT LPSTR *MarshaledCredential
  642. );
  643. #ifdef UNICODE
  644. #define CredMarshalCredential CredMarshalCredentialW
  645. #else
  646. #define CredMarshalCredential CredMarshalCredentialA
  647. #endif // UNICODE
  648. WINADVAPI
  649. BOOL
  650. WINAPI
  651. CredUnmarshalCredentialW(
  652. IN LPCWSTR MarshaledCredential,
  653. OUT PCRED_MARSHAL_TYPE CredType,
  654. OUT PVOID *Credential
  655. );
  656. WINADVAPI
  657. BOOL
  658. WINAPI
  659. CredUnmarshalCredentialA(
  660. IN LPCSTR MarshaledCredential,
  661. OUT PCRED_MARSHAL_TYPE CredType,
  662. OUT PVOID *Credential
  663. );
  664. #ifdef UNICODE
  665. #define CredUnmarshalCredential CredUnmarshalCredentialW
  666. #else
  667. #define CredUnmarshalCredential CredUnmarshalCredentialA
  668. #endif // UNICODE
  669. WINADVAPI
  670. BOOL
  671. WINAPI
  672. CredIsMarshaledCredentialW(
  673. IN LPCWSTR MarshaledCredential
  674. );
  675. WINADVAPI
  676. BOOL
  677. WINAPI
  678. CredIsMarshaledCredentialA(
  679. IN LPCSTR MarshaledCredential
  680. );
  681. #ifdef UNICODE
  682. #define CredIsMarshaledCredential CredIsMarshaledCredentialW
  683. #else
  684. #define CredIsMarshaledCredential CredIsMarshaledCredentialA
  685. #endif // UNICODE
  686. WINADVAPI
  687. BOOL
  688. WINAPI
  689. CredGetSessionTypes (
  690. IN DWORD MaximumPersistCount,
  691. OUT LPDWORD MaximumPersist
  692. );
  693. WINADVAPI
  694. VOID
  695. WINAPI
  696. CredFree (
  697. IN PVOID Buffer
  698. );
  699. CREDUIAPI
  700. DWORD
  701. WINAPI
  702. CredUIPromptForCredentialsW(
  703. PCREDUI_INFOW pUiInfo,
  704. PCWSTR pszTargetName,
  705. PCtxtHandle pContext,
  706. DWORD dwAuthError,
  707. PWSTR pszUserName,
  708. ULONG ulUserNameBufferSize,
  709. PWSTR pszPassword,
  710. ULONG ulPasswordBufferSize,
  711. BOOL *save,
  712. DWORD dwFlags
  713. );
  714. CREDUIAPI
  715. DWORD
  716. WINAPI
  717. CredUIPromptForCredentialsA(
  718. PCREDUI_INFOA pUiInfo,
  719. PCSTR pszTargetName,
  720. PCtxtHandle pContext,
  721. DWORD dwAuthError,
  722. PSTR pszUserName,
  723. ULONG ulUserNameBufferSize,
  724. PSTR pszPassword,
  725. ULONG ulPasswordBufferSize,
  726. BOOL *save,
  727. DWORD dwFlags
  728. );
  729. #ifdef UNICODE
  730. #define CredUIPromptForCredentials CredUIPromptForCredentialsW
  731. #else
  732. #define CredUIPromptForCredentials CredUIPromptForCredentialsA
  733. #endif
  734. CREDUIAPI
  735. DWORD
  736. WINAPI
  737. CredUIParseUserNameW(
  738. PCWSTR pszUserName,
  739. PWSTR pszUser,
  740. ULONG ulUserBufferSize,
  741. PWSTR pszDomain,
  742. ULONG ulDomainBufferSize
  743. );
  744. CREDUIAPI
  745. DWORD
  746. WINAPI
  747. CredUIParseUserNameA(
  748. PCSTR pszUserName,
  749. PSTR pszUser,
  750. ULONG ulUserBufferSize,
  751. PSTR pszDomain,
  752. ULONG ulDomainBufferSize
  753. );
  754. #ifdef UNICODE
  755. #define CredUIParseUserName CredUIParseUserNameW
  756. #else
  757. #define CredUIParseUserName CredUIParseUserNameA
  758. #endif
  759. CREDUIAPI
  760. DWORD
  761. WINAPI
  762. CredUICmdLinePromptForCredentialsW(
  763. PCWSTR pszTargetName,
  764. PCtxtHandle pContext,
  765. DWORD dwAuthError,
  766. PWSTR UserName,
  767. ULONG ulUserBufferSize,
  768. PWSTR pszPassword,
  769. ULONG ulPasswordBufferSize,
  770. PBOOL pfSave,
  771. DWORD dwFlags
  772. );
  773. CREDUIAPI
  774. DWORD
  775. WINAPI
  776. CredUICmdLinePromptForCredentialsA(
  777. PCSTR pszTargetName,
  778. PCtxtHandle pContext,
  779. DWORD dwAuthError,
  780. PSTR UserName,
  781. ULONG ulUserBufferSize,
  782. PSTR pszPassword,
  783. ULONG ulPasswordBufferSize,
  784. PBOOL pfSave,
  785. DWORD dwFlags
  786. );
  787. #ifdef UNICODE
  788. #define CredUICmdLinePromptForCredentials CredUICmdLinePromptForCredentialsW
  789. #else
  790. #define CredUICmdLinePromptForCredentials CredUICmdLinePromptForCredentialsA
  791. #endif
  792. //
  793. // Call this API with bConfirm set to TRUE to confirm that the credential (previously created
  794. // via CredUIGetCredentials or CredUIPromptForCredentials worked, or with bConfirm set to FALSE
  795. // to indicate it didn't
  796. CREDUIAPI
  797. DWORD
  798. WINAPI
  799. CredUIConfirmCredentialsW(
  800. PCWSTR pszTargetName,
  801. BOOL bConfirm
  802. );
  803. CREDUIAPI
  804. DWORD
  805. WINAPI
  806. CredUIConfirmCredentialsA(
  807. PCSTR pszTargetName,
  808. BOOL bConfirm
  809. );
  810. #ifdef UNICODE
  811. #define CredUIConfirmCredentials CredUIConfirmCredentialsW
  812. #else
  813. #define CredUIConfirmCredentials CredUIConfirmCredentialsA
  814. #endif
  815. CREDUIAPI
  816. DWORD
  817. WINAPI
  818. CredUIStoreSSOCredW (
  819. PCWSTR pszRealm,
  820. PCWSTR pszUsername,
  821. PCWSTR pszPassword,
  822. BOOL bPersist
  823. );
  824. CREDUIAPI
  825. DWORD
  826. WINAPI
  827. CredUIReadSSOCredW (
  828. PCWSTR pszRealm,
  829. PWSTR* ppszUsername
  830. );
  831. #ifdef __cplusplus
  832. }
  833. #endif
  834. #endif // _WINCRED_H_