wincred.h 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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_PASSWORD_FOR_CERT 0x0001
  198. #define CRED_FLAGS_PROMPT_NOW 0x0002
  199. #define CRED_FLAGS_USERNAME_TARGET 0x0004
  200. #define CRED_FLAGS_OWF_CRED_BLOB 0x0008
  201. #define CRED_FLAGS_VALID_FLAGS 0x000F // Mask of all valid flags
  202. //
  203. // Values of the Credential Type field.
  204. //
  205. #define CRED_TYPE_GENERIC 1
  206. #define CRED_TYPE_DOMAIN_PASSWORD 2
  207. #define CRED_TYPE_DOMAIN_CERTIFICATE 3
  208. #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4
  209. #define CRED_TYPE_MAXIMUM 5 // Maximum supported cred type
  210. //
  211. // Maximum size of the CredBlob field (in bytes)
  212. //
  213. #define CRED_MAX_CREDENTIAL_BLOB_SIZE 512
  214. //
  215. // Values of the Credential Persist field
  216. //
  217. #define CRED_PERSIST_NONE 0
  218. #define CRED_PERSIST_SESSION 1
  219. #define CRED_PERSIST_LOCAL_MACHINE 2
  220. #define CRED_PERSIST_ENTERPRISE 3
  221. //
  222. // A credential
  223. //
  224. typedef struct _CREDENTIALA {
  225. DWORD Flags;
  226. DWORD Type;
  227. LPSTR TargetName;
  228. LPSTR Comment;
  229. FILETIME LastWritten;
  230. DWORD CredentialBlobSize;
  231. LPBYTE CredentialBlob;
  232. DWORD Persist;
  233. DWORD AttributeCount;
  234. PCREDENTIAL_ATTRIBUTEA Attributes;
  235. LPSTR TargetAlias;
  236. LPSTR UserName;
  237. } CREDENTIALA, *PCREDENTIALA;
  238. typedef struct _CREDENTIALW {
  239. DWORD Flags;
  240. DWORD Type;
  241. #ifdef MIDL_PASS
  242. [string] wchar_t *TargetName;
  243. #else // MIDL_PASS
  244. LPWSTR TargetName;
  245. #endif // MIDL_PASS
  246. #ifdef MIDL_PASS
  247. [string] wchar_t *Comment;
  248. #else // MIDL_PASS
  249. LPWSTR Comment;
  250. #endif // MIDL_PASS
  251. FILETIME LastWritten;
  252. DWORD CredentialBlobSize;
  253. #ifdef MIDL_PASS
  254. [size_is(CredentialBlobSize)]
  255. #endif // MIDL_PASS
  256. LPBYTE CredentialBlob;
  257. DWORD Persist;
  258. DWORD AttributeCount;
  259. #ifdef MIDL_PASS
  260. [size_is(AttributeCount)]
  261. #endif // MIDL_PASS
  262. PCREDENTIAL_ATTRIBUTEW Attributes;
  263. #ifdef MIDL_PASS
  264. [string] wchar_t *TargetAlias;
  265. #else // MIDL_PASS
  266. LPWSTR TargetAlias;
  267. #endif // MIDL_PASS
  268. #ifdef MIDL_PASS
  269. [string] wchar_t *UserName;
  270. #else // MIDL_PASS
  271. LPWSTR UserName;
  272. #endif // MIDL_PASS
  273. } CREDENTIALW, *PCREDENTIALW;
  274. #ifdef UNICODE
  275. typedef CREDENTIALW CREDENTIAL;
  276. typedef PCREDENTIALW PCREDENTIAL;
  277. #else
  278. typedef CREDENTIALA CREDENTIAL;
  279. typedef PCREDENTIALA PCREDENTIAL;
  280. #endif // UNICODE
  281. //
  282. // Value of the Flags field in CREDENTIAL_TARGET_INFORMATION
  283. //
  284. #define CRED_TI_SERVER_FORMAT_UNKNOWN 0x0001 // Don't know if server name is DNS or netbios format
  285. #define CRED_TI_DOMAIN_FORMAT_UNKNOWN 0x0002 // Don't know if domain name is DNS or netbios format
  286. #define CRED_TI_ONLY_PASSWORD_REQUIRED 0x0004 // Server only requires a password and not a username
  287. #define CRED_TI_USERNAME_TARGET 0x0008 // TargetName is username
  288. #define CRED_TI_CREATE_EXPLICIT_CRED 0x0010 // When creating a cred, create one named TargetInfo->TargetName
  289. #define CRED_TI_WORKGROUP_MEMBER 0x0020 // Indicates the machine is a member of a workgroup
  290. #define CRED_TI_VALID_FLAGS 0x003F
  291. //
  292. // A credential target
  293. //
  294. typedef struct _CREDENTIAL_TARGET_INFORMATIONA {
  295. LPSTR TargetName;
  296. LPSTR NetbiosServerName;
  297. LPSTR DnsServerName;
  298. LPSTR NetbiosDomainName;
  299. LPSTR DnsDomainName;
  300. LPSTR DnsTreeName;
  301. LPSTR PackageName;
  302. ULONG Flags;
  303. DWORD CredTypeCount;
  304. LPDWORD CredTypes;
  305. } CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA;
  306. typedef struct _CREDENTIAL_TARGET_INFORMATIONW {
  307. #ifdef MIDL_PASS
  308. [string] wchar_t *TargetName;
  309. [string] wchar_t *NetbiosServerName;
  310. [string] wchar_t *DnsServerName;
  311. [string] wchar_t *NetbiosDomainName;
  312. [string] wchar_t *DnsDomainName;
  313. [string] wchar_t *DnsTreeName;
  314. [string] wchar_t *PackageName;
  315. #else // MIDL_PASS
  316. LPWSTR TargetName;
  317. LPWSTR NetbiosServerName;
  318. LPWSTR DnsServerName;
  319. LPWSTR NetbiosDomainName;
  320. LPWSTR DnsDomainName;
  321. LPWSTR DnsTreeName;
  322. LPWSTR PackageName;
  323. #endif // MIDL_PASS
  324. ULONG Flags;
  325. DWORD CredTypeCount;
  326. LPDWORD CredTypes;
  327. } CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW;
  328. #ifdef UNICODE
  329. typedef CREDENTIAL_TARGET_INFORMATIONW CREDENTIAL_TARGET_INFORMATION;
  330. typedef PCREDENTIAL_TARGET_INFORMATIONW PCREDENTIAL_TARGET_INFORMATION;
  331. #else
  332. typedef CREDENTIAL_TARGET_INFORMATIONA CREDENTIAL_TARGET_INFORMATION;
  333. typedef PCREDENTIAL_TARGET_INFORMATIONA PCREDENTIAL_TARGET_INFORMATION;
  334. #endif // UNICODE
  335. //
  336. // Certificate credential information
  337. //
  338. // The cbSize should be the size of the structure, sizeof(CERT_CREDENTIAL_INFO),
  339. // rgbHashofCert is the hash of the cert which is to be used as the credential.
  340. //
  341. #define CERT_HASH_LENGTH 20 // SHA1 hashes are used for cert hashes
  342. typedef struct _CERT_CREDENTIAL_INFO {
  343. ULONG cbSize;
  344. UCHAR rgbHashOfCert[CERT_HASH_LENGTH];
  345. } CERT_CREDENTIAL_INFO, *PCERT_CREDENTIAL_INFO;
  346. //
  347. // Username Target credential information
  348. //
  349. // This credential can be pass to LsaLogonUser to ask it to find a credential with a
  350. // TargetName of UserName.
  351. //
  352. typedef struct _USERNAME_TARGET_CREDENTIAL_INFO {
  353. LPWSTR UserName;
  354. } USERNAME_TARGET_CREDENTIAL_INFO, *PUSERNAME_TARGET_CREDENTIAL_INFO;
  355. //
  356. // Credential type for credential marshaling routines
  357. //
  358. typedef enum _CRED_MARSHAL_TYPE {
  359. CertCredential = 1,
  360. UsernameTargetCredential
  361. } CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE;
  362. //
  363. // Credential UI info
  364. //
  365. typedef struct _CREDUI_INFOA
  366. {
  367. DWORD cbSize;
  368. HWND hwndParent;
  369. PCSTR pszMessageText;
  370. PCSTR pszCaptionText;
  371. HBITMAP hbmBanner;
  372. } CREDUI_INFOA, *PCREDUI_INFOA;
  373. typedef struct _CREDUI_INFOW
  374. {
  375. DWORD cbSize;
  376. HWND hwndParent;
  377. PCWSTR pszMessageText;
  378. PCWSTR pszCaptionText;
  379. HBITMAP hbmBanner;
  380. } CREDUI_INFOW, *PCREDUI_INFOW;
  381. #ifdef UNICODE
  382. typedef CREDUI_INFOW CREDUI_INFO;
  383. typedef PCREDUI_INFOW PCREDUI_INFO;
  384. #else
  385. typedef CREDUI_INFOA CREDUI_INFO;
  386. typedef PCREDUI_INFOA PCREDUI_INFO;
  387. #endif
  388. //-----------------------------------------------------------------------------
  389. // Values
  390. //-----------------------------------------------------------------------------
  391. // String length limits:
  392. #define CREDUI_MAX_MESSAGE_LENGTH 32767
  393. #define CREDUI_MAX_CAPTION_LENGTH 128
  394. #define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH
  395. #define CREDUI_MAX_DOMAIN_TARGET_LENGTH (CRED_MAX_STRING_LENGTH + NNLEN)
  396. #define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH
  397. #define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2)
  398. //
  399. // Flags for CredUIPromptForCredentials and/or CredUICmdLinePromptForCredentials
  400. //
  401. #define CREDUI_FLAGS_INCORRECT_PASSWORD 0x00001 // indicates the username is valid, but password is not
  402. #define CREDUI_FLAGS_DO_NOT_PERSIST 0x00002 // Do not show "Save" checkbox, and do not persist credentials
  403. #define CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00004 // Populate list box with admin accounts
  404. #define CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00008 // do not include certificates in the drop list
  405. #define CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00010
  406. #define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00040
  407. #define CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00080
  408. #define CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00100
  409. #define CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00200
  410. #define CREDUI_FLAGS_VALIDATE_USERNAME 0x00400
  411. #define CREDUI_FLAGS_COMPLETE_USERNAME 0x00800 //
  412. #define CREDUI_FLAGS_PERSIST 0x01000 // Do not show "Save" checkbox, but persist credentials anyway
  413. #define CREDUI_FLAGS_SERVER_CREDENTIAL 0x04000
  414. #define CREDUI_FLAGS_EXPECT_CONFIRMATION 0x20000 // do not persist unless caller later confirms credential via CredUIConfirmCredential() api
  415. #define CREDUI_FLAGS_GENERIC_CREDENTIALS 0x40000 // Credential is a generic credential
  416. #define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x80000 // Credential has a username as the target
  417. #define CREDUI_FLAGS_KEEP_USERNAME 0x100000 // don't allow the user to change the supplied username
  418. //
  419. // Mask of flags valid for CredUIPromptForCredentials
  420. //
  421. #define CREDUI_FLAGS_PROMPT_VALID ( \
  422. CREDUI_FLAGS_INCORRECT_PASSWORD | \
  423. CREDUI_FLAGS_DO_NOT_PERSIST | \
  424. CREDUI_FLAGS_REQUEST_ADMINISTRATOR | \
  425. CREDUI_FLAGS_EXCLUDE_CERTIFICATES | \
  426. CREDUI_FLAGS_REQUIRE_CERTIFICATE | \
  427. CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX | \
  428. CREDUI_FLAGS_ALWAYS_SHOW_UI | \
  429. CREDUI_FLAGS_REQUIRE_SMARTCARD | \
  430. CREDUI_FLAGS_PASSWORD_ONLY_OK | \
  431. CREDUI_FLAGS_VALIDATE_USERNAME | \
  432. CREDUI_FLAGS_COMPLETE_USERNAME | \
  433. CREDUI_FLAGS_PERSIST | \
  434. CREDUI_FLAGS_SERVER_CREDENTIAL | \
  435. CREDUI_FLAGS_EXPECT_CONFIRMATION | \
  436. CREDUI_FLAGS_GENERIC_CREDENTIALS | \
  437. CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS | \
  438. CREDUI_FLAGS_KEEP_USERNAME )
  439. //-----------------------------------------------------------------------------
  440. // Functions
  441. //-----------------------------------------------------------------------------
  442. //
  443. // Values of flags to CredWrite and CredWriteDomainCredentials
  444. //
  445. #define CRED_PRESERVE_CREDENTIAL_BLOB 0x1
  446. WINADVAPI
  447. BOOL
  448. WINAPI
  449. CredWriteW (
  450. IN PCREDENTIALW Credential,
  451. IN DWORD Flags
  452. );
  453. WINADVAPI
  454. BOOL
  455. WINAPI
  456. CredWriteA (
  457. IN PCREDENTIALA Credential,
  458. IN DWORD Flags
  459. );
  460. #ifdef UNICODE
  461. #define CredWrite CredWriteW
  462. #else
  463. #define CredWrite CredWriteA
  464. #endif // UNICODE
  465. WINADVAPI
  466. BOOL
  467. WINAPI
  468. CredReadW (
  469. IN LPCWSTR TargetName,
  470. IN DWORD Type,
  471. IN DWORD Flags,
  472. OUT PCREDENTIALW *Credential
  473. );
  474. WINADVAPI
  475. BOOL
  476. WINAPI
  477. CredReadA (
  478. IN LPCSTR TargetName,
  479. IN DWORD Type,
  480. IN DWORD Flags,
  481. OUT PCREDENTIALA *Credential
  482. );
  483. #ifdef UNICODE
  484. #define CredRead CredReadW
  485. #else
  486. #define CredRead CredReadA
  487. #endif // UNICODE
  488. WINADVAPI
  489. BOOL
  490. WINAPI
  491. CredEnumerateW (
  492. IN LPCWSTR Filter,
  493. IN DWORD Flags,
  494. OUT DWORD *Count,
  495. OUT PCREDENTIALW **Credential
  496. );
  497. WINADVAPI
  498. BOOL
  499. WINAPI
  500. CredEnumerateA (
  501. IN LPCSTR Filter,
  502. IN DWORD Flags,
  503. OUT DWORD *Count,
  504. OUT PCREDENTIALA **Credential
  505. );
  506. #ifdef UNICODE
  507. #define CredEnumerate CredEnumerateW
  508. #else
  509. #define CredEnumerate CredEnumerateA
  510. #endif // UNICODE
  511. WINADVAPI
  512. BOOL
  513. WINAPI
  514. CredWriteDomainCredentialsW (
  515. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  516. IN PCREDENTIALW Credential,
  517. IN DWORD Flags
  518. );
  519. WINADVAPI
  520. BOOL
  521. WINAPI
  522. CredWriteDomainCredentialsA (
  523. IN PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,
  524. IN PCREDENTIALA Credential,
  525. IN DWORD Flags
  526. );
  527. #ifdef UNICODE
  528. #define CredWriteDomainCredentials CredWriteDomainCredentialsW
  529. #else
  530. #define CredWriteDomainCredentials CredWriteDomainCredentialsA
  531. #endif // UNICODE
  532. //
  533. // Values of flags to CredReadDomainCredentials
  534. //
  535. #define CRED_CACHE_TARGET_INFORMATION 0x1
  536. WINADVAPI
  537. BOOL
  538. WINAPI
  539. CredReadDomainCredentialsW (
  540. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  541. IN DWORD Flags,
  542. OUT DWORD *Count,
  543. OUT PCREDENTIALW **Credential
  544. );
  545. WINADVAPI
  546. BOOL
  547. WINAPI
  548. CredReadDomainCredentialsA (
  549. IN PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,
  550. IN DWORD Flags,
  551. OUT DWORD *Count,
  552. OUT PCREDENTIALA **Credential
  553. );
  554. #ifdef UNICODE
  555. #define CredReadDomainCredentials CredReadDomainCredentialsW
  556. #else
  557. #define CredReadDomainCredentials CredReadDomainCredentialsA
  558. #endif // UNICODE
  559. WINADVAPI
  560. BOOL
  561. WINAPI
  562. CredDeleteW (
  563. IN LPCWSTR TargetName,
  564. IN DWORD Type,
  565. IN DWORD Flags
  566. );
  567. WINADVAPI
  568. BOOL
  569. WINAPI
  570. CredDeleteA (
  571. IN LPCSTR TargetName,
  572. IN DWORD Type,
  573. IN DWORD Flags
  574. );
  575. #ifdef UNICODE
  576. #define CredDelete CredDeleteW
  577. #else
  578. #define CredDelete CredDeleteA
  579. #endif // UNICODE
  580. WINADVAPI
  581. BOOL
  582. WINAPI
  583. CredRenameW (
  584. IN LPCWSTR OldTargetName,
  585. IN LPCWSTR NewTargetName,
  586. IN DWORD Type,
  587. IN DWORD Flags
  588. );
  589. WINADVAPI
  590. BOOL
  591. WINAPI
  592. CredRenameA (
  593. IN LPCSTR OldTargetName,
  594. IN LPCSTR NewTargetName,
  595. IN DWORD Type,
  596. IN DWORD Flags
  597. );
  598. #ifdef UNICODE
  599. #define CredRename CredRenameW
  600. #else
  601. #define CredRename CredRenameA
  602. #endif // UNICODE
  603. //
  604. // Values of flags to CredGetTargetInfo
  605. //
  606. #define CRED_ALLOW_NAME_RESOLUTION 0x1
  607. WINADVAPI
  608. BOOL
  609. WINAPI
  610. CredGetTargetInfoW (
  611. IN LPCWSTR TargetName,
  612. IN DWORD Flags,
  613. OUT PCREDENTIAL_TARGET_INFORMATIONW *TargetInfo
  614. );
  615. WINADVAPI
  616. BOOL
  617. WINAPI
  618. CredGetTargetInfoA (
  619. IN LPCSTR TargetName,
  620. IN DWORD Flags,
  621. OUT PCREDENTIAL_TARGET_INFORMATIONA *TargetInfo
  622. );
  623. #ifdef UNICODE
  624. #define CredGetTargetInfo CredGetTargetInfoW
  625. #else
  626. #define CredGetTargetInfo CredGetTargetInfoA
  627. #endif // UNICODE
  628. WINADVAPI
  629. BOOL
  630. WINAPI
  631. CredMarshalCredentialW(
  632. IN CRED_MARSHAL_TYPE CredType,
  633. IN PVOID Credential,
  634. OUT LPWSTR *MarshaledCredential
  635. );
  636. WINADVAPI
  637. BOOL
  638. WINAPI
  639. CredMarshalCredentialA(
  640. IN CRED_MARSHAL_TYPE CredType,
  641. IN PVOID Credential,
  642. OUT LPSTR *MarshaledCredential
  643. );
  644. #ifdef UNICODE
  645. #define CredMarshalCredential CredMarshalCredentialW
  646. #else
  647. #define CredMarshalCredential CredMarshalCredentialA
  648. #endif // UNICODE
  649. WINADVAPI
  650. BOOL
  651. WINAPI
  652. CredUnmarshalCredentialW(
  653. IN LPCWSTR MarshaledCredential,
  654. OUT PCRED_MARSHAL_TYPE CredType,
  655. OUT PVOID *Credential
  656. );
  657. WINADVAPI
  658. BOOL
  659. WINAPI
  660. CredUnmarshalCredentialA(
  661. IN LPCSTR MarshaledCredential,
  662. OUT PCRED_MARSHAL_TYPE CredType,
  663. OUT PVOID *Credential
  664. );
  665. #ifdef UNICODE
  666. #define CredUnmarshalCredential CredUnmarshalCredentialW
  667. #else
  668. #define CredUnmarshalCredential CredUnmarshalCredentialA
  669. #endif // UNICODE
  670. WINADVAPI
  671. BOOL
  672. WINAPI
  673. CredIsMarshaledCredentialW(
  674. IN LPCWSTR MarshaledCredential
  675. );
  676. WINADVAPI
  677. BOOL
  678. WINAPI
  679. CredIsMarshaledCredentialA(
  680. IN LPCSTR MarshaledCredential
  681. );
  682. #ifdef UNICODE
  683. #define CredIsMarshaledCredential CredIsMarshaledCredentialW
  684. #else
  685. #define CredIsMarshaledCredential CredIsMarshaledCredentialA
  686. #endif // UNICODE
  687. WINADVAPI
  688. BOOL
  689. WINAPI
  690. CredGetSessionTypes (
  691. IN DWORD MaximumPersistCount,
  692. OUT LPDWORD MaximumPersist
  693. );
  694. WINADVAPI
  695. VOID
  696. WINAPI
  697. CredFree (
  698. IN PVOID Buffer
  699. );
  700. CREDUIAPI
  701. DWORD
  702. WINAPI
  703. CredUIPromptForCredentialsW(
  704. PCREDUI_INFOW pUiInfo,
  705. PCWSTR pszTargetName,
  706. PCtxtHandle pContext,
  707. DWORD dwAuthError,
  708. PWSTR pszUserName,
  709. ULONG ulUserNameBufferSize,
  710. PWSTR pszPassword,
  711. ULONG ulPasswordBufferSize,
  712. BOOL *save,
  713. DWORD dwFlags
  714. );
  715. CREDUIAPI
  716. DWORD
  717. WINAPI
  718. CredUIPromptForCredentialsA(
  719. PCREDUI_INFOA pUiInfo,
  720. PCSTR pszTargetName,
  721. PCtxtHandle pContext,
  722. DWORD dwAuthError,
  723. PSTR pszUserName,
  724. ULONG ulUserNameBufferSize,
  725. PSTR pszPassword,
  726. ULONG ulPasswordBufferSize,
  727. BOOL *save,
  728. DWORD dwFlags
  729. );
  730. #ifdef UNICODE
  731. #define CredUIPromptForCredentials CredUIPromptForCredentialsW
  732. #else
  733. #define CredUIPromptForCredentials CredUIPromptForCredentialsA
  734. #endif
  735. CREDUIAPI
  736. DWORD
  737. WINAPI
  738. CredUIParseUserNameW(
  739. PCWSTR pszUserName,
  740. PWSTR pszUser,
  741. ULONG ulUserBufferSize,
  742. PWSTR pszDomain,
  743. ULONG ulDomainBufferSize
  744. );
  745. CREDUIAPI
  746. DWORD
  747. WINAPI
  748. CredUIParseUserNameA(
  749. PCSTR pszUserName,
  750. PSTR pszUser,
  751. ULONG ulUserBufferSize,
  752. PSTR pszDomain,
  753. ULONG ulDomainBufferSize
  754. );
  755. #ifdef UNICODE
  756. #define CredUIParseUserName CredUIParseUserNameW
  757. #else
  758. #define CredUIParseUserName CredUIParseUserNameA
  759. #endif
  760. CREDUIAPI
  761. DWORD
  762. WINAPI
  763. CredUICmdLinePromptForCredentialsW(
  764. PCWSTR pszTargetName,
  765. PCtxtHandle pContext,
  766. DWORD dwAuthError,
  767. PWSTR UserName,
  768. ULONG ulUserBufferSize,
  769. PWSTR pszPassword,
  770. ULONG ulPasswordBufferSize,
  771. PBOOL pfSave,
  772. DWORD dwFlags
  773. );
  774. CREDUIAPI
  775. DWORD
  776. WINAPI
  777. CredUICmdLinePromptForCredentialsA(
  778. PCSTR pszTargetName,
  779. PCtxtHandle pContext,
  780. DWORD dwAuthError,
  781. PSTR UserName,
  782. ULONG ulUserBufferSize,
  783. PSTR pszPassword,
  784. ULONG ulPasswordBufferSize,
  785. PBOOL pfSave,
  786. DWORD dwFlags
  787. );
  788. #ifdef UNICODE
  789. #define CredUICmdLinePromptForCredentials CredUICmdLinePromptForCredentialsW
  790. #else
  791. #define CredUICmdLinePromptForCredentials CredUICmdLinePromptForCredentialsA
  792. #endif
  793. //
  794. // Call this API with bConfirm set to TRUE to confirm that the credential (previously created
  795. // via CredUIGetCredentials or CredUIPromptForCredentials worked, or with bConfirm set to FALSE
  796. // to indicate it didn't
  797. CREDUIAPI
  798. DWORD
  799. WINAPI
  800. CredUIConfirmCredentialsW(
  801. PCWSTR pszTargetName,
  802. BOOL bConfirm
  803. );
  804. CREDUIAPI
  805. DWORD
  806. WINAPI
  807. CredUIConfirmCredentialsA(
  808. PCSTR pszTargetName,
  809. BOOL bConfirm
  810. );
  811. #ifdef UNICODE
  812. #define CredUIConfirmCredentials CredUIConfirmCredentialsW
  813. #else
  814. #define CredUIConfirmCredentials CredUIConfirmCredentialsA
  815. #endif
  816. CREDUIAPI
  817. DWORD
  818. WINAPI
  819. CredUIStoreSSOCredW (
  820. PCWSTR pszRealm,
  821. PCWSTR pszUsername,
  822. PCWSTR pszPassword,
  823. BOOL bPersist
  824. );
  825. CREDUIAPI
  826. DWORD
  827. WINAPI
  828. CredUIReadSSOCredW (
  829. PCWSTR pszRealm,
  830. PWSTR* ppszUsername
  831. );
  832. #ifdef __cplusplus
  833. }
  834. #endif
  835. #endif // _WINCRED_H_