1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! Types and macros for Subauthentication Packages.
7 use shared::minwindef::{PUCHAR, ULONG, USHORT};
8 use um::winnt::{BOOLEAN, CHAR, LARGE_INTEGER, LONG, PCHAR, PVOID, PWSTR};
9 STRUCT!{struct UNICODE_STRING {
10     Length: USHORT,
11     MaximumLength: USHORT,
12     Buffer: PWSTR,
13 }}
14 pub type PUNICODE_STRING = *mut UNICODE_STRING;
15 STRUCT!{struct STRING {
16     Length: USHORT,
17     MaximumLength: USHORT,
18     Buffer: PCHAR,
19 }}
20 pub type PSTRING = *mut STRING;
21 STRUCT!{struct OLD_LARGE_INTEGER {
22     LowPart: ULONG,
23     HighPart: LONG,
24 }}
25 pub type POLD_LARGE_INTEGER = *mut OLD_LARGE_INTEGER;
26 pub type SAM_HANDLE = PVOID;
27 pub type PSAM_HANDLE = *mut PVOID;
28 pub const USER_ACCOUNT_DISABLED: ULONG = 0x00000001;
29 pub const USER_HOME_DIRECTORY_REQUIRED: ULONG = 0x00000002;
30 pub const USER_PASSWORD_NOT_REQUIRED: ULONG = 0x00000004;
31 pub const USER_TEMP_DUPLICATE_ACCOUNT: ULONG = 0x00000008;
32 pub const USER_NORMAL_ACCOUNT: ULONG = 0x00000010;
33 pub const USER_MNS_LOGON_ACCOUNT: ULONG = 0x00000020;
34 pub const USER_INTERDOMAIN_TRUST_ACCOUNT: ULONG = 0x00000040;
35 pub const USER_WORKSTATION_TRUST_ACCOUNT: ULONG = 0x00000080;
36 pub const USER_SERVER_TRUST_ACCOUNT: ULONG = 0x00000100;
37 pub const USER_DONT_EXPIRE_PASSWORD: ULONG = 0x00000200;
38 pub const USER_ACCOUNT_AUTO_LOCKED: ULONG = 0x00000400;
39 pub const USER_ENCRYPTED_TEXT_PASSWORD_ALLOWED: ULONG = 0x00000800;
40 pub const USER_SMARTCARD_REQUIRED: ULONG = 0x00001000;
41 pub const USER_TRUSTED_FOR_DELEGATION: ULONG = 0x00002000;
42 pub const USER_NOT_DELEGATED: ULONG = 0x00004000;
43 pub const USER_USE_DES_KEY_ONLY: ULONG = 0x00008000;
44 pub const USER_DONT_REQUIRE_PREAUTH: ULONG = 0x00010000;
45 pub const USER_PASSWORD_EXPIRED: ULONG = 0x00020000;
46 pub const USER_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION: ULONG = 0x00040000;
47 pub const USER_NO_AUTH_DATA_REQUIRED: ULONG = 0x00080000;
48 pub const USER_PARTIAL_SECRETS_ACCOUNT: ULONG = 0x00100000;
49 pub const USER_USE_AES_KEYS: ULONG = 0x00200000;
50 pub const NEXT_FREE_ACCOUNT_CONTROL_BIT: ULONG = USER_USE_AES_KEYS << 1;
51 pub const USER_MACHINE_ACCOUNT_MASK: ULONG = USER_INTERDOMAIN_TRUST_ACCOUNT
52     | USER_WORKSTATION_TRUST_ACCOUNT | USER_SERVER_TRUST_ACCOUNT;
53 pub const USER_ACCOUNT_TYPE_MASK: ULONG = USER_TEMP_DUPLICATE_ACCOUNT | USER_NORMAL_ACCOUNT
54     | USER_MACHINE_ACCOUNT_MASK;
55 pub const USER_COMPUTED_ACCOUNT_CONTROL_BITS: ULONG = USER_ACCOUNT_AUTO_LOCKED
56     | USER_PASSWORD_EXPIRED;
57 pub const SAM_DAYS_PER_WEEK: USHORT = 7;
58 pub const SAM_HOURS_PER_WEEK: USHORT = 24 * SAM_DAYS_PER_WEEK;
59 pub const SAM_MINUTES_PER_WEEK: USHORT = 60 * SAM_HOURS_PER_WEEK;
60 STRUCT!{struct LOGON_HOURS {
61     UnitsPerWeek: USHORT,
62     LogonHours: PUCHAR,
63 }}
64 pub type PLOGON_HOURS = *mut LOGON_HOURS;
65 STRUCT!{struct SR_SECURITY_DESCRIPTOR {
66     Length: ULONG,
67     SecurityDescriptor: PUCHAR,
68 }}
69 pub type PSR_SECURITY_DESCRIPTOR = *mut SR_SECURITY_DESCRIPTOR;
70 STRUCT!{struct USER_ALL_INFORMATION {
71     LastLogon: LARGE_INTEGER,
72     LastLogoff: LARGE_INTEGER,
73     PasswordLastSet: LARGE_INTEGER,
74     AccountExpires: LARGE_INTEGER,
75     PasswordCanChange: LARGE_INTEGER,
76     PasswordMustChange: LARGE_INTEGER,
77     UserName: UNICODE_STRING,
78     FullName: UNICODE_STRING,
79     HomeDirectory: UNICODE_STRING,
80     HomeDirectoryDrive: UNICODE_STRING,
81     ScriptPath: UNICODE_STRING,
82     ProfilePath: UNICODE_STRING,
83     AdminComment: UNICODE_STRING,
84     WorkStations: UNICODE_STRING,
85     UserComment: UNICODE_STRING,
86     Parameters: UNICODE_STRING,
87     LmPassword: UNICODE_STRING,
88     NtPassword: UNICODE_STRING,
89     PrivateData: UNICODE_STRING,
90     SecurityDescriptor: SR_SECURITY_DESCRIPTOR,
91     UserId: ULONG,
92     PrimaryGroupId: ULONG,
93     UserAccountControl: ULONG,
94     WhichFields: ULONG,
95     LogonHours: LOGON_HOURS,
96     BadPasswordCount: USHORT,
97     LogonCount: USHORT,
98     CountryCode: USHORT,
99     CodePage: USHORT,
100     LmPasswordPresent: BOOLEAN,
101     NtPasswordPresent: BOOLEAN,
102     PasswordExpired: BOOLEAN,
103     PrivateDataSensitive: BOOLEAN,
104 }}
105 pub type PUSER_ALL_INFORMATION = *mut USER_ALL_INFORMATION;
106 pub const USER_ALL_PARAMETERS: ULONG = 0x00200000;
107 pub const CLEAR_BLOCK_LENGTH: usize = 8;
108 STRUCT!{struct CLEAR_BLOCK {
109     data: [CHAR; CLEAR_BLOCK_LENGTH],
110 }}
111 pub type PCLEAR_BLOCK = *mut CLEAR_BLOCK;
112 pub const CYPHER_BLOCK_LENGTH: usize = 8;
113 STRUCT!{struct CYPHER_BLOCK {
114     data: [CHAR; CYPHER_BLOCK_LENGTH],
115 }}
116 pub type PCYPHER_BLOCK = *mut CYPHER_BLOCK;
117 STRUCT!{struct LM_OWF_PASSWORD {
118     data: [CYPHER_BLOCK; 2],
119 }}
120 pub type PLM_OWF_PASSWORD = *mut LM_OWF_PASSWORD;
121 pub type LM_CHALLENGE = CLEAR_BLOCK;
122 pub type PLM_CHALLENGE = *mut LM_CHALLENGE;
123 pub type NT_OWF_PASSWORD = LM_OWF_PASSWORD;
124 pub type PNT_OWF_PASSWORD = *mut NT_OWF_PASSWORD;
125 pub type NT_CHALLENGE = LM_CHALLENGE;
126 pub type PNT_CHALLENGE = *mut NT_CHALLENGE;
127 pub const USER_SESSION_KEY_LENGTH: usize = CYPHER_BLOCK_LENGTH * 2;
128 STRUCT!{struct USER_SESSION_KEY {
129     data: [CYPHER_BLOCK; 2],
130 }}
131 pub type PUSER_SESSION_KEY = *mut USER_SESSION_KEY;
132 ENUM!{enum NETLOGON_LOGON_INFO_CLASS {
133     NetlogonInteractiveInformation = 1,
134     NetlogonNetworkInformation,
135     NetlogonServiceInformation,
136     NetlogonGenericInformation,
137     NetlogonInteractiveTransitiveInformation,
138     NetlogonNetworkTransitiveInformation,
139     NetlogonServiceTransitiveInformation,
140 }}
141 STRUCT!{struct NETLOGON_LOGON_IDENTITY_INFO {
142     LogonDomainName: UNICODE_STRING,
143     ParameterControl: ULONG,
144     LogonId: OLD_LARGE_INTEGER,
145     UserName: UNICODE_STRING,
146     Workstation: UNICODE_STRING,
147 }}
148 pub type PNETLOGON_LOGON_IDENTITY_INFO = *mut NETLOGON_LOGON_IDENTITY_INFO;
149 STRUCT!{struct NETLOGON_INTERACTIVE_INFO {
150     Identity: NETLOGON_LOGON_IDENTITY_INFO,
151     LmOwfPassword: LM_OWF_PASSWORD,
152     NtOwfPassword: NT_OWF_PASSWORD,
153 }}
154 pub type PNETLOGON_INTERACTIVE_INFO = *mut NETLOGON_INTERACTIVE_INFO;
155 STRUCT!{struct NETLOGON_SERVICE_INFO {
156     Identity: NETLOGON_LOGON_IDENTITY_INFO,
157     LmOwfPassword: LM_OWF_PASSWORD,
158     NtOwfPassword: NT_OWF_PASSWORD,
159 }}
160 pub type PNETLOGON_SERVICE_INFO = *mut NETLOGON_SERVICE_INFO;
161 STRUCT!{struct NETLOGON_NETWORK_INFO {
162     Identity: NETLOGON_LOGON_IDENTITY_INFO,
163     LmChallenge: LM_CHALLENGE,
164     NtChallengeResponse: STRING,
165     LmChallengeResponse: STRING,
166 }}
167 pub type PNETLOGON_NETWORK_INFO = *mut NETLOGON_NETWORK_INFO;
168 STRUCT!{struct NETLOGON_GENERIC_INFO {
169     Identity: NETLOGON_LOGON_IDENTITY_INFO,
170     PackageName: UNICODE_STRING,
171     DataLength: ULONG,
172     LogonData: PUCHAR,
173 }}
174 pub type PNETLOGON_GENERIC_INFO = *mut NETLOGON_GENERIC_INFO;
175 pub const MSV1_0_PASSTHRU: ULONG = 0x01;
176 pub const MSV1_0_GUEST_LOGON: ULONG = 0x02;
177 STRUCT!{struct MSV1_0_VALIDATION_INFO {
178     LogoffTime: LARGE_INTEGER,
179     KickoffTime: LARGE_INTEGER,
180     LogonServer: UNICODE_STRING,
181     LogonDomainName: UNICODE_STRING,
182     SessionKey: USER_SESSION_KEY,
183     Authoritative: BOOLEAN,
184     UserFlags: ULONG,
185     WhichFields: ULONG,
186     UserId: ULONG,
187 }}
188 pub type PMSV1_0_VALIDATION_INFO = *mut MSV1_0_VALIDATION_INFO;
189 pub const MSV1_0_VALIDATION_LOGOFF_TIME: ULONG = 0x00000001;
190 pub const MSV1_0_VALIDATION_KICKOFF_TIME: ULONG = 0x00000002;
191 pub const MSV1_0_VALIDATION_LOGON_SERVER: ULONG = 0x00000004;
192 pub const MSV1_0_VALIDATION_LOGON_DOMAIN: ULONG = 0x00000008;
193 pub const MSV1_0_VALIDATION_SESSION_KEY: ULONG = 0x00000010;
194 pub const MSV1_0_VALIDATION_USER_FLAGS: ULONG = 0x00000020;
195 pub const MSV1_0_VALIDATION_USER_ID: ULONG = 0x00000040;
196 pub const MSV1_0_SUBAUTH_ACCOUNT_DISABLED: ULONG = 0x00000001;
197 pub const MSV1_0_SUBAUTH_PASSWORD: ULONG = 0x00000002;
198 pub const MSV1_0_SUBAUTH_WORKSTATIONS: ULONG = 0x00000004;
199 pub const MSV1_0_SUBAUTH_LOGON_HOURS: ULONG = 0x00000008;
200 pub const MSV1_0_SUBAUTH_ACCOUNT_EXPIRY: ULONG = 0x00000010;
201 pub const MSV1_0_SUBAUTH_PASSWORD_EXPIRY: ULONG = 0x00000020;
202 pub const MSV1_0_SUBAUTH_ACCOUNT_TYPE: ULONG = 0x00000040;
203 pub const MSV1_0_SUBAUTH_LOCKOUT: ULONG = 0x00000080;
204 // STATUS_*
205