wincred.h 10.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright (C) 2006 Robert Shearman (for CodeWeavers)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifndef _WINCRED_H_
#define _WINCRED_H_

22 23 24 25
#ifdef __cplusplus
extern "C" {
#endif

26 27 28 29 30 31
#ifdef _ADVAPI32_
#define WINADVAPI
#else
#define WINADVAPI DECLSPEC_IMPORT
#endif

32 33 34 35 36 37 38 39 40
#ifndef __SECHANDLE_DEFINED__
#define __SECHANDLE_DEFINED__
typedef struct _SecHandle
{
    ULONG_PTR dwLower;
    ULONG_PTR dwUpper;
} SecHandle, *PSecHandle;
#endif

41 42
#ifndef __WINE_CTXTHANDLE_DEFINED__
#define __WINE_CTXTHANDLE_DEFINED__
43 44
typedef SecHandle CtxtHandle;
typedef PSecHandle PCtxtHandle;
45
#endif
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
typedef struct _CREDENTIAL_ATTRIBUTEA
{
    LPSTR Keyword;
    DWORD Flags;
    DWORD ValueSize;
    LPBYTE Value;
} CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA;

typedef struct _CREDENTIAL_ATTRIBUTEW
{
    LPWSTR Keyword;
    DWORD Flags;
    DWORD ValueSize;
    LPBYTE Value;
} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;

DECL_WINELIB_TYPE_AW(CREDENTIAL_ATTRIBUTE)
DECL_WINELIB_TYPE_AW(PCREDENTIAL_ATTRIBUTE)

typedef struct _CREDENTIALA
{
    DWORD Flags;
    DWORD Type;
    LPSTR TargetName;
    LPSTR Comment;
    FILETIME LastWritten;
    DWORD CredentialBlobSize;
    LPBYTE CredentialBlob;
    DWORD Persist;
    DWORD AttributeCount;
77
    PCREDENTIAL_ATTRIBUTEA Attributes;
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    LPSTR TargetAlias;
    LPSTR UserName;
} CREDENTIALA, *PCREDENTIALA;

typedef struct _CREDENTIALW
{
    DWORD Flags;
    DWORD Type;
    LPWSTR TargetName;
    LPWSTR Comment;
    FILETIME LastWritten;
    DWORD CredentialBlobSize;
    LPBYTE CredentialBlob;
    DWORD Persist;
    DWORD AttributeCount;
93
    PCREDENTIAL_ATTRIBUTEW Attributes;
94 95 96 97 98 99 100
    LPWSTR TargetAlias;
    LPWSTR UserName;
} CREDENTIALW, *PCREDENTIALW;

DECL_WINELIB_TYPE_AW(CREDENTIAL)
DECL_WINELIB_TYPE_AW(PCREDENTIAL)

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
typedef struct _CREDENTIAL_TARGET_INFORMATIONA
{
    LPSTR TargetName;
    LPSTR NetbiosServerName;
    LPSTR DnsServerName;
    LPSTR NetbiosDomainName;
    LPSTR DnsDomainName;
    LPSTR DnsTreeName;
    LPSTR PackageName;
    DWORD Flags;
    DWORD CredTypeCount;
    LPDWORD CredTypes;
} CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA;

typedef struct _CREDENTIAL_TARGET_INFORMATIONW
{
    LPWSTR TargetName;
    LPWSTR NetbiosServerName;
    LPWSTR DnsServerName;
    LPWSTR NetbiosDomainName;
    LPWSTR DnsDomainName;
    LPWSTR DnsTreeName;
    LPWSTR PackageName;
    DWORD Flags;
    DWORD CredTypeCount;
    LPDWORD CredTypes;
} CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW;

DECL_WINELIB_TYPE_AW(CREDENTIAL_TARGET_INFORMATION)
DECL_WINELIB_TYPE_AW(PCREDENTIAL_TARGET_INFORMATION)

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
typedef struct _CREDUI_INFOA
{
    DWORD cbSize;
    HWND hwndParent;
    PCSTR pszMessageText;
    PCSTR pszCaptionText;
    HBITMAP hbmBanner;
} CREDUI_INFOA, *PCREDUI_INFOA;

typedef struct _CREDUI_INFOW
{
    DWORD cbSize;
    HWND hwndParent;
    PCWSTR pszMessageText;
    PCWSTR pszCaptionText;
    HBITMAP hbmBanner;
} CREDUI_INFOW, *PCREDUI_INFOW;

150 151 152
DECL_WINELIB_TYPE_AW(CREDUI_INFO)
DECL_WINELIB_TYPE_AW(PCREDUI_INFO)

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
typedef enum _CRED_MARSHAL_TYPE
{
    CertCredential = 1,
    UsernameTargetCredential,
    BinaryBlobCredential
} CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE;

#define CERT_HASH_LENGTH    20

typedef struct _CERT_CREDENTIAL_INFO
{
    ULONG cbSize;
    UCHAR rgbHashOfCert[CERT_HASH_LENGTH];
} CERT_CREDENTIAL_INFO, *PCERT_CREDENTIAL_INFO;

typedef struct _USERNAME_TARGET_CREDENTIAL_INFO
{
    LPWSTR UserName;
} USERNAME_TARGET_CREDENTIAL_INFO;

typedef struct _BINARY_BLOB_CREDENTIAL_INFO
{
    ULONG cbBlob;
    LPBYTE pbBlob;
} BINARY_BLOB_CREDENTIAL_INFO, *PBINARY_BLOB_CREDENTIAL_INFO;

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
#define CRED_MAX_STRING_LENGTH              256
#define CRED_MAX_USERNAME_LENGTH            513
#define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767
#define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH  337
#define CRED_MAX_VALUE_SIZE                 256
#define CRED_MAX_ATTRIBUTES                 64

#define CRED_MAX_BLOB_SIZE                  512

#define CREDUI_MAX_MESSAGE_LENGTH 32767
#define CREDUI_MAX_CAPTION_LENGTH 128
#define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH
#define CREDUI_MAX_DOMAIN_TARGET_LENGTH CRED_MAX_DOMAIN_TARGET_LENGTH
#define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH
#define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2)

195 196 197 198 199 200 201 202 203 204 205 206
/* flags for CREDENTIAL::Flags */
#define CRED_FLAGS_PASSWORD_FOR_CERT                0x0001
#define CRED_FLAGS_PROMPT_NOW                       0x0002
#define CRED_FLAGS_USERNAME_TARGET                  0x0004
#define CRED_FLAGS_OWF_CRED_BLOB                    0x0008
#define CRED_FLAGS_VALID_FLAGS                      0x000f

/* values for CREDENTIAL::Type */
#define CRED_TYPE_GENERIC                           1
#define CRED_TYPE_DOMAIN_PASSWORD                   2
#define CRED_TYPE_DOMAIN_CERTIFICATE                3
#define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD           4
207 208 209
#define CRED_TYPE_GENERIC_CERTIFICATE               5
#define CRED_TYPE_MAXIMUM                           6
#define CRED_TYPE_MAXIMUM_EX                        (CRED_TYPE_MAXIMUM+1000)
210 211 212 213 214 215 216

/* values for CREDENTIAL::Persist */
#define CRED_PERSIST_NONE                           0
#define CRED_PERSIST_SESSION                        1
#define CRED_PERSIST_LOCAL_MACHINE                  2
#define CRED_PERSIST_ENTERPRISE                     3

217 218 219 220 221
/* values for CREDENTIAL_TARGET_INFORMATION::Flags */
#define CRED_TI_SERVER_FORMAT_UNKNOWN               1
#define CRED_TI_DOMAIN_FORMAT_UNKNOWN               2
#define CRED_TI_ONLY_PASSWORD_REQUIRED              4

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
#define CREDUI_FLAGS_INCORRECT_PASSWORD             0x00000001
#define CREDUI_FLAGS_DO_NOT_PERSIST                 0x00000002
#define CREDUI_FLAGS_REQUEST_ADMINISTRATOR          0x00000004
#define CREDUI_FLAGS_EXCLUDE_CERTIFICATES           0x00000008
#define CREDUI_FLAGS_REQUIRE_CERTIFICATE            0x00000010
#define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX            0x00000040
#define CREDUI_FLAGS_ALWAYS_SHOW_UI                 0x00000080
#define CREDUI_FLAGS_REQUIRE_SMARTCARD              0x00000100
#define CREDUI_FLAGS_PASSWORD_ONLY_OK               0x00000200
#define CREDUI_FLAGS_VALIDATE_USERNAME              0x00000400
#define CREDUI_FLAGS_COMPLETE_USERNAME              0x00000800
#define CREDUI_FLAGS_PERSIST                        0x00001000
#define CREDUI_FLAGS_SERVER_CREDENTIAL              0x00004000
#define CREDUI_FLAGS_EXPECT_CONFIRMATION            0x00020000
#define CREDUI_FLAGS_GENERIC_CREDENTIALS            0x00040000
#define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS    0x00080000
#define CREDUI_FLAGS_KEEP_USERNAME                  0x00100000

240 241 242
/* flags for CredWrite and CredWriteDomainCredentials */
#define CRED_PRESERVE_CREDENTIAL_BLOB               0x00000001

243 244 245 246 247 248 249
WINADVAPI BOOL  WINAPI CredDeleteA(LPCSTR,DWORD,DWORD);
WINADVAPI BOOL  WINAPI CredDeleteW(LPCWSTR,DWORD,DWORD);
#define                CredDelete WINELIB_NAME_AW(CredDelete)
WINADVAPI BOOL  WINAPI CredEnumerateA(LPCSTR,DWORD,DWORD *,PCREDENTIALA **);
WINADVAPI BOOL  WINAPI CredEnumerateW(LPCWSTR,DWORD,DWORD *,PCREDENTIALW **);
#define                CredEnumerate WINELIB_NAME_AW(CredEnumerate)
WINADVAPI VOID  WINAPI CredFree(PVOID);
250
WINADVAPI BOOL  WINAPI CredGetSessionTypes(DWORD,LPDWORD);
251 252 253
WINADVAPI BOOL  WINAPI CredIsMarshaledCredentialA(LPCSTR);
WINADVAPI BOOL  WINAPI CredIsMarshaledCredentialW(LPCWSTR);
#define                CredIsMarshaledCredential WINELIB_NAME_AW(CredIsMarshaledCredential)
254 255 256
WINADVAPI BOOL  WINAPI CredMarshalCredentialA(CRED_MARSHAL_TYPE,PVOID,LPSTR *);
WINADVAPI BOOL  WINAPI CredMarshalCredentialW(CRED_MARSHAL_TYPE,PVOID,LPWSTR *);
#define                CredMarshalCredential WINELIB_NAME_AW(CredMarshalCredential)
257 258 259
WINADVAPI BOOL  WINAPI CredReadA(LPCSTR,DWORD,DWORD,PCREDENTIALA *);
WINADVAPI BOOL  WINAPI CredReadW(LPCWSTR,DWORD,DWORD,PCREDENTIALW *);
#define                CredRead WINELIB_NAME_AW(CredRead)
260 261 262
WINADVAPI BOOL  WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA,DWORD,DWORD *,PCREDENTIALA **);
WINADVAPI BOOL  WINAPI CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW,DWORD,DWORD *,PCREDENTIALW **);
#define                CredReadDomainCredentials WINELIB_NAME_AW(CredReadDomainCredentials)
263 264 265
WINADVAPI BOOL  WINAPI CredRenameA(LPCSTR,LPCSTR,DWORD,DWORD);
WINADVAPI BOOL  WINAPI CredRenameW(LPCWSTR,LPCWSTR,DWORD,DWORD);
#define                CredRename WINELIB_NAME_AW(CredRename)
266 267 268
WINADVAPI BOOL  WINAPI CredUnmarshalCredentialA(LPCSTR,PCRED_MARSHAL_TYPE,PVOID *);
WINADVAPI BOOL  WINAPI CredUnmarshalCredentialW(LPCWSTR,PCRED_MARSHAL_TYPE,PVOID *);
#define                CredUnmarshalCredential WINELIB_NAME_AW(CredUnmarshalCredential)
269 270 271
WINADVAPI BOOL  WINAPI CredWriteA(PCREDENTIALA,DWORD);
WINADVAPI BOOL  WINAPI CredWriteW(PCREDENTIALW,DWORD);
#define                CredWrite WINELIB_NAME_AW(CredWrite)
272

273 274
DWORD WINAPI CredUICmdLinePromptForCredentialsW(PCWSTR,PCtxtHandle,DWORD,PWSTR,ULONG,PWSTR,ULONG,PBOOL,DWORD);
DWORD WINAPI CredUICmdLinePromptForCredentialsA(PCSTR,PCtxtHandle,DWORD,PSTR,ULONG,PSTR,ULONG,PBOOL,DWORD);
275 276 277 278 279 280 281
#define      CredUICmdLinePromptForCredentials WINELIB_NAME_AW(CredUICmdLinePromptForCredentials)
DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR,BOOL);
DWORD WINAPI CredUIConfirmCredentialsA(PCSTR,BOOL);
#define      CredUIConfirmCredentials WINELIB_NAME_AW(CredUIConfirmCredentials)
DWORD WINAPI CredUIParseUserNameW(PCWSTR,PWSTR,ULONG,PWSTR,ULONG);
DWORD WINAPI CredUIParseUserNameA(PCSTR,PSTR,ULONG,PSTR,ULONG);
#define      CredUIParseUserName WINELIB_NAME_AW(CredUIParseUserName)
282 283
DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW,PCWSTR,PCtxtHandle,DWORD,PWSTR,ULONG,PWSTR,ULONG,PBOOL,DWORD);
DWORD WINAPI CredUIPromptForCredentialsA(PCREDUI_INFOA,PCSTR,PCtxtHandle,DWORD,PSTR,ULONG,PSTR,ULONG,PBOOL,DWORD);
284 285 286 287 288 289
#define      CredUIPromptForCredentials WINELIB_NAME_AW(CredUIPromptForCredentials)
DWORD WINAPI CredUIStoreSSOCredW(PCWSTR,PCWSTR,PCWSTR,BOOL);
/* Note: no CredUIStoreSSOCredA in PSDK header */
DWORD WINAPI CredUIReadSSOCredW(PCWSTR,PWSTR*);
/* Note: no CredUIReadSSOCredA in PSDK header */

290 291 292 293
#ifdef __cplusplus
}
#endif

294
#endif /* _WINCRED_H_ */