2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Guenther Deschner 2008.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 /*******************************************************************
24 ********************************************************************/
26 void init_samr_DomInfo1(struct samr_DomInfo1 *r,
27 uint16_t min_password_length,
28 uint16_t password_history_length,
29 uint32_t password_properties,
30 int64_t max_password_age,
31 int64_t min_password_age)
33 r->min_password_length = min_password_length;
34 r->password_history_length = password_history_length;
35 r->password_properties = password_properties;
36 r->max_password_age = max_password_age;
37 r->min_password_age = min_password_age;
40 /*******************************************************************
42 ********************************************************************/
44 void init_samr_DomGeneralInformation(struct samr_DomGeneralInformation *r,
45 NTTIME force_logoff_time,
46 const char *oem_information,
47 const char *domain_name,
49 uint64_t sequence_num,
50 enum samr_DomainServerState domain_server_state,
57 r->force_logoff_time = force_logoff_time;
58 init_lsa_String(&r->oem_information, oem_information);
59 init_lsa_String(&r->domain_name, domain_name);
60 init_lsa_String(&r->primary, primary);
61 r->sequence_num = sequence_num;
62 r->domain_server_state = domain_server_state;
64 r->unknown3 = unknown3;
65 r->num_users = num_users;
66 r->num_groups = num_groups;
67 r->num_aliases = num_aliases;
70 /*******************************************************************
72 ********************************************************************/
74 void init_samr_DomInfo3(struct samr_DomInfo3 *r,
75 NTTIME force_logoff_time)
77 r->force_logoff_time = force_logoff_time;
80 /*******************************************************************
82 ********************************************************************/
84 void init_samr_DomOEMInformation(struct samr_DomOEMInformation *r,
85 const char *oem_information)
87 init_lsa_String(&r->oem_information, oem_information);
90 /*******************************************************************
92 ********************************************************************/
94 void init_samr_DomInfo5(struct samr_DomInfo5 *r,
95 const char *domain_name)
97 init_lsa_String(&r->domain_name, domain_name);
100 /*******************************************************************
102 ********************************************************************/
104 void init_samr_DomInfo6(struct samr_DomInfo6 *r,
107 init_lsa_String(&r->primary, primary);
110 /*******************************************************************
112 ********************************************************************/
114 void init_samr_DomInfo7(struct samr_DomInfo7 *r,
120 /*******************************************************************
122 ********************************************************************/
124 void init_samr_DomInfo8(struct samr_DomInfo8 *r,
125 uint64_t sequence_num,
126 NTTIME domain_create_time)
128 r->sequence_num = sequence_num;
129 r->domain_create_time = domain_create_time;
132 /*******************************************************************
134 ********************************************************************/
136 void init_samr_DomInfo9(struct samr_DomInfo9 *r,
137 enum samr_DomainServerState domain_server_state)
139 r->domain_server_state = domain_server_state;
143 /*******************************************************************
145 ********************************************************************/
147 void init_samr_DomInfo12(struct samr_DomInfo12 *r,
148 uint64_t lockout_duration,
149 uint64_t lockout_window,
150 uint16_t lockout_threshold)
152 r->lockout_duration = lockout_duration;
153 r->lockout_window = lockout_window;
154 r->lockout_threshold = lockout_threshold;
157 /*******************************************************************
158 inits a samr_GroupInfoAll structure.
159 ********************************************************************/
161 void init_samr_group_info1(struct samr_GroupInfoAll *r,
164 uint32_t num_members,
165 const char *description)
167 DEBUG(5, ("init_samr_group_info1\n"));
169 init_lsa_String(&r->name, name);
170 r->attributes = attributes;
171 r->num_members = num_members;
172 init_lsa_String(&r->description, description);
175 /*******************************************************************
176 inits a lsa_String structure
177 ********************************************************************/
179 void init_samr_group_info2(struct lsa_String *r, const char *group_name)
181 DEBUG(5, ("init_samr_group_info2\n"));
183 init_lsa_String(r, group_name);
186 /*******************************************************************
187 inits a samr_GroupInfoAttributes structure.
188 ********************************************************************/
190 void init_samr_group_info3(struct samr_GroupInfoAttributes *r,
193 DEBUG(5, ("init_samr_group_info3\n"));
195 r->attributes = attributes;
198 /*******************************************************************
199 inits a lsa_String structure
200 ********************************************************************/
202 void init_samr_group_info4(struct lsa_String *r, const char *description)
204 DEBUG(5, ("init_samr_group_info4\n"));
206 init_lsa_String(r, description);
209 /*******************************************************************
210 inits a samr_GroupInfoAll structure.
211 ********************************************************************/
213 void init_samr_group_info5(struct samr_GroupInfoAll *r,
216 uint32_t num_members,
217 const char *description)
219 DEBUG(5, ("init_samr_group_info5\n"));
221 init_lsa_String(&r->name, name);
222 r->attributes = attributes;
223 r->num_members = num_members;
224 init_lsa_String(&r->description, description);
227 /*******************************************************************
228 inits a samr_AliasInfoAll structure.
229 ********************************************************************/
231 void init_samr_alias_info1(struct samr_AliasInfoAll *r,
233 uint32_t num_members,
234 const char *description)
236 DEBUG(5, ("init_samr_alias_info1\n"));
238 init_lsa_String(&r->name, name);
239 r->num_members = num_members;
240 init_lsa_String(&r->description, description);
243 /*******************************************************************
244 inits a lsa_String structure.
245 ********************************************************************/
247 void init_samr_alias_info3(struct lsa_String *r,
248 const char *description)
250 DEBUG(5, ("init_samr_alias_info3\n"));
252 init_lsa_String(r, description);
255 /*************************************************************************
256 inits a samr_CryptPasswordEx structure
257 *************************************************************************/
259 void init_samr_CryptPasswordEx(const char *pwd,
260 DATA_BLOB *session_key,
261 struct samr_CryptPasswordEx *pwd_buf)
263 /* samr_CryptPasswordEx */
266 struct MD5Context md5_ctx;
267 uint8_t confounder[16];
268 DATA_BLOB confounded_session_key = data_blob(NULL, 16);
270 encode_pw_buffer(pwbuf, pwd, STR_UNICODE);
272 generate_random_buffer((uint8_t *)confounder, 16);
275 MD5Update(&md5_ctx, confounder, 16);
276 MD5Update(&md5_ctx, session_key->data,
277 session_key->length);
278 MD5Final(confounded_session_key.data, &md5_ctx);
280 SamOEMhashBlob(pwbuf, 516, &confounded_session_key);
281 memcpy(&pwbuf[516], confounder, 16);
283 memcpy(pwd_buf->data, pwbuf, sizeof(pwbuf));
284 data_blob_free(&confounded_session_key);
287 /*************************************************************************
288 inits a samr_CryptPassword structure
289 *************************************************************************/
291 void init_samr_CryptPassword(const char *pwd,
292 DATA_BLOB *session_key,
293 struct samr_CryptPassword *pwd_buf)
295 /* samr_CryptPassword */
297 encode_pw_buffer(pwd_buf->data, pwd, STR_UNICODE);
298 SamOEMhashBlob(pwd_buf->data, 516, session_key);