[DDK]
[reactos.git] / include / psdk / wincred.h
1 /*
2 * Copyright (C) 2006 Robert Shearman (for CodeWeavers)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef _WINCRED_H_
20 #define _WINCRED_H_
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #ifndef __SECHANDLE_DEFINED__
27 #define __SECHANDLE_DEFINED__
28 typedef struct _SecHandle
29 {
30 ULONG_PTR dwLower;
31 ULONG_PTR dwUpper;
32 } SecHandle, *PSecHandle;
33 #endif
34
35 typedef SecHandle CtxtHandle;
36 typedef PSecHandle PCtxtHandle;
37
38 typedef struct _CREDENTIAL_ATTRIBUTEA
39 {
40 LPSTR Keyword;
41 DWORD Flags;
42 DWORD ValueSize;
43 LPBYTE Value;
44 } CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA;
45
46 typedef struct _CREDENTIAL_ATTRIBUTEW
47 {
48 LPWSTR Keyword;
49 DWORD Flags;
50 DWORD ValueSize;
51 LPBYTE Value;
52 } CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
53
54 DECL_WINELIB_TYPE_AW(CREDENTIAL_ATTRIBUTE)
55 DECL_WINELIB_TYPE_AW(PCREDENTIAL_ATTRIBUTE)
56
57 typedef struct _CREDENTIALA
58 {
59 DWORD Flags;
60 DWORD Type;
61 LPSTR TargetName;
62 LPSTR Comment;
63 FILETIME LastWritten;
64 DWORD CredentialBlobSize;
65 LPBYTE CredentialBlob;
66 DWORD Persist;
67 DWORD AttributeCount;
68 PCREDENTIAL_ATTRIBUTEA Attributes;
69 LPSTR TargetAlias;
70 LPSTR UserName;
71 } CREDENTIALA, *PCREDENTIALA;
72
73 typedef struct _CREDENTIALW
74 {
75 DWORD Flags;
76 DWORD Type;
77 LPWSTR TargetName;
78 LPWSTR Comment;
79 FILETIME LastWritten;
80 DWORD CredentialBlobSize;
81 LPBYTE CredentialBlob;
82 DWORD Persist;
83 DWORD AttributeCount;
84 PCREDENTIAL_ATTRIBUTEW Attributes;
85 LPWSTR TargetAlias;
86 LPWSTR UserName;
87 } CREDENTIALW, *PCREDENTIALW;
88
89 DECL_WINELIB_TYPE_AW(CREDENTIAL)
90 DECL_WINELIB_TYPE_AW(PCREDENTIAL)
91
92 typedef struct _CREDUI_INFOA
93 {
94 DWORD cbSize;
95 HWND hwndParent;
96 PCSTR pszMessageText;
97 PCSTR pszCaptionText;
98 HBITMAP hbmBanner;
99 } CREDUI_INFOA, *PCREDUI_INFOA;
100
101 typedef struct _CREDUI_INFOW
102 {
103 DWORD cbSize;
104 HWND hwndParent;
105 PCWSTR pszMessageText;
106 PCWSTR pszCaptionText;
107 HBITMAP hbmBanner;
108 } CREDUI_INFOW, *PCREDUI_INFOW;
109
110 typedef enum _CRED_MARSHAL_TYPE {
111 CertCredential = 1,
112 UsernameTargetCredential
113 } CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE;
114
115 typedef struct _CREDENTIAL_TARGET_INFORMATIONA {
116 LPSTR TargetName;
117 LPSTR NetbiosServerName;
118 LPSTR DnsServerName;
119 LPSTR NetbiosDomainName;
120 LPSTR DnsDomainName;
121 LPSTR DnsTreeName;
122 LPSTR PackageName;
123 ULONG Flags;
124 DWORD CredTypeCount;
125 LPDWORD CredTypes;
126 } CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA;
127
128 typedef struct _CREDENTIAL_TARGET_INFORMATIONW {
129 LPWSTR TargetName;
130 LPWSTR NetbiosServerName;
131 LPWSTR DnsServerName;
132 LPWSTR NetbiosDomainName;
133 LPWSTR DnsDomainName;
134 LPWSTR DnsTreeName;
135 LPWSTR PackageName;
136 ULONG Flags;
137 DWORD CredTypeCount;
138 LPDWORD CredTypes;
139 } CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW;
140
141 #ifdef UNICODE
142 typedef CREDENTIAL_TARGET_INFORMATIONW CREDENTIAL_TARGET_INFORMATION;
143 typedef PCREDENTIAL_TARGET_INFORMATIONW PCREDENTIAL_TARGET_INFORMATION;
144 #else
145 typedef CREDENTIAL_TARGET_INFORMATIONA CREDENTIAL_TARGET_INFORMATION;
146 typedef PCREDENTIAL_TARGET_INFORMATIONA PCREDENTIAL_TARGET_INFORMATION;
147 #endif /* UNICODE */
148
149 DECL_WINELIB_TYPE_AW(CREDUI_INFO)
150 DECL_WINELIB_TYPE_AW(PCREDUI_INFO)
151
152 #define CRED_MAX_STRING_LENGTH 256
153 #define CRED_MAX_USERNAME_LENGTH 513
154 #define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767
155 #define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH 337
156 #define CRED_MAX_VALUE_SIZE 256
157 #define CRED_MAX_ATTRIBUTES 64
158
159 #define CRED_MAX_BLOB_SIZE 512
160
161 #define CREDUI_MAX_MESSAGE_LENGTH 32767
162 #define CREDUI_MAX_CAPTION_LENGTH 128
163 #define CREDUI_MAX_GENERIC_TARGET_LENGTH CRED_MAX_GENERIC_TARGET_NAME_LENGTH
164 #define CREDUI_MAX_DOMAIN_TARGET_LENGTH CRED_MAX_DOMAIN_TARGET_LENGTH
165 #define CREDUI_MAX_USERNAME_LENGTH CRED_MAX_USERNAME_LENGTH
166 #define CREDUI_MAX_PASSWORD_LENGTH (CRED_MAX_CREDENTIAL_BLOB_SIZE / 2)
167
168 /* flags for CREDENTIAL::Flags */
169 #define CRED_FLAGS_PASSWORD_FOR_CERT 0x0001
170 #define CRED_FLAGS_PROMPT_NOW 0x0002
171 #define CRED_FLAGS_USERNAME_TARGET 0x0004
172 #define CRED_FLAGS_OWF_CRED_BLOB 0x0008
173 #define CRED_FLAGS_VALID_FLAGS 0x000f
174
175 /* values for CREDENTIAL::Type */
176 #define CRED_TYPE_GENERIC 1
177 #define CRED_TYPE_DOMAIN_PASSWORD 2
178 #define CRED_TYPE_DOMAIN_CERTIFICATE 3
179 #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4
180 #define CRED_TYPE_MAXIMUM 5
181
182 /* values for CREDENTIAL::Persist */
183 #define CRED_PERSIST_NONE 0
184 #define CRED_PERSIST_SESSION 1
185 #define CRED_PERSIST_LOCAL_MACHINE 2
186 #define CRED_PERSIST_ENTERPRISE 3
187
188 #define CREDUI_FLAGS_INCORRECT_PASSWORD 0x00000001
189 #define CREDUI_FLAGS_DO_NOT_PERSIST 0x00000002
190 #define CREDUI_FLAGS_REQUEST_ADMINISTRATOR 0x00000004
191 #define CREDUI_FLAGS_EXCLUDE_CERTIFICATES 0x00000008
192 #define CREDUI_FLAGS_REQUIRE_CERTIFICATE 0x00000010
193 #define CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX 0x00000040
194 #define CREDUI_FLAGS_ALWAYS_SHOW_UI 0x00000080
195 #define CREDUI_FLAGS_REQUIRE_SMARTCARD 0x00000100
196 #define CREDUI_FLAGS_PASSWORD_ONLY_OK 0x00000200
197 #define CREDUI_FLAGS_VALIDATE_USERNAME 0x00000400
198 #define CREDUI_FLAGS_COMPLETE_USERNAME 0x00000800
199 #define CREDUI_FLAGS_PERSIST 0x00001000
200 #define CREDUI_FLAGS_SERVER_CREDENTIAL 0x00004000
201 #define CREDUI_FLAGS_EXPECT_CONFIRMATION 0x00020000
202 #define CREDUI_FLAGS_GENERIC_CREDENTIALS 0x00040000
203 #define CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS 0x00080000
204 #define CREDUI_FLAGS_KEEP_USERNAME 0x00100000
205
206 /* flags for CredWrite and CredWriteDomainCredentials */
207 #define CRED_PRESERVE_CREDENTIAL_BLOB 0x00000001
208
209 BOOL WINAPI CredDeleteA(LPCSTR,DWORD,DWORD);
210 BOOL WINAPI CredDeleteW(LPCWSTR,DWORD,DWORD);
211 #define CredDelete WINELIB_NAME_AW(CredDelete)
212 BOOL WINAPI CredEnumerateA(LPCSTR,DWORD,DWORD *,PCREDENTIALA **);
213 BOOL WINAPI CredEnumerateW(LPCWSTR,DWORD,DWORD *,PCREDENTIALW **);
214 #define CredEnumerate WINELIB_NAME_AW(CredEnumerate)
215 VOID WINAPI CredFree(PVOID);
216 BOOL WINAPI CredReadA(LPCSTR,DWORD,DWORD,PCREDENTIALA *);
217 BOOL WINAPI CredReadW(LPCWSTR,DWORD,DWORD,PCREDENTIALW *);
218 #define CredRead WINELIB_NAME_AW(CredRead)
219 BOOL WINAPI CredRenameA(LPCSTR,LPCSTR,DWORD,DWORD);
220 BOOL WINAPI CredRenameW(LPCWSTR,LPCWSTR,DWORD,DWORD);
221 #define CredRename WINELIB_NAME_AW(CredRename)
222 BOOL WINAPI CredWriteA(PCREDENTIALA,DWORD);
223 BOOL WINAPI CredWriteW(PCREDENTIALW,DWORD);
224 #define CredWrite WINELIB_NAME_AW(CredWrite)
225
226 DWORD WINAPI CredUICmdLinePromptForCredentialsW(PCWSTR,PCtxtHandle,DWORD,PWSTR,ULONG,PWSTR,ULONG,PBOOL,DWORD);
227 DWORD WINAPI CredUICmdLinePromptForCredentialsA(PCSTR,PCtxtHandle,DWORD,PSTR,ULONG,PSTR,ULONG,PBOOL,DWORD);
228 #define CredUICmdLinePromptForCredentials WINELIB_NAME_AW(CredUICmdLinePromptForCredentials)
229 DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR,BOOL);
230 DWORD WINAPI CredUIConfirmCredentialsA(PCSTR,BOOL);
231 #define CredUIConfirmCredentials WINELIB_NAME_AW(CredUIConfirmCredentials)
232 DWORD WINAPI CredUIParseUserNameW(PCWSTR,PWSTR,ULONG,PWSTR,ULONG);
233 DWORD WINAPI CredUIParseUserNameA(PCSTR,PSTR,ULONG,PSTR,ULONG);
234 #define CredUIParseUserName WINELIB_NAME_AW(CredUIParseUserName)
235 DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW,PCWSTR,PCtxtHandle,DWORD,PWSTR,ULONG,PWSTR,ULONG,PBOOL,DWORD);
236 DWORD WINAPI CredUIPromptForCredentialsA(PCREDUI_INFOA,PCSTR,PCtxtHandle,DWORD,PSTR,ULONG,PSTR,ULONG,PBOOL,DWORD);
237 #define CredUIPromptForCredentials WINELIB_NAME_AW(CredUIPromptForCredentials)
238 DWORD WINAPI CredUIStoreSSOCredW(PCWSTR,PCWSTR,PCWSTR,BOOL);
239 /* Note: no CredUIStoreSSOCredA in PSDK header */
240 DWORD WINAPI CredUIReadSSOCredW(PCWSTR,PWSTR*);
241 /* Note: no CredUIReadSSOCredA in PSDK header */
242
243 BOOL WINAPI CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, DWORD Flags, DWORD *Count, PCREDENTIALW **Credential);
244 BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, DWORD Flags, DWORD *Count, PCREDENTIALA **Credential);
245 BOOL WINAPI CredWriteDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, PCREDENTIALW Credential, DWORD Flags);
246 BOOL WINAPI CredWriteDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, PCREDENTIALA Credential, DWORD Flags);
247 BOOL WINAPI CredUnmarshalCredentialW(LPCWSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID *Credential);
248 BOOL WINAPI CredUnmarshalCredentialA(LPCSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID *Credential);
249
250 #ifdef UNICODE
251 #define CredReadDomainCredentials CredReadDomainCredentialsW
252 #define CredWriteDomainCredentials CredWriteDomainCredentialsW
253 #define CredUnmarshalCredential CredUnmarshalCredentialW
254 #else
255 #define CredReadDomainCredentials CredReadDomainCredentialsA
256 #define CredWriteDomainCredentials CredWriteDomainCredentialsA
257 #define CredUnmarshalCredential CredUnmarshalCredentialA
258 #endif /* UNICODE */
259
260 #ifdef __cplusplus
261 }
262 #endif
263
264 #endif /* _WINCRED_H_ */