1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef _WINCRED_H_ 7 #define _WINCRED_H_ 8 9 #include <_mingw.h> 10 #include <_mingw_unicode.h> 11 12 #ifndef WINADVAPI 13 #ifndef _ADVAPI32_ 14 #define WINADVAPI DECLSPEC_IMPORT 15 #else 16 #define WINADVAPI 17 #endif 18 #endif 19 20 #ifndef CREDUIAPI 21 #ifndef _CREDUI_ 22 #define CREDUIAPI DECLSPEC_IMPORT 23 #else 24 #define CREDUIAPI 25 #endif 26 #endif 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #ifndef __SECHANDLE_DEFINED__ 33 #define __SECHANDLE_DEFINED__ 34 35 typedef struct _SecHandle { 36 ULONG_PTR dwLower; 37 ULONG_PTR dwUpper; 38 } SecHandle,*PSecHandle; 39 #endif 40 41 typedef PSecHandle PCtxtHandle; 42 43 #ifndef _WINBASE_ 44 #ifndef _FILETIME_ 45 #define _FILETIME_ 46 47 typedef struct _FILETIME { 48 DWORD dwLowDateTime; 49 DWORD dwHighDateTime; 50 } FILETIME; 51 52 typedef struct _FILETIME *PFILETIME; 53 typedef struct _FILETIME *LPFILETIME; 54 #endif 55 #endif 56 57 #if !defined (_NTDEF_) && !defined (_NTSTATUS_PSDK) 58 #define _NTSTATUS_PSDK 59 typedef LONG NTSTATUS,*PNTSTATUS; 60 #endif 61 62 #define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006D) 63 #define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006A) 64 #define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071) 65 #define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS)0xC0000224) 66 #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022) 67 #define STATUS_DOWNGRADE_DETECTED ((NTSTATUS)0xC0000388) 68 #define STATUS_AUTHENTICATION_FIREWALL_FAILED ((NTSTATUS)0xC0000413) 69 #define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072) 70 #define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006E) 71 #define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234) 72 #define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193) 73 #define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS)0xC000015B) 74 75 #define NERR_BASE 2100 76 #define NERR_PasswordExpired (NERR_BASE+142) 77 78 #define CREDUIP_IS_USER_PASSWORD_ERROR(_Status) ((_Status)==ERROR_LOGON_FAILURE || (_Status)==HRESULT_FROM_WIN32(ERROR_LOGON_FAILURE) || (_Status)==STATUS_LOGON_FAILURE || (_Status)==HRESULT_FROM_NT(STATUS_LOGON_FAILURE) || (_Status)==ERROR_ACCESS_DENIED || (_Status)==HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || (_Status)==STATUS_ACCESS_DENIED || (_Status)==HRESULT_FROM_NT(STATUS_ACCESS_DENIED) || (_Status)==ERROR_INVALID_PASSWORD || (_Status)==HRESULT_FROM_WIN32(ERROR_INVALID_PASSWORD) || (_Status)==STATUS_WRONG_PASSWORD || (_Status)==HRESULT_FROM_NT(STATUS_WRONG_PASSWORD) || (_Status)==SEC_E_NO_CREDENTIALS || (_Status)==SEC_E_LOGON_DENIED) 79 #define CREDUIP_IS_DOWNGRADE_ERROR(_Status) ((_Status)==ERROR_DOWNGRADE_DETECTED || (_Status)==HRESULT_FROM_WIN32(ERROR_DOWNGRADE_DETECTED) || (_Status)==STATUS_DOWNGRADE_DETECTED || (_Status)==HRESULT_FROM_NT(STATUS_DOWNGRADE_DETECTED)) 80 #define CREDUIP_IS_EXPIRED_ERROR(_Status) ((_Status)==ERROR_PASSWORD_EXPIRED || (_Status)==HRESULT_FROM_WIN32(ERROR_PASSWORD_EXPIRED) || (_Status)==STATUS_PASSWORD_EXPIRED || (_Status)==HRESULT_FROM_NT(STATUS_PASSWORD_EXPIRED) || (_Status)==ERROR_PASSWORD_MUST_CHANGE || (_Status)==HRESULT_FROM_WIN32(ERROR_PASSWORD_MUST_CHANGE) || (_Status)==STATUS_PASSWORD_MUST_CHANGE || (_Status)==HRESULT_FROM_NT(STATUS_PASSWORD_MUST_CHANGE) || (_Status)==NERR_PasswordExpired || (_Status)==HRESULT_FROM_WIN32(NERR_PasswordExpired)) 81 #define CREDUI_IS_AUTHENTICATION_ERROR(_Status) (CREDUIP_IS_USER_PASSWORD_ERROR(_Status) || CREDUIP_IS_DOWNGRADE_ERROR(_Status) || CREDUIP_IS_EXPIRED_ERROR(_Status)) 82 #define CREDUI_NO_PROMPT_AUTHENTICATION_ERROR(_Status) ((_Status)==ERROR_AUTHENTICATION_FIREWALL_FAILED || (_Status)==HRESULT_FROM_WIN32(ERROR_AUTHENTICATION_FIREWALL_FAILED) || (_Status)==STATUS_AUTHENTICATION_FIREWALL_FAILED || (_Status)==HRESULT_FROM_NT(STATUS_AUTHENTICATION_FIREWALL_FAILED) || (_Status)==ERROR_ACCOUNT_DISABLED || (_Status)==HRESULT_FROM_WIN32(ERROR_ACCOUNT_DISABLED) || (_Status)==STATUS_ACCOUNT_DISABLED || (_Status)==HRESULT_FROM_NT(STATUS_ACCOUNT_DISABLED) || (_Status)==ERROR_ACCOUNT_RESTRICTION || (_Status)==HRESULT_FROM_WIN32(ERROR_ACCOUNT_RESTRICTION) || (_Status)==STATUS_ACCOUNT_RESTRICTION || (_Status)==HRESULT_FROM_NT(STATUS_ACCOUNT_RESTRICTION) || (_Status)==ERROR_ACCOUNT_LOCKED_OUT || (_Status)==HRESULT_FROM_WIN32(ERROR_ACCOUNT_LOCKED_OUT) || (_Status)==STATUS_ACCOUNT_LOCKED_OUT || (_Status)==HRESULT_FROM_NT(STATUS_ACCOUNT_LOCKED_OUT) || (_Status)==ERROR_ACCOUNT_EXPIRED || (_Status)==HRESULT_FROM_WIN32(ERROR_ACCOUNT_EXPIRED) || (_Status)==STATUS_ACCOUNT_EXPIRED || (_Status)==HRESULT_FROM_NT(STATUS_ACCOUNT_EXPIRED) || (_Status)==ERROR_LOGON_TYPE_NOT_GRANTED || (_Status)==HRESULT_FROM_WIN32(ERROR_LOGON_TYPE_NOT_GRANTED) || (_Status)==STATUS_LOGON_TYPE_NOT_GRANTED || (_Status)==HRESULT_FROM_NT(STATUS_LOGON_TYPE_NOT_GRANTED)) 83 84 #define CRED_MAX_STRING_LENGTH 256 85 #define CRED_MAX_USERNAME_LENGTH (256+1+256) 86 #define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767 87 #define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH (256+1+80) 88 #define CRED_MAX_VALUE_SIZE 256 89 #define CRED_MAX_ATTRIBUTES 64 90 91 typedef struct _CREDENTIAL_ATTRIBUTEA { 92 LPSTR Keyword; 93 DWORD Flags; 94 DWORD ValueSize; 95 LPBYTE Value; 96 } CREDENTIAL_ATTRIBUTEA,*PCREDENTIAL_ATTRIBUTEA; 97 98 typedef struct _CREDENTIAL_ATTRIBUTEW { 99 LPWSTR Keyword; 100 DWORD Flags; 101 DWORD ValueSize; 102 LPBYTE Value; 103 } CREDENTIAL_ATTRIBUTEW,*PCREDENTIAL_ATTRIBUTEW; 104 105 __MINGW_TYPEDEF_AW(CREDENTIAL_ATTRIBUTE) 106 __MINGW_TYPEDEF_AW(PCREDENTIAL_ATTRIBUTE) 107 108 #define CRED_SESSION_WILDCARD_NAME_W L"*Session" 109 #define CRED_SESSION_WILDCARD_NAME_A "*Session" 110 #define CRED_SESSION_WILDCARD_NAME_LENGTH (sizeof(CRED_SESSION_WILDCARD_NAME_A)-1) 111 112 #define CRED_SESSION_WILDCARD_NAME __MINGW_NAME_UAW(CRED_SESSION_WILDCARD_NAME) 113 114 #define CRED_FLAGS_PASSWORD_FOR_CERT 0x0001 115 #define CRED_FLAGS_PROMPT_NOW 0x0002 116 #define CRED_FLAGS_USERNAME_TARGET 0x0004 117 #define CRED_FLAGS_OWF_CRED_BLOB 0x0008 118 #define CRED_FLAGS_VALID_FLAGS 0x000F 119 120 #define CRED_TYPE_GENERIC 1 121 #define CRED_TYPE_DOMAIN_PASSWORD 2 122 #define CRED_TYPE_DOMAIN_CERTIFICATE 3 123 #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4 124 #define CRED_TYPE_MAXIMUM 5 125 #define CRED_TYPE_MAXIMUM_EX (CRED_TYPE_MAXIMUM+1000) 126 127 #define CRED_MAX_CREDENTIAL_BLOB_SIZE 512 128 129 #define CRED_PERSIST_NONE 0 130 #define CRED_PERSIST_SESSION 1 131 #define CRED_PERSIST_LOCAL_MACHINE 2 132 #define CRED_PERSIST_ENTERPRISE 3 133 134 typedef struct _CREDENTIALA { 135 DWORD Flags; 136 DWORD Type; 137 LPSTR TargetName; 138 LPSTR Comment; 139 FILETIME LastWritten; 140 DWORD CredentialBlobSize; 141 LPBYTE CredentialBlob; 142 DWORD Persist; 143 DWORD AttributeCount; 144 PCREDENTIAL_ATTRIBUTEA Attributes; 145 LPSTR TargetAlias; 146 LPSTR UserName; 147 } CREDENTIALA,*PCREDENTIALA; 148 149 typedef struct _CREDENTIALW { 150 DWORD Flags; 151 DWORD Type; 152 LPWSTR TargetName; 153 LPWSTR Comment; 154 FILETIME LastWritten; 155 DWORD CredentialBlobSize; 156 LPBYTE CredentialBlob; 157 DWORD Persist; 158 DWORD AttributeCount; 159 PCREDENTIAL_ATTRIBUTEW Attributes; 160 LPWSTR TargetAlias; 161 LPWSTR UserName; 162 } CREDENTIALW,*PCREDENTIALW; 163 164 __MINGW_TYPEDEF_AW(CREDENTIAL) 165 __MINGW_TYPEDEF_AW(PCREDENTIAL) 166 167 #define CRED_TI_SERVER_FORMAT_UNKNOWN 0x0001 168 #define CRED_TI_DOMAIN_FORMAT_UNKNOWN 0x0002 169 #define CRED_TI_ONLY_PASSWORD_REQUIRED 0x0004 170 #define CRED_TI_USERNAME_TARGET 0x0008 171 #define CRED_TI_CREATE_EXPLICIT_CRED 0x0010 172 #define CRED_TI_WORKGROUP_MEMBER 0x0020 173 #define CRED_TI_VALID_FLAGS 0x003F 174 175 typedef struct _CREDENTIAL_TARGET_INFORMATIONA { 176 LPSTR TargetName; 177 LPSTR NetbiosServerName; 178 LPSTR DnsServerName; 179 LPSTR NetbiosDomainName; 180 LPSTR DnsDomainName; 181 LPSTR DnsTreeName; 182 LPSTR PackageName; 183 ULONG Flags; 184 DWORD CredTypeCount; 185 LPDWORD CredTypes; 186 } CREDENTIAL_TARGET_INFORMATIONA,*PCREDENTIAL_TARGET_INFORMATIONA; 187 188 typedef struct _CREDENTIAL_TARGET_INFORMATIONW { 189 LPWSTR TargetName; 190 LPWSTR NetbiosServerName; 191 LPWSTR DnsServerName; 192 LPWSTR NetbiosDomainName; 193 LPWSTR DnsDomainName; 194 LPWSTR DnsTreeName; 195 LPWSTR PackageName; 196 ULONG Flags; 197 DWORD CredTypeCount; 198 LPDWORD CredTypes; 199 } CREDENTIAL_TARGET_INFORMATIONW,*PCREDENTIAL_TARGET_INFORMATIONW; 200 201 __MINGW_TYPEDEF_AW(CREDENTIAL_TARGET_INFORMATION) 202 __MINGW_TYPEDEF_AW(PCREDENTIAL_TARGET_INFORMATION) 203 204 #define CERT_HASH_LENGTH 20 205 206 typedef struct _CERT_CREDENTIAL_INFO { 207 ULONG cbSize; 208 UCHAR rgbHashOfCert[CERT_HASH_LENGTH]; 209 } CERT_CREDENTIAL_INFO,*PCERT_CREDENTIAL_INFO; 210 211 typedef struct _USERNAME_TARGET_CREDENTIAL_INFO { 212 LPWSTR UserName; 213 } USERNAME_TARGET_CREDENTIAL_INFO,*PUSERNAME_TARGET_CREDENTIAL_INFO; 214 215 typedef enum _CRED_MARSHAL_TYPE { 216 CertCredential = 1,UsernameTargetCredential 217 } CRED_MARSHAL_TYPE,*PCRED_MARSHAL_TYPE; 218 219 typedef struct _CREDUI_INFOA { 220 DWORD cbSize; 221 HWND hwndParent; 222 PCSTR pszMessageText; 223 PCSTR pszCaptionText; 224 HBITMAP hbmBanner; 225 } CREDUI_INFOA,*PCREDUI_INFOA; 226 227 typedef struct _CREDUI_INFOW { 228 DWORD cbSize; 229 HWND hwndParent; 230 PCWSTR pszMessageText; 231 PCWSTR pszCaptionText; 232 HBITMAP hbmBanner; 233 } CREDUI_INFOW,*PCREDUI_INFOW; 234 235 __MINGW_TYPEDEF_AW(CREDUI_INFO) 236 __MINGW_TYPEDEF_AW(PCREDUI_INFO) 237 238 #define CREDUI_MAX_MESSAGE_LENGTH 32767 239 #define CREDUI_MAX_CAPTION_LENGTH 128 240 #define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH 241 #define CREDUI_MAX_DOMAIN_TARGET_LENGTH CRED_MAX_DOMAIN_TARGET_NAME_LENGTH 242 #define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH 243 #define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2) 244 245 #define CREDUI_FLAGS_INCORRECT_PASSWORD 0x00001 246 #define CREDUI_FLAGS_DO_NOT_PERSIST 0x00002 247 #define CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00004 248 #define CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00008 249 #define CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00010 250 #define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00040 251 #define CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00080 252 #define CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00100 253 #define CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00200 254 #define CREDUI_FLAGS_VALIDATE_USERNAME 0x00400 255 #define CREDUI_FLAGS_COMPLETE_USERNAME 0x00800 256 #define CREDUI_FLAGS_PERSIST 0x01000 257 #define CREDUI_FLAGS_SERVER_CREDENTIAL 0x04000 258 #define CREDUI_FLAGS_EXPECT_CONFIRMATION 0x20000 259 #define CREDUI_FLAGS_GENERIC_CREDENTIALS 0x40000 260 #define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x80000 261 #define CREDUI_FLAGS_KEEP_USERNAME 0x100000 262 263 #define CREDUI_FLAGS_PROMPT_VALID (CREDUI_FLAGS_INCORRECT_PASSWORD | CREDUI_FLAGS_DO_NOT_PERSIST | CREDUI_FLAGS_REQUEST_ADMINISTRATOR | CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_REQUIRE_CERTIFICATE | CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX | CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_REQUIRE_SMARTCARD | CREDUI_FLAGS_PASSWORD_ONLY_OK | CREDUI_FLAGS_VALIDATE_USERNAME | CREDUI_FLAGS_COMPLETE_USERNAME | CREDUI_FLAGS_PERSIST | CREDUI_FLAGS_SERVER_CREDENTIAL | CREDUI_FLAGS_EXPECT_CONFIRMATION | CREDUI_FLAGS_GENERIC_CREDENTIALS | CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS | CREDUI_FLAGS_KEEP_USERNAME) 264 265 #define CRED_PRESERVE_CREDENTIAL_BLOB 0x1 266 267 #define CredWrite __MINGW_NAME_AW(CredWrite) 268 #define CredRead __MINGW_NAME_AW(CredRead) 269 #define CredEnumerate __MINGW_NAME_AW(CredEnumerate) 270 #define CredWriteDomainCredentials __MINGW_NAME_AW(CredWriteDomainCredentials) 271 #define CredReadDomainCredentials __MINGW_NAME_AW(CredReadDomainCredentials) 272 #define CredDelete __MINGW_NAME_AW(CredDelete) 273 #define CredRename __MINGW_NAME_AW(CredRename) 274 #define CredGetTargetInfo __MINGW_NAME_AW(CredGetTargetInfo) 275 #define CredMarshalCredential __MINGW_NAME_AW(CredMarshalCredential) 276 #define CredUnmarshalCredential __MINGW_NAME_AW(CredUnmarshalCredential) 277 #define CredIsMarshaledCredential __MINGW_NAME_AW(CredIsMarshaledCredential) 278 #define CredUIPromptForCredentials __MINGW_NAME_AW(CredUIPromptForCredentials) 279 #define CredUIParseUserName __MINGW_NAME_AW(CredUIParseUserName) 280 #define CredUICmdLinePromptForCredentials __MINGW_NAME_AW(CredUICmdLinePromptForCredentials) 281 #define CredUIConfirmCredentials __MINGW_NAME_AW(CredUIConfirmCredentials) 282 283 WINADVAPI WINBOOL WINAPI CredWriteW(PCREDENTIALW Credential,DWORD Flags); 284 WINADVAPI WINBOOL WINAPI CredWriteA(PCREDENTIALA Credential,DWORD Flags); 285 WINADVAPI WINBOOL WINAPI CredReadW(LPCWSTR TargetName,DWORD Type,DWORD Flags,PCREDENTIALW *Credential); 286 WINADVAPI WINBOOL WINAPI CredReadA(LPCSTR TargetName,DWORD Type,DWORD Flags,PCREDENTIALA *Credential); 287 WINADVAPI WINBOOL WINAPI CredEnumerateW(LPCWSTR Filter,DWORD Flags,DWORD *Count,PCREDENTIALW **Credential); 288 WINADVAPI WINBOOL WINAPI CredEnumerateA(LPCSTR Filter,DWORD Flags,DWORD *Count,PCREDENTIALA **Credential); 289 WINADVAPI WINBOOL WINAPI CredWriteDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,PCREDENTIALW Credential,DWORD Flags); 290 WINADVAPI WINBOOL WINAPI CredWriteDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,PCREDENTIALA Credential,DWORD Flags); 291 292 #define CRED_CACHE_TARGET_INFORMATION 0x1 293 294 WINADVAPI WINBOOL WINAPI CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,DWORD Flags,DWORD *Count,PCREDENTIALW **Credential); 295 WINADVAPI WINBOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo,DWORD Flags,DWORD *Count,PCREDENTIALA **Credential); 296 WINADVAPI WINBOOL WINAPI CredDeleteW(LPCWSTR TargetName,DWORD Type,DWORD Flags); 297 WINADVAPI WINBOOL WINAPI CredDeleteA(LPCSTR TargetName,DWORD Type,DWORD Flags); 298 WINADVAPI WINBOOL WINAPI CredRenameW(LPCWSTR OldTargetName,LPCWSTR NewTargetName,DWORD Type,DWORD Flags); 299 WINADVAPI WINBOOL WINAPI CredRenameA(LPCSTR OldTargetName,LPCSTR NewTargetName,DWORD Type,DWORD Flags); 300 301 #define CRED_ALLOW_NAME_RESOLUTION 0x1 302 303 WINADVAPI WINBOOL WINAPI CredGetTargetInfoW(LPCWSTR TargetName,DWORD Flags,PCREDENTIAL_TARGET_INFORMATIONW *TargetInfo); 304 WINADVAPI WINBOOL WINAPI CredGetTargetInfoA(LPCSTR TargetName,DWORD Flags,PCREDENTIAL_TARGET_INFORMATIONA *TargetInfo); 305 WINADVAPI WINBOOL WINAPI CredMarshalCredentialW(CRED_MARSHAL_TYPE CredType,PVOID Credential,LPWSTR *MarshaledCredential); 306 WINADVAPI WINBOOL WINAPI CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType,PVOID Credential,LPSTR *MarshaledCredential); 307 WINADVAPI WINBOOL WINAPI CredUnmarshalCredentialW(LPCWSTR MarshaledCredential,PCRED_MARSHAL_TYPE CredType,PVOID *Credential); 308 WINADVAPI WINBOOL WINAPI CredUnmarshalCredentialA(LPCSTR MarshaledCredential,PCRED_MARSHAL_TYPE CredType,PVOID *Credential); 309 WINADVAPI WINBOOL WINAPI CredIsMarshaledCredentialW(LPCWSTR MarshaledCredential); 310 WINADVAPI WINBOOL WINAPI CredIsMarshaledCredentialA(LPCSTR MarshaledCredential); 311 WINADVAPI WINBOOL WINAPI CredGetSessionTypes (DWORD MaximumPersistCount,LPDWORD MaximumPersist); 312 WINADVAPI VOID WINAPI CredFree (PVOID Buffer); 313 CREDUIAPI DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUiInfo,PCWSTR pszTargetName,PCtxtHandle pContext,DWORD dwAuthError,PWSTR pszUserName,ULONG ulUserNameBufferSize,PWSTR pszPassword,ULONG ulPasswordBufferSize,WINBOOL *save,DWORD dwFlags); 314 CREDUIAPI DWORD WINAPI CredUIPromptForCredentialsA(PCREDUI_INFOA pUiInfo,PCSTR pszTargetName,PCtxtHandle pContext,DWORD dwAuthError,PSTR pszUserName,ULONG ulUserNameBufferSize,PSTR pszPassword,ULONG ulPasswordBufferSize,WINBOOL *save,DWORD dwFlags); 315 CREDUIAPI DWORD WINAPI CredUIParseUserNameW(CONST WCHAR *UserName,WCHAR *user,ULONG userBufferSize,WCHAR *domain,ULONG domainBufferSize); 316 CREDUIAPI DWORD WINAPI CredUIParseUserNameA(CONST CHAR *userName,CHAR *user,ULONG userBufferSize,CHAR *domain,ULONG domainBufferSize); 317 CREDUIAPI DWORD WINAPI CredUICmdLinePromptForCredentialsW(PCWSTR pszTargetName,PCtxtHandle pContext,DWORD dwAuthError,PWSTR UserName,ULONG ulUserBufferSize,PWSTR pszPassword,ULONG ulPasswordBufferSize,PBOOL pfSave,DWORD dwFlags); 318 CREDUIAPI DWORD WINAPI CredUICmdLinePromptForCredentialsA(PCSTR pszTargetName,PCtxtHandle pContext,DWORD dwAuthError,PSTR UserName,ULONG ulUserBufferSize,PSTR pszPassword,ULONG ulPasswordBufferSize,PBOOL pfSave,DWORD dwFlags); 319 CREDUIAPI DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName,WINBOOL bConfirm); 320 CREDUIAPI DWORD WINAPI CredUIConfirmCredentialsA(PCSTR pszTargetName,WINBOOL bConfirm); 321 CREDUIAPI DWORD WINAPI CredUIStoreSSOCredW (PCWSTR pszRealm,PCWSTR pszUsername,PCWSTR pszPassword,WINBOOL bPersist); 322 CREDUIAPI DWORD WINAPI CredUIReadSSOCredW (PCWSTR pszRealm,PWSTR *ppszUsername); 323 324 #if (_WIN32_WINNT >= 0x0600) 325 #define CredFindBestCredential __MINGW_NAME_AW(CredFindBestCredential) 326 #define CredIsProtected __MINGW_NAME_AW(CredIsProtected) 327 #define CredPackAuthenticationBuffer __MINGW_NAME_AW(CredPackAuthenticationBuffer) 328 #define CredProtect __MINGW_NAME_AW(CredProtect) 329 #define CredUIPromptForWindowsCredentials __MINGW_NAME_AW(CredUIPromptForWindowsCredentials) 330 #define CredUnPackAuthenticationBuffer __MINGW_NAME_AW(CredUnPackAuthenticationBuffer) 331 #define CredUnprotect __MINGW_NAME_AW(CredUnprotect) 332 333 #define CREDUIWIN_GENERIC 0x1 334 #define CREDUIWIN_CHECKBOX 0x2 335 #define CREDUIWIN_AUTHPACKAGE_ONLY 0x10 336 #define CREDUIWIN_IN_CRED_ONLY 0x20 337 #define CREDUIWIN_ENUMERATE_ADMINS 0x100 338 #define CREDUIWIN_ENUMERATE_CURRENT_USER 0x200 339 #define CREDUIWIN_SECURE_PROMPT 0x1000 340 #define CREDUIWIN_PACK_32_WOW 0x10000000 341 342 typedef enum _CRED_PROTECTION_TYPE { 343 CredUnprotected = 0, 344 CredUserProtection = 1, 345 CredTrustedProtection = 2 346 } CRED_PROTECTION_TYPE, *PCRED_PROTECTION_TYPE; 347 348 WINADVAPI WINBOOL WINAPI CredFindBestCredentialA( 349 LPCSTR TargetName, 350 DWORD Type, 351 DWORD Flags, 352 PCREDENTIALA *Credential 353 ); 354 355 WINADVAPI WINBOOL WINAPI CredFindBestCredentialW( 356 LPCWSTR TargetName, 357 DWORD Type, 358 DWORD Flags, 359 PCREDENTIALW *Credential 360 ); 361 362 WINADVAPI WINBOOL WINAPI CredIsProtectedA( 363 LPSTR pszProtectedCredentials, 364 CRED_PROTECTION_TYPE *pProtectionType 365 ); 366 367 WINADVAPI WINBOOL WINAPI CredIsProtectedW( 368 LPWSTR pszProtectedCredentials, 369 CRED_PROTECTION_TYPE *pProtectionType 370 ); 371 372 CREDUIAPI WINBOOL WINAPI CredPackAuthenticationBufferA( 373 DWORD dwFlags, 374 LPSTR pszUserName, 375 LPSTR pszPassword, 376 PBYTE pPackedCredentials, 377 DWORD *pcbPackedCredentials 378 ); 379 380 CREDUIAPI WINBOOL WINAPI CredPackAuthenticationBufferW( 381 DWORD dwFlags, 382 LPWSTR pszUserName, 383 LPWSTR pszPassword, 384 PBYTE pPackedCredentials, 385 DWORD *pcbPackedCredentials 386 ); 387 388 WINADVAPI WINBOOL WINAPI CredProtectW( 389 WINBOOL fAsSelf, 390 LPWSTR pszCredentials, 391 DWORD cchCredentials, 392 LPWSTR pszProtectedCredentials, 393 DWORD *pcchMaxChars, 394 CRED_PROTECTION_TYPE *ProtectionType 395 ); 396 397 WINADVAPI WINBOOL WINAPI CredProtectA( 398 WINBOOL fAsSelf, 399 LPSTR pszCredentials, 400 DWORD cchCredentials, 401 LPSTR pszProtectedCredentials, 402 DWORD *pcchMaxChars, 403 CRED_PROTECTION_TYPE *ProtectionType 404 ); 405 406 CREDUIAPI DWORD WINAPI CredUIPromptForWindowsCredentialsA( 407 PCREDUI_INFOA pUiInfo, 408 DWORD dwAuthError, 409 ULONG *pulAuthPackage, 410 LPCVOID pvInAuthBuffer, 411 ULONG ulInAuthBufferSize, 412 LPVOID *ppvOutAuthBuffer, 413 ULONG *pulOutAuthBufferSize, 414 WINBOOL *pfSave, 415 DWORD dwFlags 416 ); 417 418 CREDUIAPI DWORD WINAPI CredUIPromptForWindowsCredentialsW( 419 PCREDUI_INFOW pUiInfo, 420 DWORD dwAuthError, 421 ULONG *pulAuthPackage, 422 LPCVOID pvInAuthBuffer, 423 ULONG ulInAuthBufferSize, 424 LPVOID *ppvOutAuthBuffer, 425 ULONG *pulOutAuthBufferSize, 426 WINBOOL *pfSave, 427 DWORD dwFlags 428 ); 429 430 CREDUIAPI WINBOOL WINAPI CredUnPackAuthenticationBufferA( 431 DWORD dwFlags, 432 PVOID pAuthBuffer, 433 DWORD cbAuthBuffer, 434 LPSTR pszUserName, 435 DWORD *pcchMaxUserName, 436 LPSTR pszDomainName, 437 DWORD *pcchMaxDomainame, 438 LPSTR pszPassword, 439 DWORD *pcchMaxPassword 440 ); 441 442 CREDUIAPI WINBOOL WINAPI CredUnPackAuthenticationBufferW( 443 DWORD dwFlags, 444 PVOID pAuthBuffer, 445 DWORD cbAuthBuffer, 446 LPWSTR pszUserName, 447 DWORD *pcchMaxUserName, 448 LPWSTR pszDomainName, 449 DWORD *pcchMaxDomainame, 450 LPWSTR pszPassword, 451 DWORD *pcchMaxPassword 452 ); 453 454 WINADVAPI WINBOOL WINAPI CredUnprotectA( 455 WINBOOL fAsSelf, 456 LPSTR pszProtectedCredentials, 457 DWORD cchCredentials, 458 LPSTR pszCredentials, 459 DWORD *pcchMaxChars 460 ); 461 462 WINADVAPI WINBOOL WINAPI CredUnprotectW( 463 WINBOOL fAsSelf, 464 LPWSTR pszProtectedCredentials, 465 DWORD cchCredentials, 466 LPWSTR pszCredentials, 467 DWORD *pcchMaxChars 468 ); 469 470 #endif /* (_WIN32_WINNT >= 0x0600) */ 471 472 #ifdef __cplusplus 473 } 474 #endif 475 476 #endif /* _WINCRED_H_ */ 477 478