2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997.
7 * Copyright (C) Jean François Micouleau 2002.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define DBGC_CLASS DBGC_RPC_PARSE
29 /*******************************************************************
30 Reads or writes a structure.
31 ********************************************************************/
33 static BOOL
net_io_neg_flags(const char *desc
, NEG_FLAGS
*neg
, prs_struct
*ps
, int depth
)
38 prs_debug(ps
, depth
, desc
, "net_io_neg_flags");
44 if(!prs_uint32("neg_flags", ps
, depth
, &neg
->neg_flags
))
50 /*******************************************************************
51 Inits a NETLOGON_INFO_3 structure.
52 ********************************************************************/
54 static void init_netinfo_3(NETLOGON_INFO_3
*info
, uint32 flags
, uint32 logon_attempts
)
57 info
->logon_attempts
= logon_attempts
;
58 info
->reserved_1
= 0x0;
59 info
->reserved_2
= 0x0;
60 info
->reserved_3
= 0x0;
61 info
->reserved_4
= 0x0;
62 info
->reserved_5
= 0x0;
65 /*******************************************************************
66 Reads or writes a NETLOGON_INFO_3 structure.
67 ********************************************************************/
69 static BOOL
net_io_netinfo_3(const char *desc
, NETLOGON_INFO_3
*info
, prs_struct
*ps
, int depth
)
74 prs_debug(ps
, depth
, desc
, "net_io_netinfo_3");
80 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
82 if(!prs_uint32("logon_attempts", ps
, depth
, &info
->logon_attempts
))
84 if(!prs_uint32("reserved_1 ", ps
, depth
, &info
->reserved_1
))
86 if(!prs_uint32("reserved_2 ", ps
, depth
, &info
->reserved_2
))
88 if(!prs_uint32("reserved_3 ", ps
, depth
, &info
->reserved_3
))
90 if(!prs_uint32("reserved_4 ", ps
, depth
, &info
->reserved_4
))
92 if(!prs_uint32("reserved_5 ", ps
, depth
, &info
->reserved_5
))
99 /*******************************************************************
100 Inits a NETLOGON_INFO_1 structure.
101 ********************************************************************/
103 static void init_netinfo_1(NETLOGON_INFO_1
*info
, uint32 flags
, uint32 pdc_status
)
106 info
->pdc_status
= pdc_status
;
109 /*******************************************************************
110 Reads or writes a NETLOGON_INFO_1 structure.
111 ********************************************************************/
113 static BOOL
net_io_netinfo_1(const char *desc
, NETLOGON_INFO_1
*info
, prs_struct
*ps
, int depth
)
118 prs_debug(ps
, depth
, desc
, "net_io_netinfo_1");
124 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
126 if(!prs_uint32("pdc_status", ps
, depth
, &info
->pdc_status
))
132 /*******************************************************************
133 Inits a NETLOGON_INFO_2 structure.
134 ********************************************************************/
136 static void init_netinfo_2(NETLOGON_INFO_2
*info
, uint32 flags
, uint32 pdc_status
,
137 uint32 tc_status
, const char *trusted_dc_name
)
140 info
->pdc_status
= pdc_status
;
141 info
->ptr_trusted_dc_name
= 1;
142 info
->tc_status
= tc_status
;
144 if (trusted_dc_name
!= NULL
)
145 init_unistr2(&info
->uni_trusted_dc_name
, trusted_dc_name
, UNI_STR_TERMINATE
);
147 init_unistr2(&info
->uni_trusted_dc_name
, "", UNI_STR_TERMINATE
);
150 /*******************************************************************
151 Reads or writes a NETLOGON_INFO_2 structure.
152 ********************************************************************/
154 static BOOL
net_io_netinfo_2(const char *desc
, NETLOGON_INFO_2
*info
, prs_struct
*ps
, int depth
)
159 prs_debug(ps
, depth
, desc
, "net_io_netinfo_2");
165 if(!prs_uint32("flags ", ps
, depth
, &info
->flags
))
167 if(!prs_uint32("pdc_status ", ps
, depth
, &info
->pdc_status
))
169 if(!prs_uint32("ptr_trusted_dc_name", ps
, depth
, &info
->ptr_trusted_dc_name
))
171 if(!prs_uint32("tc_status ", ps
, depth
, &info
->tc_status
))
174 if (info
->ptr_trusted_dc_name
!= 0) {
175 if(!smb_io_unistr2("unistr2", &info
->uni_trusted_dc_name
, info
->ptr_trusted_dc_name
, ps
, depth
))
185 /*******************************************************************
186 Reads or writes an NET_Q_LOGON_CTRL2 structure.
187 ********************************************************************/
189 BOOL
net_io_q_logon_ctrl2(const char *desc
, NET_Q_LOGON_CTRL2
*q_l
, prs_struct
*ps
, int depth
)
194 prs_debug(ps
, depth
, desc
, "net_io_q_logon_ctrl2");
200 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
203 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
209 if(!prs_uint32("function_code", ps
, depth
, &q_l
->function_code
))
211 if(!prs_uint32("query_level ", ps
, depth
, &q_l
->query_level
))
213 if(!prs_uint32("switch_value ", ps
, depth
, &q_l
->switch_value
))
219 /*******************************************************************
220 Inits an NET_Q_LOGON_CTRL2 structure.
221 ********************************************************************/
223 void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2
*q_l
, const char *srv_name
,
226 DEBUG(5,("init_q_logon_ctrl2\n"));
228 q_l
->function_code
= 0x01;
229 q_l
->query_level
= query_level
;
230 q_l
->switch_value
= 0x01;
232 init_unistr2(&q_l
->uni_server_name
, srv_name
, UNI_STR_TERMINATE
);
235 /*******************************************************************
236 Inits an NET_R_LOGON_CTRL2 structure.
237 ********************************************************************/
239 void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2
*r_l
, uint32 query_level
,
240 uint32 flags
, uint32 pdc_status
,
241 uint32 logon_attempts
, uint32 tc_status
,
242 const char *trusted_domain_name
)
244 DEBUG(5,("init_r_logon_ctrl2\n"));
246 r_l
->switch_value
= query_level
; /* should only be 0x1 */
248 switch (query_level
) {
250 r_l
->ptr
= 1; /* undocumented pointer */
251 init_netinfo_1(&r_l
->logon
.info1
, flags
, pdc_status
);
252 r_l
->status
= NT_STATUS_OK
;
255 r_l
->ptr
= 1; /* undocumented pointer */
256 init_netinfo_2(&r_l
->logon
.info2
, flags
, pdc_status
,
257 tc_status
, trusted_domain_name
);
258 r_l
->status
= NT_STATUS_OK
;
261 r_l
->ptr
= 1; /* undocumented pointer */
262 init_netinfo_3(&r_l
->logon
.info3
, flags
, logon_attempts
);
263 r_l
->status
= NT_STATUS_OK
;
266 DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n",
268 r_l
->ptr
= 0; /* undocumented pointer */
270 /* take a guess at an error code... */
271 r_l
->status
= NT_STATUS_INVALID_INFO_CLASS
;
276 /*******************************************************************
277 Reads or writes an NET_R_LOGON_CTRL2 structure.
278 ********************************************************************/
280 BOOL
net_io_r_logon_ctrl2(const char *desc
, NET_R_LOGON_CTRL2
*r_l
, prs_struct
*ps
, int depth
)
285 prs_debug(ps
, depth
, desc
, "net_io_r_logon_ctrl2");
288 if(!prs_uint32("switch_value ", ps
, depth
, &r_l
->switch_value
))
290 if(!prs_uint32("ptr ", ps
, depth
, &r_l
->ptr
))
294 switch (r_l
->switch_value
) {
296 if(!net_io_netinfo_1("", &r_l
->logon
.info1
, ps
, depth
))
300 if(!net_io_netinfo_2("", &r_l
->logon
.info2
, ps
, depth
))
304 if(!net_io_netinfo_3("", &r_l
->logon
.info3
, ps
, depth
))
308 DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n",
314 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
320 /*******************************************************************
321 Reads or writes an NET_Q_LOGON_CTRL structure.
322 ********************************************************************/
324 BOOL
net_io_q_logon_ctrl(const char *desc
, NET_Q_LOGON_CTRL
*q_l
, prs_struct
*ps
,
327 prs_debug(ps
, depth
, desc
, "net_io_q_logon_ctrl");
333 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
336 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
342 if(!prs_uint32("function_code", ps
, depth
, &q_l
->function_code
))
344 if(!prs_uint32("query_level ", ps
, depth
, &q_l
->query_level
))
350 /*******************************************************************
351 Inits an NET_Q_LOGON_CTRL structure.
352 ********************************************************************/
354 void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL
*q_l
, const char *srv_name
,
357 DEBUG(5,("init_q_logon_ctrl\n"));
359 q_l
->function_code
= 0x01; /* ??? */
360 q_l
->query_level
= query_level
;
362 init_unistr2(&q_l
->uni_server_name
, srv_name
, UNI_STR_TERMINATE
);
365 /*******************************************************************
366 Inits an NET_R_LOGON_CTRL structure.
367 ********************************************************************/
369 void init_net_r_logon_ctrl(NET_R_LOGON_CTRL
*r_l
, uint32 query_level
,
370 uint32 flags
, uint32 pdc_status
)
372 DEBUG(5,("init_r_logon_ctrl\n"));
374 r_l
->switch_value
= query_level
; /* should only be 0x1 */
376 switch (query_level
) {
378 r_l
->ptr
= 1; /* undocumented pointer */
379 init_netinfo_1(&r_l
->logon
.info1
, flags
, pdc_status
);
380 r_l
->status
= NT_STATUS_OK
;
383 DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n",
385 r_l
->ptr
= 0; /* undocumented pointer */
387 /* take a guess at an error code... */
388 r_l
->status
= NT_STATUS_INVALID_INFO_CLASS
;
393 /*******************************************************************
394 Reads or writes an NET_R_LOGON_CTRL structure.
395 ********************************************************************/
397 BOOL
net_io_r_logon_ctrl(const char *desc
, NET_R_LOGON_CTRL
*r_l
, prs_struct
*ps
,
400 prs_debug(ps
, depth
, desc
, "net_io_r_logon_ctrl");
403 if(!prs_uint32("switch_value ", ps
, depth
, &r_l
->switch_value
))
405 if(!prs_uint32("ptr ", ps
, depth
, &r_l
->ptr
))
409 switch (r_l
->switch_value
) {
411 if(!net_io_netinfo_1("", &r_l
->logon
.info1
, ps
, depth
))
415 DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n",
421 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
427 /*******************************************************************
428 Inits an NET_R_TRUST_DOM_LIST structure.
429 ********************************************************************/
431 void init_r_trust_dom(NET_R_TRUST_DOM_LIST
*r_t
,
432 uint32 num_doms
, const char *dom_name
)
436 DEBUG(5,("init_r_trust_dom\n"));
438 for (i
= 0; i
< MAX_TRUST_DOMS
; i
++) {
439 r_t
->uni_trust_dom_name
[i
].uni_str_len
= 0;
440 r_t
->uni_trust_dom_name
[i
].uni_max_len
= 0;
442 if (num_doms
> MAX_TRUST_DOMS
)
443 num_doms
= MAX_TRUST_DOMS
;
445 for (i
= 0; i
< num_doms
; i
++) {
447 fstrcpy(domain_name
, dom_name
);
448 strupper_m(domain_name
);
449 init_unistr2(&r_t
->uni_trust_dom_name
[i
], domain_name
, UNI_STR_TERMINATE
);
450 /* the use of UNISTR2 here is non-standard. */
451 r_t
->uni_trust_dom_name
[i
].offset
= 0x1;
454 r_t
->status
= NT_STATUS_OK
;
457 /*******************************************************************
458 Reads or writes an NET_R_TRUST_DOM_LIST structure.
459 ********************************************************************/
461 BOOL
net_io_r_trust_dom(const char *desc
, NET_R_TRUST_DOM_LIST
*r_t
, prs_struct
*ps
, int depth
)
468 prs_debug(ps
, depth
, desc
, "net_io_r_trust_dom");
471 /* temporary code to give a valid response */
473 if(!prs_uint32("status", ps
, depth
, &value
))
477 if(!prs_uint32("status", ps
, depth
, &value
))
480 if(!prs_uint32("status", ps
, depth
, &value
))
484 if(!prs_uint32("status", ps
, depth
, &value
))
488 if(!prs_uint32("status", ps
, depth
, &value
))
491 /* old non working code */
495 for (i
= 0; i
< MAX_TRUST_DOMS
; i
++) {
496 if (r_t
->uni_trust_dom_name
[i
].uni_str_len
== 0)
498 if(!smb_io_unistr2("", &r_t
->uni_trust_dom_name
[i
], True
, ps
, depth
))
502 if(!prs_ntstatus("status", ps
, depth
, &r_t
->status
))
509 /*******************************************************************
510 Reads or writes an NET_Q_TRUST_DOM_LIST structure.
511 ********************************************************************/
513 BOOL
net_io_q_trust_dom(const char *desc
, NET_Q_TRUST_DOM_LIST
*q_l
, prs_struct
*ps
, int depth
)
518 prs_debug(ps
, depth
, desc
, "net_io_q_trust_dom");
521 if(!prs_uint32("ptr ", ps
, depth
, &q_l
->ptr
))
523 if(!smb_io_unistr2 ("", &q_l
->uni_server_name
, q_l
->ptr
, ps
, depth
))
529 /*******************************************************************
530 Inits an NET_Q_REQ_CHAL structure.
531 ********************************************************************/
533 void init_q_req_chal(NET_Q_REQ_CHAL
*q_c
,
534 const char *logon_srv
, const char *logon_clnt
,
537 DEBUG(5,("init_q_req_chal: %d\n", __LINE__
));
539 q_c
->undoc_buffer
= 1; /* don't know what this buffer is */
541 init_unistr2(&q_c
->uni_logon_srv
, logon_srv
, UNI_STR_TERMINATE
);
542 init_unistr2(&q_c
->uni_logon_clnt
, logon_clnt
, UNI_STR_TERMINATE
);
544 memcpy(q_c
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
546 DEBUG(5,("init_q_req_chal: %d\n", __LINE__
));
549 /*******************************************************************
550 Reads or writes an NET_Q_REQ_CHAL structure.
551 ********************************************************************/
553 BOOL
net_io_q_req_chal(const char *desc
, NET_Q_REQ_CHAL
*q_c
, prs_struct
*ps
, int depth
)
558 prs_debug(ps
, depth
, desc
, "net_io_q_req_chal");
564 if(!prs_uint32("undoc_buffer", ps
, depth
, &q_c
->undoc_buffer
))
567 if(!smb_io_unistr2("", &q_c
->uni_logon_srv
, True
, ps
, depth
)) /* logon server unicode string */
569 if(!smb_io_unistr2("", &q_c
->uni_logon_clnt
, True
, ps
, depth
)) /* logon client unicode string */
572 if(!smb_io_chal("", &q_c
->clnt_chal
, ps
, depth
))
578 /*******************************************************************
579 Reads or writes a structure.
580 ********************************************************************/
582 BOOL
net_io_r_req_chal(const char *desc
, NET_R_REQ_CHAL
*r_c
, prs_struct
*ps
, int depth
)
587 prs_debug(ps
, depth
, desc
, "net_io_r_req_chal");
593 if(!smb_io_chal("", &r_c
->srv_chal
, ps
, depth
)) /* server challenge */
596 if(!prs_ntstatus("status", ps
, depth
, &r_c
->status
))
603 /*******************************************************************
604 Reads or writes a structure.
605 ********************************************************************/
607 BOOL
net_io_q_auth(const char *desc
, NET_Q_AUTH
*q_a
, prs_struct
*ps
, int depth
)
612 prs_debug(ps
, depth
, desc
, "net_io_q_auth");
618 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
620 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
626 /*******************************************************************
627 Reads or writes a structure.
628 ********************************************************************/
630 BOOL
net_io_r_auth(const char *desc
, NET_R_AUTH
*r_a
, prs_struct
*ps
, int depth
)
635 prs_debug(ps
, depth
, desc
, "net_io_r_auth");
641 if(!smb_io_chal("", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
644 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
650 /*******************************************************************
651 Inits a NET_Q_AUTH_2 struct.
652 ********************************************************************/
654 void init_q_auth_2(NET_Q_AUTH_2
*q_a
,
655 const char *logon_srv
, const char *acct_name
, uint16 sec_chan
, const char *comp_name
,
656 DOM_CHAL
*clnt_chal
, uint32 clnt_flgs
)
658 DEBUG(5,("init_q_auth_2: %d\n", __LINE__
));
660 init_log_info(&q_a
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
);
661 memcpy(q_a
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
662 q_a
->clnt_flgs
.neg_flags
= clnt_flgs
;
664 DEBUG(5,("init_q_auth_2: %d\n", __LINE__
));
667 /*******************************************************************
668 Reads or writes a structure.
669 ********************************************************************/
671 BOOL
net_io_q_auth_2(const char *desc
, NET_Q_AUTH_2
*q_a
, prs_struct
*ps
, int depth
)
676 prs_debug(ps
, depth
, desc
, "net_io_q_auth_2");
682 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
684 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
686 if(!net_io_neg_flags("", &q_a
->clnt_flgs
, ps
, depth
))
692 /*******************************************************************
693 Reads or writes a structure.
694 ********************************************************************/
696 BOOL
net_io_r_auth_2(const char *desc
, NET_R_AUTH_2
*r_a
, prs_struct
*ps
, int depth
)
701 prs_debug(ps
, depth
, desc
, "net_io_r_auth_2");
707 if(!smb_io_chal("", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
709 if(!net_io_neg_flags("", &r_a
->srv_flgs
, ps
, depth
))
712 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
718 /*******************************************************************
719 Inits a NET_Q_AUTH_3 struct.
720 ********************************************************************/
722 void init_q_auth_3(NET_Q_AUTH_3
*q_a
,
723 const char *logon_srv
, const char *acct_name
, uint16 sec_chan
, const char *comp_name
,
724 DOM_CHAL
*clnt_chal
, uint32 clnt_flgs
)
726 DEBUG(5,("init_q_auth_3: %d\n", __LINE__
));
728 init_log_info(&q_a
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
);
729 memcpy(q_a
->clnt_chal
.data
, clnt_chal
->data
, sizeof(clnt_chal
->data
));
730 q_a
->clnt_flgs
.neg_flags
= clnt_flgs
;
732 DEBUG(5,("init_q_auth_3: %d\n", __LINE__
));
735 /*******************************************************************
736 Reads or writes a structure.
737 ********************************************************************/
739 BOOL
net_io_q_auth_3(const char *desc
, NET_Q_AUTH_3
*q_a
, prs_struct
*ps
, int depth
)
744 prs_debug(ps
, depth
, desc
, "net_io_q_auth_3");
750 if(!smb_io_log_info ("", &q_a
->clnt_id
, ps
, depth
)) /* client identification info */
752 if(!smb_io_chal("", &q_a
->clnt_chal
, ps
, depth
))
754 if(!net_io_neg_flags("", &q_a
->clnt_flgs
, ps
, depth
))
760 /*******************************************************************
761 Reads or writes a structure.
762 ********************************************************************/
764 BOOL
net_io_r_auth_3(const char *desc
, NET_R_AUTH_3
*r_a
, prs_struct
*ps
, int depth
)
769 prs_debug(ps
, depth
, desc
, "net_io_r_auth_3");
775 if(!smb_io_chal("srv_chal", &r_a
->srv_chal
, ps
, depth
)) /* server challenge */
777 if(!net_io_neg_flags("srv_flgs", &r_a
->srv_flgs
, ps
, depth
))
779 if (!prs_uint32("unknown", ps
, depth
, &r_a
->unknown
))
782 if(!prs_ntstatus("status", ps
, depth
, &r_a
->status
))
789 /*******************************************************************
790 Inits a NET_Q_SRV_PWSET.
791 ********************************************************************/
793 void init_q_srv_pwset(NET_Q_SRV_PWSET
*q_s
,
794 const char *logon_srv
, const char *sess_key
, const char *acct_name
,
795 uint16 sec_chan
, const char *comp_name
,
796 DOM_CRED
*cred
, uchar hashed_mach_pwd
[16])
798 unsigned char nt_cypher
[16];
800 DEBUG(5,("init_q_srv_pwset\n"));
802 /* Process the new password. */
803 cred_hash3( nt_cypher
, hashed_mach_pwd
, (const unsigned char *)sess_key
, 1);
805 init_clnt_info(&q_s
->clnt_id
, logon_srv
, acct_name
, sec_chan
, comp_name
, cred
);
807 memcpy(q_s
->pwd
, nt_cypher
, sizeof(q_s
->pwd
));
810 /*******************************************************************
811 Reads or writes a structure.
812 ********************************************************************/
814 BOOL
net_io_q_srv_pwset(const char *desc
, NET_Q_SRV_PWSET
*q_s
, prs_struct
*ps
, int depth
)
819 prs_debug(ps
, depth
, desc
, "net_io_q_srv_pwset");
825 if(!smb_io_clnt_info("", &q_s
->clnt_id
, ps
, depth
)) /* client identification/authentication info */
827 if(!prs_uint8s (False
, "pwd", ps
, depth
, q_s
->pwd
, 16)) /* new password - undocumented */
833 /*******************************************************************
834 Reads or writes a structure.
835 ********************************************************************/
837 BOOL
net_io_r_srv_pwset(const char *desc
, NET_R_SRV_PWSET
*r_s
, prs_struct
*ps
, int depth
)
842 prs_debug(ps
, depth
, desc
, "net_io_r_srv_pwset");
848 if(!smb_io_cred("", &r_s
->srv_cred
, ps
, depth
)) /* server challenge */
851 if(!prs_ntstatus("status", ps
, depth
, &r_s
->status
))
857 /*************************************************************************
858 Init DOM_SID2 array from a string containing multiple sids
859 *************************************************************************/
861 static int init_dom_sid2s(TALLOC_CTX
*ctx
, const char *sids_str
, DOM_SID2
**ppsids
)
867 DEBUG(4,("init_dom_sid2s: %s\n", sids_str
? sids_str
:""));
875 /* Count the number of valid SIDs. */
876 for (count
= 0, ptr
= sids_str
; next_token(&ptr
, s2
, NULL
, sizeof(s2
)); ) {
878 if (string_to_sid(&tmpsid
, s2
))
882 /* Now allocate space for them. */
883 *ppsids
= (DOM_SID2
*)talloc_zero(ctx
, count
* sizeof(DOM_SID2
));
889 for (number
= 0, ptr
= sids_str
; next_token(&ptr
, s2
, NULL
, sizeof(s2
)); ) {
891 if (string_to_sid(&tmpsid
, s2
)) {
892 /* count only valid sids */
893 init_dom_sid2(&sids
[number
], &tmpsid
);
902 /*******************************************************************
903 Inits a NET_ID_INFO_1 structure.
904 ********************************************************************/
906 void init_id_info1(NET_ID_INFO_1
*id
, const char *domain_name
,
907 uint32 param_ctrl
, uint32 log_id_low
, uint32 log_id_high
,
908 const char *user_name
, const char *wksta_name
,
909 const char *sess_key
,
910 unsigned char lm_cypher
[16], unsigned char nt_cypher
[16])
912 unsigned char lm_owf
[16];
913 unsigned char nt_owf
[16];
915 DEBUG(5,("init_id_info1: %d\n", __LINE__
));
917 id
->ptr_id_info1
= 1;
919 id
->param_ctrl
= param_ctrl
;
920 init_logon_id(&id
->logon_id
, log_id_low
, log_id_high
);
923 if (lm_cypher
&& nt_cypher
) {
924 unsigned char key
[16];
925 #ifdef DEBUG_PASSWORD
926 DEBUG(100,("lm cypher:"));
927 dump_data(100, (char *)lm_cypher
, 16);
929 DEBUG(100,("nt cypher:"));
930 dump_data(100, (char *)nt_cypher
, 16);
934 memcpy(key
, sess_key
, 8);
936 memcpy(lm_owf
, lm_cypher
, 16);
937 SamOEMhash(lm_owf
, key
, 16);
938 memcpy(nt_owf
, nt_cypher
, 16);
939 SamOEMhash(nt_owf
, key
, 16);
941 #ifdef DEBUG_PASSWORD
942 DEBUG(100,("encrypt of lm owf password:"));
943 dump_data(100, (char *)lm_owf
, 16);
945 DEBUG(100,("encrypt of nt owf password:"));
946 dump_data(100, (char *)nt_owf
, 16);
948 /* set up pointers to cypher blocks */
953 init_owf_info(&id
->lm_owf
, lm_cypher
);
954 init_owf_info(&id
->nt_owf
, nt_cypher
);
956 init_unistr2(&id
->uni_domain_name
, domain_name
, UNI_FLAGS_NONE
);
957 init_uni_hdr(&id
->hdr_domain_name
, &id
->uni_domain_name
);
958 init_unistr2(&id
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
959 init_uni_hdr(&id
->hdr_user_name
, &id
->uni_user_name
);
960 init_unistr2(&id
->uni_wksta_name
, wksta_name
, UNI_FLAGS_NONE
);
961 init_uni_hdr(&id
->hdr_wksta_name
, &id
->uni_wksta_name
);
964 /*******************************************************************
965 Reads or writes an NET_ID_INFO_1 structure.
966 ********************************************************************/
968 static BOOL
net_io_id_info1(const char *desc
, NET_ID_INFO_1
*id
, prs_struct
*ps
, int depth
)
973 prs_debug(ps
, depth
, desc
, "net_io_id_info1");
979 if(!prs_uint32("ptr_id_info1", ps
, depth
, &id
->ptr_id_info1
))
982 if (id
->ptr_id_info1
!= 0) {
983 if(!smb_io_unihdr("unihdr", &id
->hdr_domain_name
, ps
, depth
))
986 if(!prs_uint32("param_ctrl", ps
, depth
, &id
->param_ctrl
))
988 if(!smb_io_logon_id("", &id
->logon_id
, ps
, depth
))
991 if(!smb_io_unihdr("unihdr", &id
->hdr_user_name
, ps
, depth
))
993 if(!smb_io_unihdr("unihdr", &id
->hdr_wksta_name
, ps
, depth
))
996 if(!smb_io_owf_info("", &id
->lm_owf
, ps
, depth
))
998 if(!smb_io_owf_info("", &id
->nt_owf
, ps
, depth
))
1001 if(!smb_io_unistr2("unistr2", &id
->uni_domain_name
,
1002 id
->hdr_domain_name
.buffer
, ps
, depth
))
1004 if(!smb_io_unistr2("unistr2", &id
->uni_user_name
,
1005 id
->hdr_user_name
.buffer
, ps
, depth
))
1007 if(!smb_io_unistr2("unistr2", &id
->uni_wksta_name
,
1008 id
->hdr_wksta_name
.buffer
, ps
, depth
))
1015 /*******************************************************************
1016 Inits a NET_ID_INFO_2 structure.
1018 This is a network logon packet. The log_id parameters
1019 are what an NT server would generate for LUID once the
1020 user is logged on. I don't think we care about them.
1022 Note that this has no access to the NT and LM hashed passwords,
1023 so it forwards the challenge, and the NT and LM responses (24
1024 bytes each) over the secure channel to the Domain controller
1025 for it to say yea or nay. This is the preferred method of
1026 checking for a logon as it doesn't export the password
1027 hashes to anyone who has compromised the secure channel. JRA.
1028 ********************************************************************/
1030 void init_id_info2(NET_ID_INFO_2
* id
, const char *domain_name
,
1032 uint32 log_id_low
, uint32 log_id_high
,
1033 const char *user_name
, const char *wksta_name
,
1034 const uchar lm_challenge
[8],
1035 const uchar
* lm_chal_resp
, size_t lm_chal_resp_len
,
1036 const uchar
* nt_chal_resp
, size_t nt_chal_resp_len
)
1038 unsigned char lm_owf
[24];
1039 unsigned char nt_owf
[128];
1041 DEBUG(5,("init_id_info2: %d\n", __LINE__
));
1043 id
->ptr_id_info2
= 1;
1046 id
->param_ctrl
= param_ctrl
;
1047 init_logon_id(&id
->logon_id
, log_id_low
, log_id_high
);
1050 /* oops. can only send what-ever-it-is direct */
1051 memcpy(nt_owf
, nt_chal_resp
, MIN(sizeof(nt_owf
), nt_chal_resp_len
));
1052 nt_chal_resp
= nt_owf
;
1055 /* oops. can only send what-ever-it-is direct */
1056 memcpy(lm_owf
, lm_chal_resp
, MIN(sizeof(lm_owf
), lm_chal_resp_len
));
1057 lm_chal_resp
= lm_owf
;
1060 memcpy(id
->lm_chal
, lm_challenge
, sizeof(id
->lm_chal
));
1061 init_str_hdr(&id
->hdr_nt_chal_resp
, nt_chal_resp_len
, nt_chal_resp_len
, (nt_chal_resp
!= NULL
) ? 1 : 0);
1062 init_str_hdr(&id
->hdr_lm_chal_resp
, lm_chal_resp_len
, lm_chal_resp_len
, (lm_chal_resp
!= NULL
) ? 1 : 0);
1064 init_unistr2(&id
->uni_domain_name
, domain_name
, UNI_FLAGS_NONE
);
1065 init_uni_hdr(&id
->hdr_domain_name
, &id
->uni_domain_name
);
1066 init_unistr2(&id
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
1067 init_uni_hdr(&id
->hdr_user_name
, &id
->uni_user_name
);
1068 init_unistr2(&id
->uni_wksta_name
, wksta_name
, UNI_FLAGS_NONE
);
1069 init_uni_hdr(&id
->hdr_wksta_name
, &id
->uni_wksta_name
);
1071 init_string2(&id
->nt_chal_resp
, (const char *)nt_chal_resp
, nt_chal_resp_len
, nt_chal_resp_len
);
1072 init_string2(&id
->lm_chal_resp
, (const char *)lm_chal_resp
, lm_chal_resp_len
, lm_chal_resp_len
);
1076 /*******************************************************************
1077 Reads or writes an NET_ID_INFO_2 structure.
1078 ********************************************************************/
1080 static BOOL
net_io_id_info2(const char *desc
, NET_ID_INFO_2
*id
, prs_struct
*ps
, int depth
)
1085 prs_debug(ps
, depth
, desc
, "net_io_id_info2");
1091 if(!prs_uint32("ptr_id_info2", ps
, depth
, &id
->ptr_id_info2
))
1094 if (id
->ptr_id_info2
!= 0) {
1095 if(!smb_io_unihdr("unihdr", &id
->hdr_domain_name
, ps
, depth
))
1098 if(!prs_uint32("param_ctrl", ps
, depth
, &id
->param_ctrl
))
1100 if(!smb_io_logon_id("", &id
->logon_id
, ps
, depth
))
1103 if(!smb_io_unihdr("unihdr", &id
->hdr_user_name
, ps
, depth
))
1105 if(!smb_io_unihdr("unihdr", &id
->hdr_wksta_name
, ps
, depth
))
1108 if(!prs_uint8s (False
, "lm_chal", ps
, depth
, id
->lm_chal
, 8)) /* lm 8 byte challenge */
1111 if(!smb_io_strhdr("hdr_nt_chal_resp", &id
->hdr_nt_chal_resp
, ps
, depth
))
1113 if(!smb_io_strhdr("hdr_lm_chal_resp", &id
->hdr_lm_chal_resp
, ps
, depth
))
1116 if(!smb_io_unistr2("uni_domain_name", &id
->uni_domain_name
,
1117 id
->hdr_domain_name
.buffer
, ps
, depth
))
1119 if(!smb_io_unistr2("uni_user_name ", &id
->uni_user_name
,
1120 id
->hdr_user_name
.buffer
, ps
, depth
))
1122 if(!smb_io_unistr2("uni_wksta_name ", &id
->uni_wksta_name
,
1123 id
->hdr_wksta_name
.buffer
, ps
, depth
))
1125 if(!smb_io_string2("nt_chal_resp", &id
->nt_chal_resp
,
1126 id
->hdr_nt_chal_resp
.buffer
, ps
, depth
))
1128 if(!smb_io_string2("lm_chal_resp", &id
->lm_chal_resp
,
1129 id
->hdr_lm_chal_resp
.buffer
, ps
, depth
))
1137 /*******************************************************************
1138 Inits a DOM_SAM_INFO structure.
1139 ********************************************************************/
1141 void init_sam_info(DOM_SAM_INFO
*sam
,
1142 const char *logon_srv
, const char *comp_name
,
1143 DOM_CRED
*clnt_cred
,
1144 DOM_CRED
*rtn_cred
, uint16 logon_level
,
1145 NET_ID_INFO_CTR
*ctr
)
1147 DEBUG(5,("init_sam_info: %d\n", __LINE__
));
1149 init_clnt_info2(&sam
->client
, logon_srv
, comp_name
, clnt_cred
);
1151 if (rtn_cred
!= NULL
) {
1152 sam
->ptr_rtn_cred
= 1;
1153 memcpy(&sam
->rtn_cred
, rtn_cred
, sizeof(sam
->rtn_cred
));
1155 sam
->ptr_rtn_cred
= 0;
1158 sam
->logon_level
= logon_level
;
1162 /*******************************************************************
1163 Reads or writes a DOM_SAM_INFO structure.
1164 ********************************************************************/
1166 static BOOL
net_io_id_info_ctr(const char *desc
, NET_ID_INFO_CTR
**pp_ctr
, prs_struct
*ps
, int depth
)
1168 NET_ID_INFO_CTR
*ctr
= *pp_ctr
;
1170 prs_debug(ps
, depth
, desc
, "smb_io_sam_info");
1173 if (UNMARSHALLING(ps
)) {
1174 ctr
= *pp_ctr
= (NET_ID_INFO_CTR
*)prs_alloc_mem(ps
, sizeof(NET_ID_INFO_CTR
));
1182 /* don't 4-byte align here! */
1184 if(!prs_uint16("switch_value ", ps
, depth
, &ctr
->switch_value
))
1187 switch (ctr
->switch_value
) {
1189 if(!net_io_id_info1("", &ctr
->auth
.id1
, ps
, depth
))
1193 if(!net_io_id_info2("", &ctr
->auth
.id2
, ps
, depth
))
1198 DEBUG(4,("smb_io_sam_info: unknown switch_value!\n"));
1205 /*******************************************************************
1206 Reads or writes a DOM_SAM_INFO structure.
1207 ********************************************************************/
1209 static BOOL
smb_io_sam_info(const char *desc
, DOM_SAM_INFO
*sam
, prs_struct
*ps
, int depth
)
1214 prs_debug(ps
, depth
, desc
, "smb_io_sam_info");
1220 if(!smb_io_clnt_info2("", &sam
->client
, ps
, depth
))
1223 if(!prs_uint32("ptr_rtn_cred ", ps
, depth
, &sam
->ptr_rtn_cred
))
1225 if(!smb_io_cred("", &sam
->rtn_cred
, ps
, depth
))
1228 if(!prs_uint16("logon_level ", ps
, depth
, &sam
->logon_level
))
1231 if (sam
->logon_level
!= 0) {
1232 if(!net_io_id_info_ctr("logon_info", &sam
->ctr
, ps
, depth
))
1239 /*************************************************************************
1240 Inits a NET_USER_INFO_3 structure.
1242 This is a network logon reply packet, and contains much information about
1243 the user. This information is passed as a (very long) paramater list
1244 to avoid having to link in the PASSDB code to every program that deals
1246 *************************************************************************/
1248 void init_net_user_info3(TALLOC_CTX
*ctx
, NET_USER_INFO_3
*usr
,
1252 const char* user_name
,
1253 const char* full_name
,
1254 const char* home_dir
,
1255 const char* dir_drive
,
1256 const char* logon_script
,
1257 const char* profile_path
,
1259 time_t unix_logon_time
,
1260 time_t unix_logoff_time
,
1261 time_t unix_kickoff_time
,
1262 time_t unix_pass_last_set_time
,
1263 time_t unix_pass_can_change_time
,
1264 time_t unix_pass_must_change_time
,
1266 uint16 logon_count
, uint16 bad_pw_count
,
1267 uint32 num_groups
, const DOM_GID
*gids
,
1268 uint32 user_flgs
, uchar nt_session_key
[16],
1269 uchar lm_session_key
[16],
1270 const char *logon_srv
, const char *logon_dom
,
1271 const DOM_SID
*dom_sid
, const char *other_sids
)
1273 /* only cope with one "other" sid, right now. */
1274 /* need to count the number of space-delimited sids */
1276 int num_other_sids
= 0;
1278 NTTIME logon_time
, logoff_time
, kickoff_time
,
1279 pass_last_set_time
, pass_can_change_time
,
1280 pass_must_change_time
;
1284 usr
->ptr_user_info
= 1; /* yes, we're bothering to put USER_INFO data here */
1286 /* Create NTTIME structs */
1287 unix_to_nt_time (&logon_time
, unix_logon_time
);
1288 unix_to_nt_time (&logoff_time
, unix_logoff_time
);
1289 unix_to_nt_time (&kickoff_time
, unix_kickoff_time
);
1290 unix_to_nt_time (&pass_last_set_time
, unix_pass_last_set_time
);
1291 unix_to_nt_time (&pass_can_change_time
, unix_pass_can_change_time
);
1292 unix_to_nt_time (&pass_must_change_time
, unix_pass_must_change_time
);
1294 usr
->logon_time
= logon_time
;
1295 usr
->logoff_time
= logoff_time
;
1296 usr
->kickoff_time
= kickoff_time
;
1297 usr
->pass_last_set_time
= pass_last_set_time
;
1298 usr
->pass_can_change_time
= pass_can_change_time
;
1299 usr
->pass_must_change_time
= pass_must_change_time
;
1301 usr
->logon_count
= logon_count
;
1302 usr
->bad_pw_count
= bad_pw_count
;
1304 usr
->user_rid
= user_rid
;
1305 usr
->group_rid
= group_rid
;
1306 usr
->num_groups
= num_groups
;
1308 usr
->buffer_groups
= 1; /* indicates fill in groups, below, even if there are none */
1309 usr
->user_flgs
= user_flgs
;
1311 if (nt_session_key
!= NULL
)
1312 memcpy(usr
->user_sess_key
, nt_session_key
, sizeof(usr
->user_sess_key
));
1314 memset((char *)usr
->user_sess_key
, '\0', sizeof(usr
->user_sess_key
));
1316 usr
->buffer_dom_id
= dom_sid
? 1 : 0; /* yes, we're bothering to put a domain SID in */
1318 memset((char *)usr
->padding
, '\0', sizeof(usr
->padding
));
1320 #if 0 /* JRATEST - exchange auth test. */
1321 if (lm_session_key
!= NULL
)
1322 memcpy(usr
->padding
, lm_session_key
, sizeof(usr
->user_sess_key
));
1325 num_other_sids
= init_dom_sid2s(ctx
, other_sids
, &usr
->other_sids
);
1327 usr
->num_other_sids
= num_other_sids
;
1328 usr
->buffer_other_sids
= (num_other_sids
!= 0) ? 1 : 0;
1330 init_unistr2(&usr
->uni_user_name
, user_name
, UNI_FLAGS_NONE
);
1331 init_uni_hdr(&usr
->hdr_user_name
, &usr
->uni_user_name
);
1332 init_unistr2(&usr
->uni_full_name
, full_name
, UNI_FLAGS_NONE
);
1333 init_uni_hdr(&usr
->hdr_full_name
, &usr
->uni_full_name
);
1334 init_unistr2(&usr
->uni_logon_script
, logon_script
, UNI_FLAGS_NONE
);
1335 init_uni_hdr(&usr
->hdr_logon_script
, &usr
->uni_logon_script
);
1336 init_unistr2(&usr
->uni_profile_path
, profile_path
, UNI_FLAGS_NONE
);
1337 init_uni_hdr(&usr
->hdr_profile_path
, &usr
->uni_profile_path
);
1338 init_unistr2(&usr
->uni_home_dir
, home_dir
, UNI_FLAGS_NONE
);
1339 init_uni_hdr(&usr
->hdr_home_dir
, &usr
->uni_home_dir
);
1340 init_unistr2(&usr
->uni_dir_drive
, dir_drive
, UNI_FLAGS_NONE
);
1341 init_uni_hdr(&usr
->hdr_dir_drive
, &usr
->uni_dir_drive
);
1343 usr
->num_groups2
= num_groups
;
1345 usr
->gids
= (DOM_GID
*)talloc_zero(ctx
,sizeof(DOM_GID
) * (num_groups
));
1346 if (usr
->gids
== NULL
&& num_groups
>0)
1349 for (i
= 0; i
< num_groups
; i
++)
1350 usr
->gids
[i
] = gids
[i
];
1352 init_unistr2(&usr
->uni_logon_srv
, logon_srv
, UNI_FLAGS_NONE
);
1353 init_uni_hdr(&usr
->hdr_logon_srv
, &usr
->uni_logon_srv
);
1354 init_unistr2(&usr
->uni_logon_dom
, logon_dom
, UNI_FLAGS_NONE
);
1355 init_uni_hdr(&usr
->hdr_logon_dom
, &usr
->uni_logon_dom
);
1357 init_dom_sid2(&usr
->dom_sid
, dom_sid
);
1358 /* "other" sids are set up above */
1361 /*******************************************************************
1362 This code has been modified to cope with a NET_USER_INFO_2 - which is
1363 exactly the same as a NET_USER_INFO_3, minus the other sids parameters.
1364 We use validation level to determine if we're marshalling a info 2 or
1365 INFO_3 - be we always return an INFO_3. Based on code donated by Marc
1366 Jacobsen at HP. JRA.
1367 ********************************************************************/
1369 BOOL
net_io_user_info3(const char *desc
, NET_USER_INFO_3
*usr
, prs_struct
*ps
,
1370 int depth
, uint16 validation_level
)
1377 prs_debug(ps
, depth
, desc
, "net_io_user_info3");
1380 if (UNMARSHALLING(ps
))
1386 if(!prs_uint32("ptr_user_info ", ps
, depth
, &usr
->ptr_user_info
))
1389 if (usr
->ptr_user_info
== 0)
1392 if(!smb_io_time("logon time", &usr
->logon_time
, ps
, depth
)) /* logon time */
1394 if(!smb_io_time("logoff time", &usr
->logoff_time
, ps
, depth
)) /* logoff time */
1396 if(!smb_io_time("kickoff time", &usr
->kickoff_time
, ps
, depth
)) /* kickoff time */
1398 if(!smb_io_time("last set time", &usr
->pass_last_set_time
, ps
, depth
)) /* password last set time */
1400 if(!smb_io_time("can change time", &usr
->pass_can_change_time
, ps
, depth
)) /* password can change time */
1402 if(!smb_io_time("must change time", &usr
->pass_must_change_time
, ps
, depth
)) /* password must change time */
1405 if(!smb_io_unihdr("hdr_user_name", &usr
->hdr_user_name
, ps
, depth
)) /* username unicode string header */
1407 if(!smb_io_unihdr("hdr_full_name", &usr
->hdr_full_name
, ps
, depth
)) /* user's full name unicode string header */
1409 if(!smb_io_unihdr("hdr_logon_script", &usr
->hdr_logon_script
, ps
, depth
)) /* logon script unicode string header */
1411 if(!smb_io_unihdr("hdr_profile_path", &usr
->hdr_profile_path
, ps
, depth
)) /* profile path unicode string header */
1413 if(!smb_io_unihdr("hdr_home_dir", &usr
->hdr_home_dir
, ps
, depth
)) /* home directory unicode string header */
1415 if(!smb_io_unihdr("hdr_dir_drive", &usr
->hdr_dir_drive
, ps
, depth
)) /* home directory drive unicode string header */
1418 if(!prs_uint16("logon_count ", ps
, depth
, &usr
->logon_count
)) /* logon count */
1420 if(!prs_uint16("bad_pw_count ", ps
, depth
, &usr
->bad_pw_count
)) /* bad password count */
1423 if(!prs_uint32("user_rid ", ps
, depth
, &usr
->user_rid
)) /* User RID */
1425 if(!prs_uint32("group_rid ", ps
, depth
, &usr
->group_rid
)) /* Group RID */
1427 if(!prs_uint32("num_groups ", ps
, depth
, &usr
->num_groups
)) /* num groups */
1429 if(!prs_uint32("buffer_groups ", ps
, depth
, &usr
->buffer_groups
)) /* undocumented buffer pointer to groups. */
1431 if(!prs_uint32("user_flgs ", ps
, depth
, &usr
->user_flgs
)) /* user flags */
1434 if(!prs_uint8s(False
, "user_sess_key", ps
, depth
, usr
->user_sess_key
, 16)) /* user session key */
1437 if(!smb_io_unihdr("hdr_logon_srv", &usr
->hdr_logon_srv
, ps
, depth
)) /* logon server unicode string header */
1439 if(!smb_io_unihdr("hdr_logon_dom", &usr
->hdr_logon_dom
, ps
, depth
)) /* logon domain unicode string header */
1442 if(!prs_uint32("buffer_dom_id ", ps
, depth
, &usr
->buffer_dom_id
)) /* undocumented logon domain id pointer */
1444 if(!prs_uint8s (False
, "padding ", ps
, depth
, usr
->padding
, 40)) /* unused padding bytes? */
1447 if (validation_level
== 3) {
1448 if(!prs_uint32("num_other_sids", ps
, depth
, &usr
->num_other_sids
)) /* 0 - num_sids */
1450 if(!prs_uint32("buffer_other_sids", ps
, depth
, &usr
->buffer_other_sids
)) /* NULL - undocumented pointer to SIDs. */
1453 if (UNMARSHALLING(ps
)) {
1454 usr
->num_other_sids
= 0;
1455 usr
->buffer_other_sids
= 0;
1459 if(!smb_io_unistr2("uni_user_name", &usr
->uni_user_name
, usr
->hdr_user_name
.buffer
, ps
, depth
)) /* username unicode string */
1461 if(!smb_io_unistr2("uni_full_name", &usr
->uni_full_name
, usr
->hdr_full_name
.buffer
, ps
, depth
)) /* user's full name unicode string */
1463 if(!smb_io_unistr2("uni_logon_script", &usr
->uni_logon_script
, usr
->hdr_logon_script
.buffer
, ps
, depth
)) /* logon script unicode string */
1465 if(!smb_io_unistr2("uni_profile_path", &usr
->uni_profile_path
, usr
->hdr_profile_path
.buffer
, ps
, depth
)) /* profile path unicode string */
1467 if(!smb_io_unistr2("uni_home_dir", &usr
->uni_home_dir
, usr
->hdr_home_dir
.buffer
, ps
, depth
)) /* home directory unicode string */
1469 if(!smb_io_unistr2("uni_dir_drive", &usr
->uni_dir_drive
, usr
->hdr_dir_drive
.buffer
, ps
, depth
)) /* home directory drive unicode string */
1474 if(!prs_uint32("num_groups2 ", ps
, depth
, &usr
->num_groups2
)) /* num groups */
1477 if (UNMARSHALLING(ps
) && usr
->num_groups2
> 0) {
1478 usr
->gids
= (DOM_GID
*)prs_alloc_mem(ps
, sizeof(DOM_GID
)*usr
->num_groups2
);
1479 if (usr
->gids
== NULL
)
1483 for (i
= 0; i
< usr
->num_groups2
; i
++) {
1484 if(!smb_io_gid("", &usr
->gids
[i
], ps
, depth
)) /* group info */
1488 if(!smb_io_unistr2("uni_logon_srv", &usr
->uni_logon_srv
, usr
->hdr_logon_srv
.buffer
, ps
, depth
)) /* logon server unicode string */
1490 if(!smb_io_unistr2("uni_logon_dom", &usr
->uni_logon_dom
, usr
->hdr_logon_srv
.buffer
, ps
, depth
)) /* logon domain unicode string */
1493 if(!smb_io_dom_sid2("", &usr
->dom_sid
, ps
, depth
)) /* domain SID */
1496 if (usr
->num_other_sids
) {
1498 if (UNMARSHALLING(ps
)) {
1499 usr
->other_sids
= (DOM_SID2
*)prs_alloc_mem(ps
, sizeof(DOM_SID2
)*usr
->num_other_sids
);
1500 if (usr
->other_sids
== NULL
)
1504 if(!prs_uint32("num_other_groups", ps
, depth
, &usr
->num_other_groups
))
1507 if (UNMARSHALLING(ps
) && usr
->num_other_groups
> 0) {
1508 usr
->other_gids
= (DOM_GID
*)prs_alloc_mem(ps
, sizeof(DOM_GID
)*usr
->num_other_groups
);
1509 if (usr
->other_gids
== NULL
)
1513 for (i
= 0; i
< usr
->num_other_groups
; i
++) {
1514 if(!smb_io_gid("", &usr
->other_gids
[i
], ps
, depth
)) /* other GIDs */
1517 for (i
= 0; i
< usr
->num_other_sids
; i
++) {
1518 if(!smb_io_dom_sid2("", &usr
->other_sids
[i
], ps
, depth
)) /* other domain SIDs */
1526 /*******************************************************************
1527 Reads or writes a structure.
1528 ********************************************************************/
1530 BOOL
net_io_q_sam_logon(const char *desc
, NET_Q_SAM_LOGON
*q_l
, prs_struct
*ps
, int depth
)
1535 prs_debug(ps
, depth
, desc
, "net_io_q_sam_logon");
1541 if(!smb_io_sam_info("", &q_l
->sam_id
, ps
, depth
))
1544 if(!prs_align_uint16(ps
))
1547 if(!prs_uint16("validation_level", ps
, depth
, &q_l
->validation_level
))
1553 /*******************************************************************
1554 Reads or writes a structure.
1555 ********************************************************************/
1557 BOOL
net_io_r_sam_logon(const char *desc
, NET_R_SAM_LOGON
*r_l
, prs_struct
*ps
, int depth
)
1562 prs_debug(ps
, depth
, desc
, "net_io_r_sam_logon");
1565 if(!prs_uint32("buffer_creds", ps
, depth
, &r_l
->buffer_creds
)) /* undocumented buffer pointer */
1567 if(!smb_io_cred("", &r_l
->srv_creds
, ps
, depth
)) /* server credentials. server time stamp appears to be ignored. */
1570 if(!prs_uint16("switch_value", ps
, depth
, &r_l
->switch_value
))
1575 #if 1 /* W2k always needs this - even for bad passwd. JRA */
1576 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
))
1579 if (r_l
->switch_value
!= 0) {
1580 if(!net_io_user_info3("", r_l
->user
, ps
, depth
, r_l
->switch_value
))
1585 if(!prs_uint32("auth_resp ", ps
, depth
, &r_l
->auth_resp
)) /* 1 - Authoritative response; 0 - Non-Auth? */
1588 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
1597 /*******************************************************************
1598 Reads or writes a structure.
1599 ********************************************************************/
1601 BOOL
net_io_q_sam_logoff(const char *desc
, NET_Q_SAM_LOGOFF
*q_l
, prs_struct
*ps
, int depth
)
1606 prs_debug(ps
, depth
, desc
, "net_io_q_sam_logoff");
1612 if(!smb_io_sam_info("", &q_l
->sam_id
, ps
, depth
)) /* domain SID */
1618 /*******************************************************************
1619 Reads or writes a structure.
1620 ********************************************************************/
1622 BOOL
net_io_r_sam_logoff(const char *desc
, NET_R_SAM_LOGOFF
*r_l
, prs_struct
*ps
, int depth
)
1627 prs_debug(ps
, depth
, desc
, "net_io_r_sam_logoff");
1633 if(!prs_uint32("buffer_creds", ps
, depth
, &r_l
->buffer_creds
)) /* undocumented buffer pointer */
1635 if(!smb_io_cred("", &r_l
->srv_creds
, ps
, depth
)) /* server credentials. server time stamp appears to be ignored. */
1638 if(!prs_ntstatus("status ", ps
, depth
, &r_l
->status
))
1644 /*******************************************************************
1645 makes a NET_Q_SAM_SYNC structure.
1646 ********************************************************************/
1647 BOOL
init_net_q_sam_sync(NET_Q_SAM_SYNC
* q_s
, const char *srv_name
,
1648 const char *cli_name
, DOM_CRED
*cli_creds
,
1649 DOM_CRED
*ret_creds
, uint32 database_id
,
1652 DEBUG(5, ("init_q_sam_sync\n"));
1654 init_unistr2(&q_s
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
1655 init_unistr2(&q_s
->uni_cli_name
, cli_name
, UNI_STR_TERMINATE
);
1658 memcpy(&q_s
->cli_creds
, cli_creds
, sizeof(q_s
->cli_creds
));
1661 memcpy(&q_s
->ret_creds
, ret_creds
, sizeof(q_s
->ret_creds
));
1663 memset(&q_s
->ret_creds
, 0, sizeof(q_s
->ret_creds
));
1665 q_s
->database_id
= database_id
;
1666 q_s
->restart_state
= 0;
1667 q_s
->sync_context
= next_rid
;
1668 q_s
->max_size
= 0xffff;
1673 /*******************************************************************
1674 reads or writes a structure.
1675 ********************************************************************/
1676 BOOL
net_io_q_sam_sync(const char *desc
, NET_Q_SAM_SYNC
* q_s
, prs_struct
*ps
,
1679 prs_debug(ps
, depth
, desc
, "net_io_q_sam_sync");
1682 if (!smb_io_unistr2("", &q_s
->uni_srv_name
, True
, ps
, depth
))
1684 if (!smb_io_unistr2("", &q_s
->uni_cli_name
, True
, ps
, depth
))
1687 if (!smb_io_cred("", &q_s
->cli_creds
, ps
, depth
))
1689 if (!smb_io_cred("", &q_s
->ret_creds
, ps
, depth
))
1692 if (!prs_uint32("database_id ", ps
, depth
, &q_s
->database_id
))
1694 if (!prs_uint32("restart_state", ps
, depth
, &q_s
->restart_state
))
1696 if (!prs_uint32("sync_context ", ps
, depth
, &q_s
->sync_context
))
1699 if (!prs_uint32("max_size", ps
, depth
, &q_s
->max_size
))
1705 /*******************************************************************
1706 reads or writes a structure.
1707 ********************************************************************/
1708 static BOOL
net_io_sam_delta_hdr(const char *desc
, SAM_DELTA_HDR
* delta
,
1709 prs_struct
*ps
, int depth
)
1711 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_hdr");
1714 if (!prs_uint16("type", ps
, depth
, &delta
->type
))
1716 if (!prs_uint16("type2", ps
, depth
, &delta
->type2
))
1718 if (!prs_uint32("target_rid", ps
, depth
, &delta
->target_rid
))
1721 if (!prs_uint32("type3", ps
, depth
, &delta
->type3
))
1724 /* Not sure why we need this but it seems to be necessary to get
1725 sam deltas working. */
1727 if (delta
->type
!= 0x16) {
1728 if (!prs_uint32("ptr_delta", ps
, depth
, &delta
->ptr_delta
))
1735 /*******************************************************************
1736 reads or writes a structure.
1737 ********************************************************************/
1738 static BOOL
net_io_sam_delta_mod_count(const char *desc
, SAM_DELTA_MOD_COUNT
*info
,
1739 prs_struct
*ps
, int depth
)
1741 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_stamp");
1744 if (!prs_uint32("seqnum", ps
, depth
, &info
->seqnum
))
1746 if (!prs_uint32("dom_mod_count_ptr", ps
, depth
,
1747 &info
->dom_mod_count_ptr
))
1750 if (info
->dom_mod_count_ptr
) {
1751 if (!prs_uint64("dom_mod_count", ps
, depth
,
1752 &info
->dom_mod_count
))
1759 /*******************************************************************
1760 reads or writes a structure.
1761 ********************************************************************/
1762 static BOOL
net_io_sam_domain_info(const char *desc
, SAM_DOMAIN_INFO
* info
,
1763 prs_struct
*ps
, int depth
)
1765 prs_debug(ps
, depth
, desc
, "net_io_sam_domain_info");
1768 if (!smb_io_unihdr("hdr_dom_name", &info
->hdr_dom_name
, ps
, depth
))
1770 if (!smb_io_unihdr("hdr_oem_info", &info
->hdr_oem_info
, ps
, depth
))
1773 if (!prs_uint64("force_logoff", ps
, depth
, &info
->force_logoff
))
1775 if (!prs_uint16("min_pwd_len", ps
, depth
, &info
->min_pwd_len
))
1777 if (!prs_uint16("pwd_history_len", ps
, depth
, &info
->pwd_history_len
))
1779 if (!prs_uint64("max_pwd_age", ps
, depth
, &info
->max_pwd_age
))
1781 if (!prs_uint64("min_pwd_age", ps
, depth
, &info
->min_pwd_age
))
1783 if (!prs_uint64("dom_mod_count", ps
, depth
, &info
->dom_mod_count
))
1785 if (!smb_io_time("creation_time", &info
->creation_time
, ps
, depth
))
1788 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
1790 if (!smb_io_unihdr("hdr_unknown", &info
->hdr_unknown
, ps
, depth
))
1793 if (ps
->data_offset
+ 40 > ps
->buffer_size
)
1795 ps
->data_offset
+= 40;
1797 if (!smb_io_unistr2("uni_dom_name", &info
->uni_dom_name
,
1798 info
->hdr_dom_name
.buffer
, ps
, depth
))
1800 if (!smb_io_unistr2("buf_oem_info", &info
->buf_oem_info
,
1801 info
->hdr_oem_info
.buffer
, ps
, depth
))
1804 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
1805 info
->hdr_sec_desc
.buffer
, ps
, depth
))
1807 if (!smb_io_unistr2("buf_unknown", &info
->buf_unknown
,
1808 info
->hdr_unknown
.buffer
, ps
, depth
))
1814 /*******************************************************************
1815 reads or writes a structure.
1816 ********************************************************************/
1817 static BOOL
net_io_sam_group_info(const char *desc
, SAM_GROUP_INFO
* info
,
1818 prs_struct
*ps
, int depth
)
1820 prs_debug(ps
, depth
, desc
, "net_io_sam_group_info");
1823 if (!smb_io_unihdr("hdr_grp_name", &info
->hdr_grp_name
, ps
, depth
))
1825 if (!smb_io_gid("gid", &info
->gid
, ps
, depth
))
1827 if (!smb_io_unihdr("hdr_grp_desc", &info
->hdr_grp_desc
, ps
, depth
))
1829 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
1832 if (ps
->data_offset
+ 48 > ps
->buffer_size
)
1834 ps
->data_offset
+= 48;
1836 if (!smb_io_unistr2("uni_grp_name", &info
->uni_grp_name
,
1837 info
->hdr_grp_name
.buffer
, ps
, depth
))
1839 if (!smb_io_unistr2("uni_grp_desc", &info
->uni_grp_desc
,
1840 info
->hdr_grp_desc
.buffer
, ps
, depth
))
1842 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
1843 info
->hdr_sec_desc
.buffer
, ps
, depth
))
1849 /*******************************************************************
1850 reads or writes a structure.
1851 ********************************************************************/
1852 static BOOL
net_io_sam_passwd_info(const char *desc
, SAM_PWD
* pwd
,
1853 prs_struct
*ps
, int depth
)
1855 prs_debug(ps
, depth
, desc
, "net_io_sam_passwd_info");
1858 if (!prs_uint32("unk_0 ", ps
, depth
, &pwd
->unk_0
))
1861 if (!smb_io_unihdr("hdr_lm_pwd", &pwd
->hdr_lm_pwd
, ps
, depth
))
1863 if (!prs_uint8s(False
, "buf_lm_pwd", ps
, depth
, pwd
->buf_lm_pwd
, 16))
1866 if (!smb_io_unihdr("hdr_nt_pwd", &pwd
->hdr_nt_pwd
, ps
, depth
))
1868 if (!prs_uint8s(False
, "buf_nt_pwd", ps
, depth
, pwd
->buf_nt_pwd
, 16))
1871 if (!smb_io_unihdr("", &pwd
->hdr_empty_lm
, ps
, depth
))
1873 if (!smb_io_unihdr("", &pwd
->hdr_empty_nt
, ps
, depth
))
1879 /*******************************************************************
1880 makes a SAM_ACCOUNT_INFO structure.
1881 ********************************************************************/
1882 BOOL
make_sam_account_info(SAM_ACCOUNT_INFO
* info
,
1883 const UNISTR2
*user_name
,
1884 const UNISTR2
*full_name
,
1885 uint32 user_rid
, uint32 group_rid
,
1886 const UNISTR2
*home_dir
,
1887 const UNISTR2
*dir_drive
,
1888 const UNISTR2
*log_scr
,
1889 const UNISTR2
*desc
,
1891 const UNISTR2
*prof_path
,
1892 const UNISTR2
*wkstas
,
1893 const UNISTR2
*unk_str
, const UNISTR2
*mung_dial
)
1895 int len_user_name
= user_name
!= NULL
? user_name
->uni_str_len
: 0;
1896 int len_full_name
= full_name
!= NULL
? full_name
->uni_str_len
: 0;
1897 int len_home_dir
= home_dir
!= NULL
? home_dir
->uni_str_len
: 0;
1898 int len_dir_drive
= dir_drive
!= NULL
? dir_drive
->uni_str_len
: 0;
1899 int len_logon_script
= log_scr
!= NULL
? log_scr
->uni_str_len
: 0;
1900 int len_profile_path
= prof_path
!= NULL
? prof_path
->uni_str_len
: 0;
1901 int len_description
= desc
!= NULL
? desc
->uni_str_len
: 0;
1902 int len_workstations
= wkstas
!= NULL
? wkstas
->uni_str_len
: 0;
1903 int len_unknown_str
= unk_str
!= NULL
? unk_str
->uni_str_len
: 0;
1904 int len_munged_dial
= mung_dial
!= NULL
? mung_dial
->uni_str_len
: 0;
1906 DEBUG(5, ("make_sam_account_info\n"));
1908 make_uni_hdr(&info
->hdr_acct_name
, len_user_name
);
1909 make_uni_hdr(&info
->hdr_full_name
, len_full_name
);
1910 make_uni_hdr(&info
->hdr_home_dir
, len_home_dir
);
1911 make_uni_hdr(&info
->hdr_dir_drive
, len_dir_drive
);
1912 make_uni_hdr(&info
->hdr_logon_script
, len_logon_script
);
1913 make_uni_hdr(&info
->hdr_profile
, len_profile_path
);
1914 make_uni_hdr(&info
->hdr_acct_desc
, len_description
);
1915 make_uni_hdr(&info
->hdr_workstations
, len_workstations
);
1916 make_uni_hdr(&info
->hdr_comment
, len_unknown_str
);
1917 make_uni_hdr(&info
->hdr_parameters
, len_munged_dial
);
1920 make_bufhdr2(&info
->hdr_sec_desc
, 0, 0, 0);
1922 info
->user_rid
= user_rid
;
1923 info
->group_rid
= group_rid
;
1925 init_nt_time(&info
->logon_time
);
1926 init_nt_time(&info
->logoff_time
);
1927 init_nt_time(&info
->pwd_last_set_time
);
1928 init_nt_time(&info
->acct_expiry_time
);
1930 info
->logon_divs
= 0xA8;
1931 info
->ptr_logon_hrs
= 0; /* Don't care right now */
1933 info
->bad_pwd_count
= 0;
1934 info
->logon_count
= 0;
1935 info
->acb_info
= acb_info
;
1936 info
->nt_pwd_present
= 0;
1937 info
->lm_pwd_present
= 0;
1938 info
->pwd_expired
= 0;
1942 info
->unknown1
= 0x4EC;
1945 copy_unistr2(&info
->uni_acct_name
, user_name
);
1946 copy_unistr2(&info
->uni_full_name
, full_name
);
1947 copy_unistr2(&info
->uni_home_dir
, home_dir
);
1948 copy_unistr2(&info
->uni_dir_drive
, dir_drive
);
1949 copy_unistr2(&info
->uni_logon_script
, log_scr
);
1950 copy_unistr2(&info
->uni_profile
, prof_path
);
1951 copy_unistr2(&info
->uni_acct_desc
, desc
);
1952 copy_unistr2(&info
->uni_workstations
, wkstas
);
1953 copy_unistr2(&info
->uni_comment
, unk_str
);
1954 copy_unistr2(&info
->uni_parameters
, mung_dial
);
1959 /*******************************************************************
1960 reads or writes a structure.
1961 ********************************************************************/
1962 static BOOL
net_io_sam_account_info(const char *desc
, uint8 sess_key
[16],
1963 SAM_ACCOUNT_INFO
* info
, prs_struct
*ps
,
1966 BUFHDR2 hdr_priv_data
;
1969 prs_debug(ps
, depth
, desc
, "net_io_sam_account_info");
1972 if (!smb_io_unihdr("hdr_acct_name", &info
->hdr_acct_name
, ps
, depth
))
1974 if (!smb_io_unihdr("hdr_full_name", &info
->hdr_full_name
, ps
, depth
))
1977 if (!prs_uint32("user_rid ", ps
, depth
, &info
->user_rid
))
1979 if (!prs_uint32("group_rid", ps
, depth
, &info
->group_rid
))
1982 if (!smb_io_unihdr("hdr_home_dir ", &info
->hdr_home_dir
, ps
, depth
))
1984 if (!smb_io_unihdr("hdr_dir_drive", &info
->hdr_dir_drive
, ps
, depth
))
1986 if (!smb_io_unihdr("hdr_logon_script", &info
->hdr_logon_script
, ps
,
1990 if (!smb_io_unihdr("hdr_acct_desc", &info
->hdr_acct_desc
, ps
, depth
))
1992 if (!smb_io_unihdr("hdr_workstations", &info
->hdr_workstations
, ps
,
1996 if (!smb_io_time("logon_time", &info
->logon_time
, ps
, depth
))
1998 if (!smb_io_time("logoff_time", &info
->logoff_time
, ps
, depth
))
2001 if (!prs_uint32("logon_divs ", ps
, depth
, &info
->logon_divs
))
2003 if (!prs_uint32("ptr_logon_hrs", ps
, depth
, &info
->ptr_logon_hrs
))
2006 if (!prs_uint16("bad_pwd_count", ps
, depth
, &info
->bad_pwd_count
))
2008 if (!prs_uint16("logon_count", ps
, depth
, &info
->logon_count
))
2010 if (!smb_io_time("pwd_last_set_time", &info
->pwd_last_set_time
, ps
,
2013 if (!smb_io_time("acct_expiry_time", &info
->acct_expiry_time
, ps
,
2017 if (!prs_uint32("acb_info", ps
, depth
, &info
->acb_info
))
2019 if (!prs_uint8s(False
, "nt_pwd", ps
, depth
, info
->nt_pwd
, 16))
2021 if (!prs_uint8s(False
, "lm_pwd", ps
, depth
, info
->lm_pwd
, 16))
2023 if (!prs_uint8("lm_pwd_present", ps
, depth
, &info
->lm_pwd_present
))
2025 if (!prs_uint8("nt_pwd_present", ps
, depth
, &info
->nt_pwd_present
))
2027 if (!prs_uint8("pwd_expired", ps
, depth
, &info
->pwd_expired
))
2030 if (!smb_io_unihdr("hdr_comment", &info
->hdr_comment
, ps
, depth
))
2032 if (!smb_io_unihdr("hdr_parameters", &info
->hdr_parameters
, ps
,
2035 if (!prs_uint16("country", ps
, depth
, &info
->country
))
2037 if (!prs_uint16("codepage", ps
, depth
, &info
->codepage
))
2040 if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data
, ps
, depth
))
2042 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2044 if (!smb_io_unihdr("hdr_profile", &info
->hdr_profile
, ps
, depth
))
2047 for (i
= 0; i
< 3; i
++)
2049 if (!smb_io_unihdr("hdr_reserved", &info
->hdr_reserved
[i
],
2054 for (i
= 0; i
< 4; i
++)
2056 if (!prs_uint32("dw_reserved", ps
, depth
,
2057 &info
->dw_reserved
[i
]))
2061 if (!smb_io_unistr2("uni_acct_name", &info
->uni_acct_name
,
2062 info
->hdr_acct_name
.buffer
, ps
, depth
))
2065 if (!smb_io_unistr2("uni_full_name", &info
->uni_full_name
,
2066 info
->hdr_full_name
.buffer
, ps
, depth
))
2069 if (!smb_io_unistr2("uni_home_dir ", &info
->uni_home_dir
,
2070 info
->hdr_home_dir
.buffer
, ps
, depth
))
2073 if (!smb_io_unistr2("uni_dir_drive", &info
->uni_dir_drive
,
2074 info
->hdr_dir_drive
.buffer
, ps
, depth
))
2077 if (!smb_io_unistr2("uni_logon_script", &info
->uni_logon_script
,
2078 info
->hdr_logon_script
.buffer
, ps
, depth
))
2081 if (!smb_io_unistr2("uni_acct_desc", &info
->uni_acct_desc
,
2082 info
->hdr_acct_desc
.buffer
, ps
, depth
))
2085 if (!smb_io_unistr2("uni_workstations", &info
->uni_workstations
,
2086 info
->hdr_workstations
.buffer
, ps
, depth
))
2090 if (!prs_uint32("unknown1", ps
, depth
, &info
->unknown1
))
2092 if (!prs_uint32("unknown2", ps
, depth
, &info
->unknown2
))
2095 if (!smb_io_buffer4("buf_logon_hrs", &info
->buf_logon_hrs
,
2096 info
->ptr_logon_hrs
, ps
, depth
))
2099 if (!smb_io_unistr2("uni_comment", &info
->uni_comment
,
2100 info
->hdr_comment
.buffer
, ps
, depth
))
2103 if (!smb_io_unistr2("uni_parameters", &info
->uni_parameters
,
2104 info
->hdr_parameters
.buffer
, ps
, depth
))
2107 if (hdr_priv_data
.buffer
!= 0)
2111 if (!prs_uint32("pwd_len", ps
, depth
, &len
))
2113 old_offset
= ps
->data_offset
;
2119 if (!prs_hash1(ps
, ps
->data_offset
, sess_key
, len
))
2122 if (!net_io_sam_passwd_info("pass", &info
->pass
,
2129 if (!prs_hash1(ps
, old_offset
, sess_key
, len
))
2133 if (old_offset
+ len
> ps
->buffer_size
)
2135 ps
->data_offset
= old_offset
+ len
;
2137 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
2138 info
->hdr_sec_desc
.buffer
, ps
, depth
))
2141 if (!smb_io_unistr2("uni_profile", &info
->uni_profile
,
2142 info
->hdr_profile
.buffer
, ps
, depth
))
2150 /*******************************************************************
2151 reads or writes a structure.
2152 ********************************************************************/
2153 static BOOL
net_io_sam_group_mem_info(const char *desc
, SAM_GROUP_MEM_INFO
* info
,
2154 prs_struct
*ps
, int depth
)
2159 prs_debug(ps
, depth
, desc
, "net_io_sam_group_mem_info");
2163 if (!prs_uint32("ptr_rids ", ps
, depth
, &info
->ptr_rids
))
2165 if (!prs_uint32("ptr_attribs", ps
, depth
, &info
->ptr_attribs
))
2167 if (!prs_uint32("num_members", ps
, depth
, &info
->num_members
))
2170 if (ps
->data_offset
+ 16 > ps
->buffer_size
)
2172 ps
->data_offset
+= 16;
2174 if (info
->ptr_rids
!= 0)
2176 if (!prs_uint32("num_members2", ps
, depth
,
2177 &info
->num_members2
))
2180 if (info
->num_members2
!= info
->num_members
)
2186 info
->rids
= talloc(ps
->mem_ctx
, sizeof(uint32
) *
2187 info
->num_members2
);
2189 if (info
->rids
== NULL
) {
2190 DEBUG(0, ("out of memory allocating %d rids\n",
2191 info
->num_members2
));
2195 for (i
= 0; i
< info
->num_members2
; i
++)
2197 slprintf(tmp
, sizeof(tmp
) - 1, "rids[%02d]", i
);
2198 if (!prs_uint32(tmp
, ps
, depth
, &info
->rids
[i
]))
2203 if (info
->ptr_attribs
!= 0)
2205 if (!prs_uint32("num_members3", ps
, depth
,
2206 &info
->num_members3
))
2208 if (info
->num_members3
!= info
->num_members
)
2214 info
->attribs
= talloc(ps
->mem_ctx
, sizeof(uint32
) *
2215 info
->num_members3
);
2217 if (info
->attribs
== NULL
) {
2218 DEBUG(0, ("out of memory allocating %d attribs\n",
2219 info
->num_members3
));
2223 for (i
= 0; i
< info
->num_members3
; i
++)
2225 slprintf(tmp
, sizeof(tmp
) - 1, "attribs[%02d]", i
);
2226 if (!prs_uint32(tmp
, ps
, depth
, &info
->attribs
[i
]))
2234 /*******************************************************************
2235 reads or writes a structure.
2236 ********************************************************************/
2237 static BOOL
net_io_sam_alias_info(const char *desc
, SAM_ALIAS_INFO
* info
,
2238 prs_struct
*ps
, int depth
)
2240 prs_debug(ps
, depth
, desc
, "net_io_sam_alias_info");
2243 if (!smb_io_unihdr("hdr_als_name", &info
->hdr_als_name
, ps
, depth
))
2245 if (!prs_uint32("als_rid", ps
, depth
, &info
->als_rid
))
2247 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2249 if (!smb_io_unihdr("hdr_als_desc", &info
->hdr_als_desc
, ps
, depth
))
2252 if (ps
->data_offset
+ 40 > ps
->buffer_size
)
2254 ps
->data_offset
+= 40;
2256 if (!smb_io_unistr2("uni_als_name", &info
->uni_als_name
,
2257 info
->hdr_als_name
.buffer
, ps
, depth
))
2259 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
2260 info
->hdr_sec_desc
.buffer
, ps
, depth
))
2263 if (info
->hdr_als_desc
.buffer
!= 0) {
2264 if (!smb_io_unistr2("uni_als_desc", &info
->uni_als_desc
,
2265 info
->hdr_als_name
.buffer
, ps
, depth
))
2272 /*******************************************************************
2273 reads or writes a structure.
2274 ********************************************************************/
2275 static BOOL
net_io_sam_alias_mem_info(const char *desc
, SAM_ALIAS_MEM_INFO
* info
,
2276 prs_struct
*ps
, int depth
)
2281 prs_debug(ps
, depth
, desc
, "net_io_sam_alias_mem_info");
2285 if (!prs_uint32("num_members", ps
, depth
, &info
->num_members
))
2287 if (!prs_uint32("ptr_members", ps
, depth
, &info
->ptr_members
))
2290 if (ps
->data_offset
+ 16 > ps
->buffer_size
)
2292 ps
->data_offset
+= 16;
2294 if (info
->ptr_members
!= 0)
2296 if (!prs_uint32("num_sids", ps
, depth
, &info
->num_sids
))
2298 if (info
->num_sids
!= info
->num_members
)
2304 info
->ptr_sids
= talloc(ps
->mem_ctx
, sizeof(uint32
) *
2307 if (info
->ptr_sids
== NULL
) {
2308 DEBUG(0, ("out of memory allocating %d ptr_sids\n",
2313 for (i
= 0; i
< info
->num_sids
; i
++)
2315 slprintf(tmp
, sizeof(tmp
) - 1, "ptr_sids[%02d]", i
);
2316 if (!prs_uint32(tmp
, ps
, depth
, &info
->ptr_sids
[i
]))
2320 info
->sids
= talloc(ps
->mem_ctx
, sizeof(DOM_SID2
) *
2323 if (info
->sids
== NULL
) {
2324 DEBUG(0, ("error allocating %d sids\n",
2329 for (i
= 0; i
< info
->num_sids
; i
++)
2331 if (info
->ptr_sids
[i
] != 0)
2333 slprintf(tmp
, sizeof(tmp
) - 1, "sids[%02d]",
2335 if (!smb_io_dom_sid2(tmp
, &info
->sids
[i
],
2345 /*******************************************************************
2346 reads or writes a structure.
2347 ********************************************************************/
2348 static BOOL
net_io_sam_policy_info(const char *desc
, SAM_DELTA_POLICY
*info
,
2349 prs_struct
*ps
, int depth
)
2352 prs_debug(ps
, depth
, desc
, "net_io_sam_policy_info");
2358 if (!prs_uint32("max_log_size", ps
, depth
, &info
->max_log_size
))
2360 if (!prs_uint64("audit_retention_period", ps
, depth
,
2361 &info
->audit_retention_period
))
2363 if (!prs_uint32("auditing_mode", ps
, depth
, &info
->auditing_mode
))
2365 if (!prs_uint32("num_events", ps
, depth
, &info
->num_events
))
2367 if (!prs_uint32("ptr_events", ps
, depth
, &info
->ptr_events
))
2370 if (!smb_io_unihdr("hdr_dom_name", &info
->hdr_dom_name
, ps
, depth
))
2373 if (!prs_uint32("sid_ptr", ps
, depth
, &info
->sid_ptr
))
2376 if (!prs_uint32("paged_pool_limit", ps
, depth
, &info
->paged_pool_limit
))
2378 if (!prs_uint32("non_paged_pool_limit", ps
, depth
,
2379 &info
->non_paged_pool_limit
))
2381 if (!prs_uint32("min_workset_size", ps
, depth
, &info
->min_workset_size
))
2383 if (!prs_uint32("max_workset_size", ps
, depth
, &info
->max_workset_size
))
2385 if (!prs_uint32("page_file_limit", ps
, depth
, &info
->page_file_limit
))
2387 if (!prs_uint64("time_limit", ps
, depth
, &info
->time_limit
))
2389 if (!smb_io_time("modify_time", &info
->modify_time
, ps
, depth
))
2391 if (!smb_io_time("create_time", &info
->create_time
, ps
, depth
))
2393 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2396 for (i
=0; i
<4; i
++) {
2398 if (!smb_io_unihdr("dummy", &dummy
, ps
, depth
))
2402 for (i
=0; i
<4; i
++) {
2404 if (!prs_uint32("reserved", ps
, depth
, &reserved
))
2408 if (!prs_uint32("num_event_audit_options", ps
, depth
,
2409 &info
->num_event_audit_options
))
2412 for (i
=0; i
<info
->num_event_audit_options
; i
++)
2413 if (!prs_uint32("event_audit_option", ps
, depth
,
2414 &info
->event_audit_option
))
2417 if (!smb_io_unistr2("domain_name", &info
->domain_name
, True
, ps
, depth
))
2420 if(!smb_io_dom_sid2("domain_sid", &info
->domain_sid
, ps
, depth
))
2423 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
2424 info
->hdr_sec_desc
.buffer
, ps
, depth
))
2433 /* This function is pretty broken - see bug #334 */
2435 /*******************************************************************
2436 reads or writes a structure.
2437 ********************************************************************/
2438 static BOOL
net_io_sam_trustdoms_info(const char *desc
, SAM_DELTA_TRUSTDOMS
*info
,
2439 prs_struct
*ps
, int depth
)
2443 prs_debug(ps
, depth
, desc
, "net_io_sam_trustdoms_info");
2449 if(!prs_uint32("buf_size", ps
, depth
, &info
->buf_size
))
2452 if(!sec_io_desc("sec_desc", &info
->sec_desc
, ps
, depth
))
2455 if(!smb_io_dom_sid2("sid", &info
->sid
, ps
, depth
))
2458 if(!smb_io_unihdr("hdr_domain", &info
->hdr_domain
, ps
, depth
))
2461 if(!prs_uint32("unknown0", ps
, depth
, &info
->unknown0
))
2463 if(!prs_uint32("unknown1", ps
, depth
, &info
->unknown1
))
2465 if(!prs_uint32("unknown2", ps
, depth
, &info
->unknown2
))
2468 if(!prs_uint32("buf_size2", ps
, depth
, &info
->buf_size2
))
2470 if(!prs_uint32("ptr", ps
, depth
, &info
->ptr
))
2473 for (i
=0; i
<12; i
++)
2474 if(!prs_uint32("unknown3", ps
, depth
, &info
->unknown3
))
2477 if (!smb_io_unistr2("domain", &info
->domain
, True
, ps
, depth
))
2487 /* This function doesn't work - see bug #334 */
2489 /*******************************************************************
2490 reads or writes a structure.
2491 ********************************************************************/
2492 static BOOL
net_io_sam_secret_info(const char *desc
, SAM_DELTA_SECRET
*info
,
2493 prs_struct
*ps
, int depth
)
2497 prs_debug(ps
, depth
, desc
, "net_io_sam_secret_info");
2503 if(!prs_uint32("buf_size", ps
, depth
, &info
->buf_size
))
2506 if(!sec_io_desc("sec_desc", &info
->sec_desc
, ps
, depth
))
2509 if (!smb_io_unistr2("secret", &info
->secret
, True
, ps
, depth
))
2515 if(!prs_uint32("count1", ps
, depth
, &info
->count1
))
2517 if(!prs_uint32("count2", ps
, depth
, &info
->count2
))
2519 if(!prs_uint32("ptr", ps
, depth
, &info
->ptr
))
2523 if(!smb_io_time("time1", &info
->time1
, ps
, depth
)) /* logon time */
2525 if(!prs_uint32("count3", ps
, depth
, &info
->count3
))
2527 if(!prs_uint32("count4", ps
, depth
, &info
->count4
))
2529 if(!prs_uint32("ptr2", ps
, depth
, &info
->ptr2
))
2531 if(!smb_io_time("time2", &info
->time2
, ps
, depth
)) /* logon time */
2533 if(!prs_uint32("unknow1", ps
, depth
, &info
->unknow1
))
2537 if(!prs_uint32("buf_size2", ps
, depth
, &info
->buf_size2
))
2539 if(!prs_uint32("ptr3", ps
, depth
, &info
->ptr3
))
2542 if(!prs_uint32("unknow2", ps
, depth
, &info
->unknow2
))
2545 if(!prs_uint32("chal_len", ps
, depth
, &info
->chal_len
))
2547 if(!prs_uint32("reserved1", ps
, depth
, &info
->reserved1
))
2549 if(!prs_uint32("chal_len2", ps
, depth
, &info
->chal_len2
))
2552 if(!prs_uint8s (False
, "chal", ps
, depth
, info
->chal
, info
->chal_len2
))
2555 if(!prs_uint32("key_len", ps
, depth
, &info
->key_len
))
2557 if(!prs_uint32("reserved2", ps
, depth
, &info
->reserved2
))
2559 if(!prs_uint32("key_len2", ps
, depth
, &info
->key_len2
))
2562 if(!prs_uint8s (False
, "key", ps
, depth
, info
->key
, info
->key_len2
))
2566 if(!prs_uint32("buf_size3", ps
, depth
, &info
->buf_size3
))
2569 if(!sec_io_desc("sec_desc2", &info
->sec_desc2
, ps
, depth
))
2578 /*******************************************************************
2579 reads or writes a structure.
2580 ********************************************************************/
2581 static BOOL
net_io_sam_privs_info(const char *desc
, SAM_DELTA_PRIVS
*info
,
2582 prs_struct
*ps
, int depth
)
2586 prs_debug(ps
, depth
, desc
, "net_io_sam_privs_info");
2592 if(!smb_io_dom_sid2("sid", &info
->sid
, ps
, depth
))
2595 if(!prs_uint32("priv_count", ps
, depth
, &info
->priv_count
))
2597 if(!prs_uint32("priv_control", ps
, depth
, &info
->priv_control
))
2600 if(!prs_uint32("priv_attr_ptr", ps
, depth
, &info
->priv_attr_ptr
))
2602 if(!prs_uint32("priv_name_ptr", ps
, depth
, &info
->priv_name_ptr
))
2605 if (!prs_uint32("paged_pool_limit", ps
, depth
, &info
->paged_pool_limit
))
2607 if (!prs_uint32("non_paged_pool_limit", ps
, depth
,
2608 &info
->non_paged_pool_limit
))
2610 if (!prs_uint32("min_workset_size", ps
, depth
, &info
->min_workset_size
))
2612 if (!prs_uint32("max_workset_size", ps
, depth
, &info
->max_workset_size
))
2614 if (!prs_uint32("page_file_limit", ps
, depth
, &info
->page_file_limit
))
2616 if (!prs_uint64("time_limit", ps
, depth
, &info
->time_limit
))
2618 if (!prs_uint32("system_flags", ps
, depth
, &info
->system_flags
))
2620 if (!smb_io_bufhdr2("hdr_sec_desc", &info
->hdr_sec_desc
, ps
, depth
))
2623 for (i
=0; i
<4; i
++) {
2625 if (!smb_io_unihdr("dummy", &dummy
, ps
, depth
))
2629 for (i
=0; i
<4; i
++) {
2631 if (!prs_uint32("reserved", ps
, depth
, &reserved
))
2635 if(!prs_uint32("attribute_count", ps
, depth
, &info
->attribute_count
))
2638 info
->attributes
= talloc(ps
->mem_ctx
, sizeof(uint32
) * info
->attribute_count
);
2640 for (i
=0; i
<info
->attribute_count
; i
++)
2641 if(!prs_uint32("attributes", ps
, depth
, &info
->attributes
[i
]))
2644 if(!prs_uint32("privlist_count", ps
, depth
, &info
->privlist_count
))
2647 info
->hdr_privslist
= talloc(ps
->mem_ctx
, sizeof(UNIHDR
) * info
->privlist_count
);
2648 info
->uni_privslist
= talloc(ps
->mem_ctx
, sizeof(UNISTR2
) * info
->privlist_count
);
2650 for (i
=0; i
<info
->privlist_count
; i
++)
2651 if(!smb_io_unihdr("hdr_privslist", &info
->hdr_privslist
[i
], ps
, depth
))
2654 for (i
=0; i
<info
->privlist_count
; i
++)
2655 if (!smb_io_unistr2("uni_privslist", &info
->uni_privslist
[i
], True
, ps
, depth
))
2658 if (!smb_io_buffer4("buf_sec_desc", &info
->buf_sec_desc
,
2659 info
->hdr_sec_desc
.buffer
, ps
, depth
))
2665 /*******************************************************************
2666 reads or writes a structure.
2667 ********************************************************************/
2668 static BOOL
net_io_sam_delta_ctr(const char *desc
, uint8 sess_key
[16],
2669 SAM_DELTA_CTR
* delta
, uint16 type
,
2670 prs_struct
*ps
, int depth
)
2672 prs_debug(ps
, depth
, desc
, "net_io_sam_delta_ctr");
2676 /* Seen in sam deltas */
2677 case SAM_DELTA_MODIFIED_COUNT
:
2678 if (!net_io_sam_delta_mod_count("", &delta
->mod_count
, ps
, depth
))
2682 case SAM_DELTA_DOMAIN_INFO
:
2683 if (!net_io_sam_domain_info("", &delta
->domain_info
, ps
, depth
))
2687 case SAM_DELTA_GROUP_INFO
:
2688 if (!net_io_sam_group_info("", &delta
->group_info
, ps
, depth
))
2692 case SAM_DELTA_ACCOUNT_INFO
:
2693 if (!net_io_sam_account_info("", sess_key
, &delta
->account_info
, ps
, depth
))
2697 case SAM_DELTA_GROUP_MEM
:
2698 if (!net_io_sam_group_mem_info("", &delta
->grp_mem_info
, ps
, depth
))
2702 case SAM_DELTA_ALIAS_INFO
:
2703 if (!net_io_sam_alias_info("", &delta
->alias_info
, ps
, depth
))
2707 case SAM_DELTA_POLICY_INFO
:
2708 if (!net_io_sam_policy_info("", &delta
->policy_info
, ps
, depth
))
2712 case SAM_DELTA_ALIAS_MEM
:
2713 if (!net_io_sam_alias_mem_info("", &delta
->als_mem_info
, ps
, depth
))
2717 case SAM_DELTA_PRIVS_INFO
:
2718 if (!net_io_sam_privs_info("", &delta
->privs_info
, ps
, depth
))
2722 /* These guys are implemented but broken */
2724 case SAM_DELTA_TRUST_DOMS
:
2725 case SAM_DELTA_SECRET_INFO
:
2728 /* These guys are not implemented yet */
2730 case SAM_DELTA_RENAME_GROUP
:
2731 case SAM_DELTA_RENAME_USER
:
2732 case SAM_DELTA_RENAME_ALIAS
:
2733 case SAM_DELTA_DELETE_GROUP
:
2734 case SAM_DELTA_DELETE_USER
:
2736 DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type
));
2743 /*******************************************************************
2744 reads or writes a structure.
2745 ********************************************************************/
2746 BOOL
net_io_r_sam_sync(const char *desc
, uint8 sess_key
[16],
2747 NET_R_SAM_SYNC
* r_s
, prs_struct
*ps
, int depth
)
2751 prs_debug(ps
, depth
, desc
, "net_io_r_sam_sync");
2754 if (!smb_io_cred("srv_creds", &r_s
->srv_creds
, ps
, depth
))
2756 if (!prs_uint32("sync_context", ps
, depth
, &r_s
->sync_context
))
2759 if (!prs_uint32("ptr_deltas", ps
, depth
, &r_s
->ptr_deltas
))
2761 if (r_s
->ptr_deltas
!= 0)
2763 if (!prs_uint32("num_deltas ", ps
, depth
, &r_s
->num_deltas
))
2765 if (!prs_uint32("ptr_deltas2", ps
, depth
, &r_s
->ptr_deltas2
))
2767 if (r_s
->ptr_deltas2
!= 0)
2769 if (!prs_uint32("num_deltas2", ps
, depth
,
2773 if (r_s
->num_deltas2
!= r_s
->num_deltas
)
2779 if (r_s
->num_deltas2
> 0) {
2780 r_s
->hdr_deltas
= (SAM_DELTA_HDR
*)
2781 talloc(ps
->mem_ctx
, r_s
->num_deltas2
*
2782 sizeof(SAM_DELTA_HDR
));
2784 if (r_s
->hdr_deltas
== NULL
) {
2785 DEBUG(0, ("error tallocating memory "
2786 "for %d delta headers\n",
2792 for (i
= 0; i
< r_s
->num_deltas2
; i
++)
2794 if (!net_io_sam_delta_hdr("",
2795 &r_s
->hdr_deltas
[i
],
2800 if (r_s
->num_deltas2
> 0) {
2801 r_s
->deltas
= (SAM_DELTA_CTR
*)
2802 talloc(ps
->mem_ctx
, r_s
->num_deltas2
*
2803 sizeof(SAM_DELTA_CTR
));
2805 if (r_s
->deltas
== NULL
) {
2806 DEBUG(0, ("error tallocating memory "
2813 for (i
= 0; i
< r_s
->num_deltas2
; i
++)
2815 if (!net_io_sam_delta_ctr(
2816 "", sess_key
, &r_s
->deltas
[i
],
2817 r_s
->hdr_deltas
[i
].type3
,
2819 DEBUG(0, ("hmm, failed on i=%d\n", i
));
2827 if (!prs_ntstatus("status", ps
, depth
, &(r_s
->status
)))
2833 /*******************************************************************
2834 makes a NET_Q_SAM_DELTAS structure.
2835 ********************************************************************/
2836 BOOL
init_net_q_sam_deltas(NET_Q_SAM_DELTAS
*q_s
, const char *srv_name
,
2837 const char *cli_name
, DOM_CRED
*cli_creds
,
2838 uint32 database_id
, UINT64_S dom_mod_count
)
2840 DEBUG(5, ("init_net_q_sam_deltas\n"));
2842 init_unistr2(&q_s
->uni_srv_name
, srv_name
, UNI_STR_TERMINATE
);
2843 init_unistr2(&q_s
->uni_cli_name
, cli_name
, UNI_STR_TERMINATE
);
2845 memcpy(&q_s
->cli_creds
, cli_creds
, sizeof(q_s
->cli_creds
));
2846 memset(&q_s
->ret_creds
, 0, sizeof(q_s
->ret_creds
));
2848 q_s
->database_id
= database_id
;
2849 q_s
->dom_mod_count
.low
= dom_mod_count
.low
;
2850 q_s
->dom_mod_count
.high
= dom_mod_count
.high
;
2851 q_s
->max_size
= 0xffff;
2856 /*******************************************************************
2857 reads or writes a structure.
2858 ********************************************************************/
2859 BOOL
net_io_q_sam_deltas(const char *desc
, NET_Q_SAM_DELTAS
*q_s
, prs_struct
*ps
,
2862 prs_debug(ps
, depth
, desc
, "net_io_q_sam_deltas");
2865 if (!smb_io_unistr2("", &q_s
->uni_srv_name
, True
, ps
, depth
))
2867 if (!smb_io_unistr2("", &q_s
->uni_cli_name
, True
, ps
, depth
))
2870 if (!smb_io_cred("", &q_s
->cli_creds
, ps
, depth
))
2872 if (!smb_io_cred("", &q_s
->ret_creds
, ps
, depth
))
2875 if (!prs_uint32("database_id ", ps
, depth
, &q_s
->database_id
))
2877 if (!prs_uint64("dom_mod_count", ps
, depth
, &q_s
->dom_mod_count
))
2879 if (!prs_uint32("max_size", ps
, depth
, &q_s
->max_size
))
2885 /*******************************************************************
2886 reads or writes a structure.
2887 ********************************************************************/
2888 BOOL
net_io_r_sam_deltas(const char *desc
, uint8 sess_key
[16],
2889 NET_R_SAM_DELTAS
*r_s
, prs_struct
*ps
, int depth
)
2893 prs_debug(ps
, depth
, desc
, "net_io_r_sam_deltas");
2896 if (!smb_io_cred("srv_creds", &r_s
->srv_creds
, ps
, depth
))
2898 if (!prs_uint64("dom_mod_count", ps
, depth
, &r_s
->dom_mod_count
))
2901 if (!prs_uint32("ptr_deltas", ps
, depth
, &r_s
->ptr_deltas
))
2903 if (!prs_uint32("num_deltas", ps
, depth
, &r_s
->num_deltas
))
2905 if (!prs_uint32("ptr_deltas2", ps
, depth
, &r_s
->num_deltas2
))
2908 if (r_s
->num_deltas2
!= 0)
2910 if (!prs_uint32("num_deltas2 ", ps
, depth
, &r_s
->num_deltas2
))
2913 if (r_s
->ptr_deltas
!= 0)
2915 if (r_s
->num_deltas
> 0) {
2916 r_s
->hdr_deltas
= (SAM_DELTA_HDR
*)
2917 talloc(ps
->mem_ctx
, r_s
->num_deltas
*
2918 sizeof(SAM_DELTA_HDR
));
2919 if (r_s
->hdr_deltas
== NULL
) {
2920 DEBUG(0, ("error tallocating memory "
2921 "for %d delta headers\n",
2927 for (i
= 0; i
< r_s
->num_deltas
; i
++)
2929 net_io_sam_delta_hdr("", &r_s
->hdr_deltas
[i
],
2933 if (r_s
->num_deltas
> 0) {
2934 r_s
->deltas
= (SAM_DELTA_CTR
*)
2935 talloc(ps
->mem_ctx
, r_s
->num_deltas
*
2936 sizeof(SAM_DELTA_CTR
));
2938 if (r_s
->deltas
== NULL
) {
2939 DEBUG(0, ("error tallocating memory "
2946 for (i
= 0; i
< r_s
->num_deltas
; i
++)
2948 if (!net_io_sam_delta_ctr(
2951 r_s
->hdr_deltas
[i
].type2
,
2960 if (!prs_ntstatus("status", ps
, depth
, &r_s
->status
))