1/* 2 * Unix SMB/CIFS implementation. 3 * RPC Pipe client / server routines 4 * Copyright (C) Andrew Tridgell 1992-2000, 5 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, 6 * Copyright (C) Paul Ashton 1997-2000, 7 * Copyright (C) Elrond 2000, 8 * Copyright (C) Jeremy Allison 2001, 9 * Copyright (C) Jean Fran�ois Micouleau 1998-2001, 10 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 */ 26 27#include "includes.h" 28#include "rpc_parse.h" 29#include "nterr.h" 30 31#undef DBGC_CLASS 32#define DBGC_CLASS DBGC_RPC_PARSE 33 34/******************************************************************* 35inits a SAMR_Q_CLOSE_HND structure. 36********************************************************************/ 37 38void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd) 39{ 40 DEBUG(5, ("init_samr_q_close_hnd\n")); 41 42 q_c->pol = *hnd; 43} 44 45/******************************************************************* 46reads or writes a structure. 47********************************************************************/ 48 49BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u, 50 prs_struct *ps, int depth) 51{ 52 if (q_u == NULL) 53 return False; 54 55 prs_debug(ps, depth, desc, "samr_io_q_close_hnd"); 56 depth++; 57 58 if(!prs_align(ps)) 59 return False; 60 61 return smb_io_pol_hnd("pol", &q_u->pol, ps, depth); 62} 63 64/******************************************************************* 65reads or writes a structure. 66********************************************************************/ 67 68BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u, 69 prs_struct *ps, int depth) 70{ 71 if (r_u == NULL) 72 return False; 73 74 prs_debug(ps, depth, desc, "samr_io_r_close_hnd"); 75 depth++; 76 77 if(!prs_align(ps)) 78 return False; 79 80 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 81 return False; 82 83 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 84 return False; 85 86 return True; 87} 88 89/******************************************************************* 90inits a SAMR_Q_LOOKUP_DOMAIN structure. 91********************************************************************/ 92 93void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u, 94 POLICY_HND *pol, char *dom_name) 95{ 96 DEBUG(5, ("init_samr_q_lookup_domain\n")); 97 98 q_u->connect_pol = *pol; 99 100 init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE); 101 init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain); 102} 103 104/******************************************************************* 105reads or writes a structure. 106********************************************************************/ 107BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u, 108 prs_struct *ps, int depth) 109{ 110 if (q_u == NULL) 111 return False; 112 113 prs_debug(ps, depth, desc, "samr_io_q_lookup_domain"); 114 depth++; 115 116 if(!prs_align(ps)) 117 return False; 118 119 if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth)) 120 return False; 121 122 if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth)) 123 return False; 124 125 if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth)) 126 return False; 127 128 return True; 129} 130 131/******************************************************************* 132inits a SAMR_R_LOOKUP_DOMAIN structure. 133********************************************************************/ 134 135void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u, 136 DOM_SID *dom_sid, NTSTATUS status) 137{ 138 DEBUG(5, ("init_samr_r_lookup_domain\n")); 139 140 r_u->status = status; 141 r_u->ptr_sid = 0; 142 if (NT_STATUS_IS_OK(status)) { 143 r_u->ptr_sid = 1; 144 init_dom_sid2(&r_u->dom_sid, dom_sid); 145 } 146} 147 148/******************************************************************* 149reads or writes a structure. 150********************************************************************/ 151 152BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u, 153 prs_struct *ps, int depth) 154{ 155 if (r_u == NULL) 156 return False; 157 158 prs_debug(ps, depth, desc, "samr_io_r_lookup_domain"); 159 depth++; 160 161 if(!prs_align(ps)) 162 return False; 163 164 if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid)) 165 return False; 166 167 if (r_u->ptr_sid != 0) { 168 if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth)) 169 return False; 170 if(!prs_align(ps)) 171 return False; 172 } 173 174 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 175 return False; 176 177 return True; 178} 179 180/******************************************************************* 181reads or writes a structure. 182********************************************************************/ 183 184void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid) 185{ 186 DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n")); 187 188 q_u->dom_pol = *dom_pol; 189 init_dom_sid2(&q_u->sid, sid); 190} 191 192/******************************************************************* 193reads or writes a structure. 194********************************************************************/ 195 196BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, 197 prs_struct *ps, int depth) 198{ 199 if (q_u == NULL) 200 return False; 201 202 prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain"); 203 depth++; 204 205 if(!prs_align(ps)) 206 return False; 207 208 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth)) 209 return False; 210 211 if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth)) 212 return False; 213 214 if(!prs_align(ps)) 215 return False; 216 217 return True; 218} 219 220/******************************************************************* 221reads or writes a structure. 222********************************************************************/ 223 224BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u, 225 prs_struct *ps, int depth) 226{ 227 if (r_u == NULL) 228 return False; 229 230 prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain"); 231 depth++; 232 233 if(!prs_align(ps)) 234 return False; 235 236 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 237 return False; 238 239 return True; 240} 241 242/******************************************************************* 243reads or writes a structure. 244********************************************************************/ 245 246void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u, 247 POLICY_HND *pol, uint32 flags, 248 const DOM_SID *sid) 249{ 250 DEBUG(5, ("samr_init_samr_q_open_domain\n")); 251 252 q_u->pol = *pol; 253 q_u->flags = flags; 254 init_dom_sid2(&q_u->dom_sid, sid); 255} 256 257/******************************************************************* 258reads or writes a structure. 259********************************************************************/ 260 261BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u, 262 prs_struct *ps, int depth) 263{ 264 if (q_u == NULL) 265 return False; 266 267 prs_debug(ps, depth, desc, "samr_io_q_open_domain"); 268 depth++; 269 270 if(!prs_align(ps)) 271 return False; 272 273 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 274 return False; 275 276 if(!prs_uint32("flags", ps, depth, &q_u->flags)) 277 return False; 278 279 if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth)) 280 return False; 281 282 return True; 283} 284 285/******************************************************************* 286reads or writes a structure. 287********************************************************************/ 288 289BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u, 290 prs_struct *ps, int depth) 291{ 292 if (r_u == NULL) 293 return False; 294 295 prs_debug(ps, depth, desc, "samr_io_r_open_domain"); 296 depth++; 297 298 if(!prs_align(ps)) 299 return False; 300 301 if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth)) 302 return False; 303 304 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 305 return False; 306 307 return True; 308} 309 310/******************************************************************* 311reads or writes a structure. 312********************************************************************/ 313 314void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u, 315 POLICY_HND *user_pol) 316{ 317 DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n")); 318 319 q_u->user_pol = *user_pol; 320} 321 322/******************************************************************* 323reads or writes a structure. 324********************************************************************/ 325 326BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u, 327 prs_struct *ps, int depth) 328{ 329 if (q_u == NULL) 330 return False; 331 332 prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo"); 333 depth++; 334 335 if(!prs_align(ps)) 336 return False; 337 338 return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth); 339} 340 341/******************************************************************* 342 Init. 343********************************************************************/ 344 345void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status) 346{ 347 DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n")); 348 349 r_u->unknown_0 = 0x0000; 350 351 /* 352 * used to be 353 * r_u->unknown_1 = 0x0015; 354 * but for trusts. 355 */ 356 r_u->unknown_1 = 0x01D1; 357 r_u->unknown_1 = 0x0015; 358 359 r_u->unknown_2 = 0x00000000; 360 361 r_u->status = status; 362} 363 364/******************************************************************* 365reads or writes a structure. 366********************************************************************/ 367 368BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u, 369 prs_struct *ps, int depth) 370{ 371 if (r_u == NULL) 372 return False; 373 374 prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo"); 375 depth++; 376 377 if(!prs_align(ps)) 378 return False; 379 380 if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0)) 381 return False; 382 if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1)) 383 return False; 384 if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2)) 385 return False; 386 if(!prs_ntstatus("status ", ps, depth, &r_u->status)) 387 return False; 388 389 return True; 390} 391 392 393/******************************************************************* 394reads or writes a structure. 395********************************************************************/ 396 397BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u, 398 prs_struct *ps, int depth) 399{ 400 if (q_u == NULL) 401 return False; 402 403 prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj"); 404 depth++; 405 406 if(!prs_align(ps)) 407 return False; 408 409 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 410 return False; 411 412 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) 413 return False; 414 415 if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth)) 416 return False; 417 418 return True; 419} 420 421 422/******************************************************************* 423reads or writes a structure. 424********************************************************************/ 425 426void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u, 427 POLICY_HND *user_pol, uint32 sec_info) 428{ 429 DEBUG(5, ("samr_init_samr_q_query_sec_obj\n")); 430 431 q_u->user_pol = *user_pol; 432 q_u->sec_info = sec_info; 433} 434 435 436/******************************************************************* 437reads or writes a structure. 438********************************************************************/ 439 440BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u, 441 prs_struct *ps, int depth) 442{ 443 if (q_u == NULL) 444 return False; 445 446 prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj"); 447 depth++; 448 449 if(!prs_align(ps)) 450 return False; 451 452 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth)) 453 return False; 454 455 if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) 456 return False; 457 458 return True; 459} 460 461/******************************************************************* 462reads or writes a structure. 463********************************************************************/ 464 465void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u, 466 POLICY_HND *domain_pol, uint16 switch_value) 467{ 468 DEBUG(5, ("samr_init_samr_q_query_dom_info\n")); 469 470 q_u->domain_pol = *domain_pol; 471 q_u->switch_value = switch_value; 472} 473 474/******************************************************************* 475reads or writes a structure. 476********************************************************************/ 477 478BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u, 479 prs_struct *ps, int depth) 480{ 481 if (q_u == NULL) 482 return False; 483 484 prs_debug(ps, depth, desc, "samr_io_q_query_dom_info"); 485 depth++; 486 487 if(!prs_align(ps)) 488 return False; 489 490 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 491 return False; 492 493 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) 494 return False; 495 496 return True; 497} 498 499 500/******************************************************************* 501inits a structure. 502********************************************************************/ 503 504void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout) 505{ 506 u_3->logout.low = nt_logout.low; 507 u_3->logout.high = nt_logout.high; 508} 509 510/******************************************************************* 511reads or writes a structure. 512********************************************************************/ 513 514static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3, 515 prs_struct *ps, int depth) 516{ 517 if (u_3 == NULL) 518 return False; 519 520 prs_debug(ps, depth, desc, "sam_io_unk_info3"); 521 depth++; 522 523 if(!smb_io_time("logout", &u_3->logout, ps, depth)) 524 return False; 525 526 return True; 527} 528 529/******************************************************************* 530inits a structure. 531********************************************************************/ 532 533void init_unk_info6(SAM_UNK_INFO_6 * u_6) 534{ 535 u_6->unknown_0 = 0x00000000; 536 u_6->ptr_0 = 1; 537 memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */ 538} 539 540/******************************************************************* 541reads or writes a structure. 542********************************************************************/ 543 544static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6, 545 prs_struct *ps, int depth) 546{ 547 if (u_6 == NULL) 548 return False; 549 550 prs_debug(ps, depth, desc, "sam_io_unk_info6"); 551 depth++; 552 553 if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */ 554 return False; 555 if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */ 556 return False; 557 if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */ 558 return False; 559 560 return True; 561} 562 563/******************************************************************* 564inits a structure. 565********************************************************************/ 566 567void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role) 568{ 569 u_7->server_role = server_role; 570} 571 572/******************************************************************* 573reads or writes a structure. 574********************************************************************/ 575 576static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7, 577 prs_struct *ps, int depth) 578{ 579 if (u_7 == NULL) 580 return False; 581 582 prs_debug(ps, depth, desc, "sam_io_unk_info7"); 583 depth++; 584 585 if(!prs_uint16("server_role", ps, depth, &u_7->server_role)) 586 return False; 587 588 return True; 589} 590 591/******************************************************************* 592inits a structure. 593********************************************************************/ 594 595void init_unk_info8(SAM_UNK_INFO_8 * u_8, uint32 seq_num) 596{ 597 unix_to_nt_time(&u_8->domain_create_time, 0); 598 u_8->seq_num.low = seq_num; 599 u_8->seq_num.high = 0x0000; 600} 601 602/******************************************************************* 603reads or writes a structure. 604********************************************************************/ 605 606static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8, 607 prs_struct *ps, int depth) 608{ 609 if (u_8 == NULL) 610 return False; 611 612 prs_debug(ps, depth, desc, "sam_io_unk_info8"); 613 depth++; 614 615 if (!prs_uint64("seq_num", ps, depth, &u_8->seq_num)) 616 return False; 617 618 if(!smb_io_time("domain_create_time", &u_8->domain_create_time, ps, depth)) 619 return False; 620 621 return True; 622} 623 624 625/******************************************************************* 626inits a structure. 627********************************************************************/ 628 629void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout) 630{ 631 u_12->duration.low = nt_lock_duration.low; 632 u_12->duration.high = nt_lock_duration.high; 633 u_12->reset_count.low = nt_reset_time.low; 634 u_12->reset_count.high = nt_reset_time.high; 635 636 u_12->bad_attempt_lockout = lockout; 637} 638 639/******************************************************************* 640reads or writes a structure. 641********************************************************************/ 642 643static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12, 644 prs_struct *ps, int depth) 645{ 646 if (u_12 == NULL) 647 return False; 648 649 prs_debug(ps, depth, desc, "sam_io_unk_info12"); 650 depth++; 651 652 if(!smb_io_time("duration", &u_12->duration, ps, depth)) 653 return False; 654 if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth)) 655 return False; 656 if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout)) 657 return False; 658 659 return True; 660} 661 662/******************************************************************* 663inits a structure. 664********************************************************************/ 665 666void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server) 667{ 668 init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE); 669 init_uni_hdr(&u_5->hdr_server, &u_5->uni_server); 670} 671 672/******************************************************************* 673reads or writes a structure. 674********************************************************************/ 675 676static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5, 677 prs_struct *ps, int depth) 678{ 679 if (u_5 == NULL) 680 return False; 681 682 prs_debug(ps, depth, desc, "sam_io_unk_info5"); 683 depth++; 684 685 if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth)) 686 return False; 687 688 if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth)) 689 return False; 690 691 return True; 692} 693 694/******************************************************************* 695inits a structure. 696********************************************************************/ 697 698void init_unk_info2(SAM_UNK_INFO_2 * u_2, 699 const char *comment, const char *domain, const char *server, 700 uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role) 701{ 702 u_2->logout.low = nt_logout.low; 703 u_2->logout.high = nt_logout.high; 704 705 u_2->seq_num.low = seq_num; 706 u_2->seq_num.high = 0x00000000; 707 708 709 u_2->unknown_4 = 0x00000001; 710 u_2->server_role = server_role; 711 u_2->unknown_6 = 0x00000001; 712 u_2->num_domain_usrs = num_users; 713 u_2->num_domain_grps = num_groups; 714 u_2->num_local_grps = num_alias; 715 716 memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */ 717 718 init_unistr2(&u_2->uni_comment, comment, UNI_FLAGS_NONE); 719 init_uni_hdr(&u_2->hdr_comment, &u_2->uni_comment); 720 init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE); 721 init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain); 722 init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE); 723 init_uni_hdr(&u_2->hdr_server, &u_2->uni_server); 724} 725 726/******************************************************************* 727reads or writes a structure. 728********************************************************************/ 729 730static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2, 731 prs_struct *ps, int depth) 732{ 733 if (u_2 == NULL) 734 return False; 735 736 prs_debug(ps, depth, desc, "sam_io_unk_info2"); 737 depth++; 738 739 if(!smb_io_time("logout", &u_2->logout, ps, depth)) 740 return False; 741 if(!smb_io_unihdr("hdr_comment", &u_2->hdr_comment, ps, depth)) 742 return False; 743 if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth)) 744 return False; 745 if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth)) 746 return False; 747 748 /* put all the data in here, at the moment, including what the above 749 pointer is referring to 750 */ 751 752 if(!prs_uint64("seq_num ", ps, depth, &u_2->seq_num)) 753 return False; 754 755 if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */ 756 return False; 757 if(!prs_uint32("server_role ", ps, depth, &u_2->server_role)) 758 return False; 759 if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */ 760 return False; 761 if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs)) 762 return False; 763 if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps)) 764 return False; 765 if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps)) 766 return False; 767 768 if(!smb_io_unistr2("uni_comment", &u_2->uni_comment, u_2->hdr_comment.buffer, ps, depth)) 769 return False; 770 if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth)) 771 return False; 772 if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth)) 773 return False; 774 775 return True; 776} 777 778/******************************************************************* 779inits a structure. 780********************************************************************/ 781 782void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist, 783 uint32 flag, NTTIME nt_expire, NTTIME nt_min_age) 784{ 785 u_1->min_length_password = min_pass_len; 786 u_1->password_history = pass_hist; 787 u_1->flag = flag; 788 789 /* password never expire */ 790 u_1->expire.high = nt_expire.high; 791 u_1->expire.low = nt_expire.low; 792 793 /* can change the password now */ 794 u_1->min_passwordage.high = nt_min_age.high; 795 u_1->min_passwordage.low = nt_min_age.low; 796 797} 798 799/******************************************************************* 800reads or writes a structure. 801********************************************************************/ 802 803static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1, 804 prs_struct *ps, int depth) 805{ 806 if (u_1 == NULL) 807 return False; 808 809 prs_debug(ps, depth, desc, "sam_io_unk_info1"); 810 depth++; 811 812 if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password)) 813 return False; 814 if(!prs_uint16("password_history", ps, depth, &u_1->password_history)) 815 return False; 816 if(!prs_uint32("flag", ps, depth, &u_1->flag)) 817 return False; 818 if(!smb_io_time("expire", &u_1->expire, ps, depth)) 819 return False; 820 if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth)) 821 return False; 822 823 return True; 824} 825 826/******************************************************************* 827inits a SAMR_R_QUERY_DOMAIN_INFO structure. 828********************************************************************/ 829 830void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u, 831 uint16 switch_value, SAM_UNK_CTR * ctr, 832 NTSTATUS status) 833{ 834 DEBUG(5, ("init_samr_r_query_dom_info\n")); 835 836 r_u->ptr_0 = 0; 837 r_u->switch_value = 0; 838 r_u->status = status; /* return status */ 839 840 if (NT_STATUS_IS_OK(status)) { 841 r_u->switch_value = switch_value; 842 r_u->ptr_0 = 1; 843 r_u->ctr = ctr; 844 } 845} 846 847/******************************************************************* 848reads or writes a structure. 849********************************************************************/ 850 851BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u, 852 prs_struct *ps, int depth) 853{ 854 if (r_u == NULL) 855 return False; 856 857 prs_debug(ps, depth, desc, "samr_io_r_query_dom_info"); 858 depth++; 859 860 if(!prs_align(ps)) 861 return False; 862 863 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) 864 return False; 865 866 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) { 867 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) 868 return False; 869 if(!prs_align(ps)) 870 return False; 871 872 switch (r_u->switch_value) { 873 case 0x0c: 874 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth)) 875 return False; 876 break; 877 case 0x08: 878 if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth)) 879 return False; 880 break; 881 case 0x07: 882 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth)) 883 return False; 884 break; 885 case 0x06: 886 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth)) 887 return False; 888 break; 889 case 0x05: 890 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth)) 891 return False; 892 break; 893 case 0x03: 894 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth)) 895 return False; 896 break; 897 case 0x02: 898 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth)) 899 return False; 900 break; 901 case 0x01: 902 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth)) 903 return False; 904 break; 905 default: 906 DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n", 907 r_u->switch_value)); 908 r_u->status = NT_STATUS_INVALID_INFO_CLASS; 909 return False; 910 } 911 } 912 913 if(!prs_align(ps)) 914 return False; 915 916 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 917 return False; 918 919 return True; 920} 921 922/******************************************************************* 923reads or writes a SAMR_R_SET_SEC_OBJ structure. 924********************************************************************/ 925 926BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u, 927 prs_struct *ps, int depth) 928{ 929 if (r_u == NULL) 930 return False; 931 932 prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj"); 933 depth++; 934 935 if(!prs_align(ps)) 936 return False; 937 938 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 939 return False; 940 941 return True; 942} 943 944/******************************************************************* 945reads or writes a SAMR_R_QUERY_SEC_OBJ structure. 946********************************************************************/ 947 948BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u, 949 prs_struct *ps, int depth) 950{ 951 if (r_u == NULL) 952 return False; 953 954 prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj"); 955 depth++; 956 957 if(!prs_align(ps)) 958 return False; 959 960 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 961 return False; 962 if (r_u->ptr != 0) { 963 if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth)) 964 return False; 965 } 966 967 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 968 return False; 969 970 return True; 971} 972 973/******************************************************************* 974reads or writes a SAM_STR1 structure. 975********************************************************************/ 976 977static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf, 978 uint32 name_buf, uint32 desc_buf, 979 prs_struct *ps, int depth) 980{ 981 if (sam == NULL) 982 return False; 983 984 prs_debug(ps, depth, desc, "sam_io_sam_str1"); 985 depth++; 986 987 if(!prs_align(ps)) 988 return False; 989 if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth)) 990 return False; 991 992 if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth)) 993 return False; 994 995 if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth)) 996 return False; 997 998 return True; 999} 1000 1001/******************************************************************* 1002inits a SAM_ENTRY1 structure. 1003********************************************************************/ 1004 1005static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx, 1006 UNISTR2 *sam_name, UNISTR2 *sam_full, 1007 UNISTR2 *sam_desc, uint32 rid_user, 1008 uint16 acb_info) 1009{ 1010 DEBUG(5, ("init_sam_entry1\n")); 1011 1012 ZERO_STRUCTP(sam); 1013 1014 sam->user_idx = user_idx; 1015 sam->rid_user = rid_user; 1016 sam->acb_info = acb_info; 1017 1018 init_uni_hdr(&sam->hdr_acct_name, sam_name); 1019 init_uni_hdr(&sam->hdr_user_name, sam_full); 1020 init_uni_hdr(&sam->hdr_user_desc, sam_desc); 1021} 1022 1023/******************************************************************* 1024reads or writes a SAM_ENTRY1 structure. 1025********************************************************************/ 1026 1027static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam, 1028 prs_struct *ps, int depth) 1029{ 1030 if (sam == NULL) 1031 return False; 1032 1033 prs_debug(ps, depth, desc, "sam_io_sam_entry1"); 1034 depth++; 1035 1036 if(!prs_align(ps)) 1037 return False; 1038 1039 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx)) 1040 return False; 1041 1042 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user)) 1043 return False; 1044 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info)) 1045 return False; 1046 1047 if(!prs_align(ps)) 1048 return False; 1049 1050 if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth)) 1051 return False; 1052 if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth)) 1053 return False; 1054 if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth)) 1055 return False; 1056 1057 return True; 1058} 1059 1060/******************************************************************* 1061reads or writes a SAM_STR2 structure. 1062********************************************************************/ 1063 1064static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf, 1065 uint32 desc_buf, prs_struct *ps, int depth) 1066{ 1067 if (sam == NULL) 1068 return False; 1069 1070 prs_debug(ps, depth, desc, "sam_io_sam_str2"); 1071 depth++; 1072 1073 if(!prs_align(ps)) 1074 return False; 1075 1076 if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */ 1077 return False; 1078 if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */ 1079 return False; 1080 1081 return True; 1082} 1083 1084/******************************************************************* 1085inits a SAM_ENTRY2 structure. 1086********************************************************************/ 1087static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx, 1088 UNISTR2 *sam_name, UNISTR2 *sam_desc, 1089 uint32 rid_user, uint16 acb_info) 1090{ 1091 DEBUG(5, ("init_sam_entry2\n")); 1092 1093 sam->user_idx = user_idx; 1094 sam->rid_user = rid_user; 1095 sam->acb_info = acb_info; 1096 1097 init_uni_hdr(&sam->hdr_srv_name, sam_name); 1098 init_uni_hdr(&sam->hdr_srv_desc, sam_desc); 1099} 1100 1101/******************************************************************* 1102reads or writes a SAM_ENTRY2 structure. 1103********************************************************************/ 1104 1105static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam, 1106 prs_struct *ps, int depth) 1107{ 1108 if (sam == NULL) 1109 return False; 1110 1111 prs_debug(ps, depth, desc, "sam_io_sam_entry2"); 1112 depth++; 1113 1114 if(!prs_align(ps)) 1115 return False; 1116 1117 if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx)) 1118 return False; 1119 1120 if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user)) 1121 return False; 1122 if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info)) 1123 return False; 1124 1125 if(!prs_align(ps)) 1126 return False; 1127 1128 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */ 1129 return False; 1130 if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */ 1131 return False; 1132 1133 return True; 1134} 1135 1136/******************************************************************* 1137reads or writes a SAM_STR3 structure. 1138********************************************************************/ 1139 1140static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf, 1141 uint32 desc_buf, prs_struct *ps, int depth) 1142{ 1143 if (sam == NULL) 1144 return False; 1145 1146 prs_debug(ps, depth, desc, "sam_io_sam_str3"); 1147 depth++; 1148 1149 if(!prs_align(ps)) 1150 return False; 1151 1152 if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */ 1153 return False; 1154 if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */ 1155 return False; 1156 1157 return True; 1158} 1159 1160/******************************************************************* 1161inits a SAM_ENTRY3 structure. 1162********************************************************************/ 1163 1164static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx, 1165 UNISTR2 *grp_name, UNISTR2 *grp_desc, 1166 uint32 rid_grp) 1167{ 1168 DEBUG(5, ("init_sam_entry3\n")); 1169 1170 sam->grp_idx = grp_idx; 1171 sam->rid_grp = rid_grp; 1172 sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */ 1173 1174 init_uni_hdr(&sam->hdr_grp_name, grp_name); 1175 init_uni_hdr(&sam->hdr_grp_desc, grp_desc); 1176} 1177 1178/******************************************************************* 1179reads or writes a SAM_ENTRY3 structure. 1180********************************************************************/ 1181 1182static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam, 1183 prs_struct *ps, int depth) 1184{ 1185 if (sam == NULL) 1186 return False; 1187 1188 prs_debug(ps, depth, desc, "sam_io_sam_entry3"); 1189 depth++; 1190 1191 if(!prs_align(ps)) 1192 return False; 1193 1194 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx)) 1195 return False; 1196 1197 if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp)) 1198 return False; 1199 if(!prs_uint32("attr ", ps, depth, &sam->attr)) 1200 return False; 1201 1202 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */ 1203 return False; 1204 if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */ 1205 return False; 1206 1207 return True; 1208} 1209 1210/******************************************************************* 1211inits a SAM_ENTRY4 structure. 1212********************************************************************/ 1213 1214static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx, 1215 uint32 len_acct_name) 1216{ 1217 DEBUG(5, ("init_sam_entry4\n")); 1218 1219 sam->user_idx = user_idx; 1220 init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0); 1221} 1222 1223/******************************************************************* 1224reads or writes a SAM_ENTRY4 structure. 1225********************************************************************/ 1226 1227static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam, 1228 prs_struct *ps, int depth) 1229{ 1230 if (sam == NULL) 1231 return False; 1232 1233 prs_debug(ps, depth, desc, "sam_io_sam_entry4"); 1234 depth++; 1235 1236 if(!prs_align(ps)) 1237 return False; 1238 1239 if(!prs_uint32("user_idx", ps, depth, &sam->user_idx)) 1240 return False; 1241 if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth)) 1242 return False; 1243 1244 return True; 1245} 1246 1247/******************************************************************* 1248inits a SAM_ENTRY5 structure. 1249********************************************************************/ 1250 1251static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx, 1252 uint32 len_grp_name) 1253{ 1254 DEBUG(5, ("init_sam_entry5\n")); 1255 1256 sam->grp_idx = grp_idx; 1257 init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name, 1258 len_grp_name != 0); 1259} 1260 1261/******************************************************************* 1262reads or writes a SAM_ENTRY5 structure. 1263********************************************************************/ 1264 1265static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam, 1266 prs_struct *ps, int depth) 1267{ 1268 if (sam == NULL) 1269 return False; 1270 1271 prs_debug(ps, depth, desc, "sam_io_sam_entry5"); 1272 depth++; 1273 1274 if(!prs_align(ps)) 1275 return False; 1276 1277 if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx)) 1278 return False; 1279 if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth)) 1280 return False; 1281 1282 return True; 1283} 1284 1285/******************************************************************* 1286inits a SAM_ENTRY structure. 1287********************************************************************/ 1288 1289void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid) 1290{ 1291 DEBUG(10, ("init_sam_entry: %d\n", rid)); 1292 1293 sam->rid = rid; 1294 init_uni_hdr(&sam->hdr_name, uni2); 1295} 1296 1297/******************************************************************* 1298reads or writes a SAM_ENTRY structure. 1299********************************************************************/ 1300 1301static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam, 1302 prs_struct *ps, int depth) 1303{ 1304 if (sam == NULL) 1305 return False; 1306 1307 prs_debug(ps, depth, desc, "sam_io_sam_entry"); 1308 depth++; 1309 1310 if(!prs_align(ps)) 1311 return False; 1312 if(!prs_uint32("rid", ps, depth, &sam->rid)) 1313 return False; 1314 if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */ 1315 return False; 1316 1317 return True; 1318} 1319 1320/******************************************************************* 1321inits a SAMR_Q_ENUM_DOM_USERS structure. 1322********************************************************************/ 1323 1324void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol, 1325 uint32 start_idx, 1326 uint16 acb_mask, uint16 unk_1, uint32 size) 1327{ 1328 DEBUG(5, ("init_samr_q_enum_dom_users\n")); 1329 1330 q_e->pol = *pol; 1331 1332 q_e->start_idx = start_idx; /* zero indicates lots */ 1333 q_e->acb_mask = acb_mask; 1334 q_e->unknown_1 = unk_1; 1335 q_e->max_size = size; 1336} 1337 1338/******************************************************************* 1339reads or writes a structure. 1340********************************************************************/ 1341 1342BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e, 1343 prs_struct *ps, int depth) 1344{ 1345 if (q_e == NULL) 1346 return False; 1347 1348 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users"); 1349 depth++; 1350 1351 if(!prs_align(ps)) 1352 return False; 1353 1354 if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth)) 1355 return False; 1356 1357 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) 1358 return False; 1359 if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask)) 1360 return False; 1361 if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1)) 1362 return False; 1363 1364 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) 1365 return False; 1366 1367 return True; 1368} 1369 1370 1371/******************************************************************* 1372inits a SAMR_R_ENUM_DOM_USERS structure. 1373********************************************************************/ 1374 1375void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u, 1376 uint32 next_idx, uint32 num_sam_entries) 1377{ 1378 DEBUG(5, ("init_samr_r_enum_dom_users\n")); 1379 1380 r_u->next_idx = next_idx; 1381 1382 if (num_sam_entries != 0) { 1383 r_u->ptr_entries1 = 1; 1384 r_u->ptr_entries2 = 1; 1385 r_u->num_entries2 = num_sam_entries; 1386 r_u->num_entries3 = num_sam_entries; 1387 1388 r_u->num_entries4 = num_sam_entries; 1389 } else { 1390 r_u->ptr_entries1 = 0; 1391 r_u->num_entries2 = num_sam_entries; 1392 r_u->ptr_entries2 = 1; 1393 } 1394} 1395 1396/******************************************************************* 1397reads or writes a structure. 1398********************************************************************/ 1399 1400BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u, 1401 prs_struct *ps, int depth) 1402{ 1403 uint32 i; 1404 1405 if (r_u == NULL) 1406 return False; 1407 1408 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users"); 1409 depth++; 1410 1411 if(!prs_align(ps)) 1412 return False; 1413 1414 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) 1415 return False; 1416 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) 1417 return False; 1418 1419 if (r_u->ptr_entries1 != 0) { 1420 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) 1421 return False; 1422 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) 1423 return False; 1424 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) 1425 return False; 1426 1427 if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) { 1428 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY, r_u->num_entries2); 1429 r_u->uni_acct_name = PRS_ALLOC_MEM(ps,UNISTR2, r_u->num_entries2); 1430 } 1431 1432 if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) { 1433 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n")); 1434 r_u->num_entries4 = 0; 1435 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; 1436 return False; 1437 } 1438 1439 for (i = 0; i < r_u->num_entries2; i++) { 1440 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) 1441 return False; 1442 } 1443 1444 for (i = 0; i < r_u->num_entries2; i++) { 1445 if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth)) 1446 return False; 1447 } 1448 1449 } 1450 1451 if(!prs_align(ps)) 1452 return False; 1453 1454 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) 1455 return False; 1456 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 1457 return False; 1458 1459 return True; 1460} 1461 1462/******************************************************************* 1463inits a SAMR_Q_QUERY_DISPINFO structure. 1464********************************************************************/ 1465 1466void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol, 1467 uint16 switch_level, uint32 start_idx, 1468 uint32 max_entries, uint32 max_size) 1469{ 1470 DEBUG(5, ("init_samr_q_query_dispinfo\n")); 1471 1472 q_e->domain_pol = *pol; 1473 1474 q_e->switch_level = switch_level; 1475 1476 q_e->start_idx = start_idx; 1477 q_e->max_entries = max_entries; 1478 q_e->max_size = max_size; 1479} 1480 1481/******************************************************************* 1482reads or writes a structure. 1483********************************************************************/ 1484 1485BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e, 1486 prs_struct *ps, int depth) 1487{ 1488 if (q_e == NULL) 1489 return False; 1490 1491 prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo"); 1492 depth++; 1493 1494 if(!prs_align(ps)) 1495 return False; 1496 1497 if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth)) 1498 return False; 1499 1500 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) 1501 return False; 1502 if(!prs_align(ps)) 1503 return False; 1504 1505 if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx)) 1506 return False; 1507 if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries)) 1508 return False; 1509 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) 1510 return False; 1511 1512 return True; 1513} 1514 1515/******************************************************************* 1516inits a SAM_DISPINFO_1 structure. 1517********************************************************************/ 1518 1519NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries, 1520 uint32 start_idx, SAM_ACCOUNT *disp_user_info, 1521 DOM_SID *domain_sid) 1522{ 1523 uint32 i; 1524 1525 SAM_ACCOUNT *pwd = NULL; 1526 ZERO_STRUCTP(sam); 1527 1528 DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries)); 1529 1530 if (num_entries==0) 1531 return NT_STATUS_OK; 1532 1533 sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries); 1534 if (!sam->sam) 1535 return NT_STATUS_NO_MEMORY; 1536 1537 sam->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries); 1538 if (!sam->str) 1539 return NT_STATUS_NO_MEMORY; 1540 1541 ZERO_STRUCTP(sam->sam); 1542 ZERO_STRUCTP(sam->str); 1543 1544 for (i = 0; i < num_entries ; i++) { 1545 const char *username; 1546 const char *fullname; 1547 const char *acct_desc; 1548 uint32 user_rid; 1549 const DOM_SID *user_sid; 1550 fstring user_sid_string, domain_sid_string; 1551 1552 DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i)); 1553 1554 pwd=&disp_user_info[i+start_idx]; 1555 1556 username = pdb_get_username(pwd); 1557 fullname = pdb_get_fullname(pwd); 1558 acct_desc = pdb_get_acct_desc(pwd); 1559 1560 if (!username) 1561 username = ""; 1562 1563 if (!fullname) 1564 fullname = ""; 1565 1566 if (!acct_desc) 1567 acct_desc = ""; 1568 1569 user_sid = pdb_get_user_sid(pwd); 1570 1571 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { 1572 DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with " 1573 "the domain sid %s. Failing operation.\n", 1574 username, 1575 sid_to_string(user_sid_string, user_sid), 1576 sid_to_string(domain_sid_string, domain_sid))); 1577 return NT_STATUS_UNSUCCESSFUL; 1578 } 1579 1580 init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE); 1581 init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE); 1582 init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE); 1583 1584 init_sam_entry1(&sam->sam[i], start_idx + i + 1, 1585 &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc, 1586 user_rid, pdb_get_acct_ctrl(pwd)); 1587 1588 } 1589 1590 return NT_STATUS_OK; 1591} 1592 1593/******************************************************************* 1594reads or writes a structure. 1595********************************************************************/ 1596 1597static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam, 1598 uint32 num_entries, 1599 prs_struct *ps, int depth) 1600{ 1601 uint32 i; 1602 1603 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1"); 1604 depth++; 1605 1606 if(!prs_align(ps)) 1607 return False; 1608 1609 if (UNMARSHALLING(ps) && num_entries > 0) { 1610 1611 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) { 1612 DEBUG(0, ("out of memory allocating SAM_ENTRY1\n")); 1613 return False; 1614 } 1615 1616 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) { 1617 DEBUG(0, ("out of memory allocating SAM_STR1\n")); 1618 return False; 1619 } 1620 } 1621 1622 for (i = 0; i < num_entries; i++) { 1623 if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth)) 1624 return False; 1625 } 1626 1627 for (i = 0; i < num_entries; i++) { 1628 if(!sam_io_sam_str1("", &sam->str[i], 1629 sam->sam[i].hdr_acct_name.buffer, 1630 sam->sam[i].hdr_user_name.buffer, 1631 sam->sam[i].hdr_user_desc.buffer, ps, depth)) 1632 return False; 1633 } 1634 1635 return True; 1636} 1637 1638/******************************************************************* 1639inits a SAM_DISPINFO_2 structure. 1640********************************************************************/ 1641 1642NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries, 1643 uint32 start_idx, SAM_ACCOUNT *disp_user_info, 1644 DOM_SID *domain_sid ) 1645{ 1646 uint32 i; 1647 1648 SAM_ACCOUNT *pwd = NULL; 1649 ZERO_STRUCTP(sam); 1650 1651 DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries)); 1652 1653 if (num_entries==0) 1654 return NT_STATUS_OK; 1655 1656 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries))) 1657 return NT_STATUS_NO_MEMORY; 1658 1659 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries))) 1660 return NT_STATUS_NO_MEMORY; 1661 1662 ZERO_STRUCTP(sam->sam); 1663 ZERO_STRUCTP(sam->str); 1664 1665 for (i = 0; i < num_entries; i++) { 1666 uint32 user_rid; 1667 const DOM_SID *user_sid; 1668 const char *username; 1669 const char *acct_desc; 1670 fstring user_sid_string, domain_sid_string; 1671 1672 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); 1673 pwd=&disp_user_info[i+start_idx]; 1674 1675 username = pdb_get_username(pwd); 1676 acct_desc = pdb_get_acct_desc(pwd); 1677 user_sid = pdb_get_user_sid(pwd); 1678 1679 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { 1680 DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with " 1681 "the domain sid %s. Failing operation.\n", 1682 username, 1683 sid_to_string(user_sid_string, user_sid), 1684 sid_to_string(domain_sid_string, domain_sid))); 1685 return NT_STATUS_UNSUCCESSFUL; 1686 } 1687 1688 init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE); 1689 init_unistr2(&sam->str[i].uni_srv_desc, acct_desc, UNI_FLAGS_NONE); 1690 1691 init_sam_entry2(&sam->sam[i], start_idx + i + 1, 1692 &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc, 1693 user_rid, pdb_get_acct_ctrl(pwd)); 1694 } 1695 1696 return NT_STATUS_OK; 1697} 1698 1699/******************************************************************* 1700reads or writes a structure. 1701********************************************************************/ 1702 1703static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam, 1704 uint32 num_entries, 1705 prs_struct *ps, int depth) 1706{ 1707 uint32 i; 1708 1709 if (sam == NULL) 1710 return False; 1711 1712 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2"); 1713 depth++; 1714 1715 if(!prs_align(ps)) 1716 return False; 1717 1718 if (UNMARSHALLING(ps) && num_entries > 0) { 1719 1720 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) { 1721 DEBUG(0, ("out of memory allocating SAM_ENTRY2\n")); 1722 return False; 1723 } 1724 1725 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) { 1726 DEBUG(0, ("out of memory allocating SAM_STR2\n")); 1727 return False; 1728 } 1729 } 1730 1731 for (i = 0; i < num_entries; i++) { 1732 if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth)) 1733 return False; 1734 } 1735 1736 for (i = 0; i < num_entries; i++) { 1737 if(!sam_io_sam_str2("", &sam->str[i], 1738 sam->sam[i].hdr_srv_name.buffer, 1739 sam->sam[i].hdr_srv_desc.buffer, ps, depth)) 1740 return False; 1741 } 1742 1743 return True; 1744} 1745 1746/******************************************************************* 1747inits a SAM_DISPINFO_3 structure. 1748********************************************************************/ 1749 1750NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries, 1751 uint32 start_idx, DOMAIN_GRP *disp_group_info) 1752{ 1753 uint32 i; 1754 1755 ZERO_STRUCTP(sam); 1756 1757 DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries)); 1758 1759 if (num_entries==0) 1760 return NT_STATUS_OK; 1761 1762 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries))) 1763 return NT_STATUS_NO_MEMORY; 1764 1765 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries))) 1766 return NT_STATUS_NO_MEMORY; 1767 1768 ZERO_STRUCTP(sam->sam); 1769 ZERO_STRUCTP(sam->str); 1770 1771 for (i = 0; i < num_entries; i++) { 1772 DOMAIN_GRP *grp = &disp_group_info[i+start_idx]; 1773 1774 DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i)); 1775 1776 init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE); 1777 init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE); 1778 1779 init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name, 1780 &sam->str[i].uni_grp_desc, grp->rid); 1781 } 1782 1783 return NT_STATUS_OK; 1784} 1785 1786/******************************************************************* 1787reads or writes a structure. 1788********************************************************************/ 1789 1790static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam, 1791 uint32 num_entries, 1792 prs_struct *ps, int depth) 1793{ 1794 uint32 i; 1795 1796 if (sam == NULL) 1797 return False; 1798 1799 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3"); 1800 depth++; 1801 1802 if(!prs_align(ps)) 1803 return False; 1804 1805 if (UNMARSHALLING(ps) && num_entries > 0) { 1806 1807 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) { 1808 DEBUG(0, ("out of memory allocating SAM_ENTRY3\n")); 1809 return False; 1810 } 1811 1812 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) { 1813 DEBUG(0, ("out of memory allocating SAM_STR3\n")); 1814 return False; 1815 } 1816 } 1817 1818 for (i = 0; i < num_entries; i++) { 1819 if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth)) 1820 return False; 1821 } 1822 1823 for (i = 0; i < num_entries; i++) { 1824 if(!sam_io_sam_str3("", &sam->str[i], 1825 sam->sam[i].hdr_grp_name.buffer, 1826 sam->sam[i].hdr_grp_desc.buffer, ps, depth)) 1827 return False; 1828 } 1829 1830 return True; 1831} 1832 1833/******************************************************************* 1834inits a SAM_DISPINFO_4 structure. 1835********************************************************************/ 1836 1837NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries, 1838 uint32 start_idx, SAM_ACCOUNT *disp_user_info) 1839{ 1840 uint32 len_sam_name; 1841 uint32 i; 1842 1843 SAM_ACCOUNT *pwd = NULL; 1844 ZERO_STRUCTP(sam); 1845 1846 DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries)); 1847 1848 if (num_entries==0) 1849 return NT_STATUS_OK; 1850 1851 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries))) 1852 return NT_STATUS_NO_MEMORY; 1853 1854 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries))) 1855 return NT_STATUS_NO_MEMORY; 1856 1857 ZERO_STRUCTP(sam->sam); 1858 ZERO_STRUCTP(sam->str); 1859 1860 for (i = 0; i < num_entries; i++) { 1861 DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); 1862 pwd=&disp_user_info[i+start_idx]; 1863 1864 len_sam_name = strlen(pdb_get_username(pwd)); 1865 1866 init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name); 1867 1868 init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name); 1869 } 1870 1871 return NT_STATUS_OK; 1872} 1873 1874/******************************************************************* 1875reads or writes a structure. 1876********************************************************************/ 1877 1878static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam, 1879 uint32 num_entries, 1880 prs_struct *ps, int depth) 1881{ 1882 uint32 i; 1883 1884 if (sam == NULL) 1885 return False; 1886 1887 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4"); 1888 depth++; 1889 1890 if(!prs_align(ps)) 1891 return False; 1892 1893 if (UNMARSHALLING(ps) && num_entries > 0) { 1894 1895 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) { 1896 DEBUG(0, ("out of memory allocating SAM_ENTRY4\n")); 1897 return False; 1898 } 1899 1900 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) { 1901 DEBUG(0, ("out of memory allocating SAM_STR4\n")); 1902 return False; 1903 } 1904 } 1905 1906 for (i = 0; i < num_entries; i++) { 1907 if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth)) 1908 return False; 1909 } 1910 1911 for (i = 0; i < num_entries; i++) { 1912 if(!smb_io_string2("acct_name", &sam->str[i].acct_name, 1913 sam->sam[i].hdr_acct_name.buffer, ps, depth)) 1914 return False; 1915 } 1916 1917 return True; 1918} 1919 1920/******************************************************************* 1921inits a SAM_DISPINFO_5 structure. 1922********************************************************************/ 1923 1924NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries, 1925 uint32 start_idx, DOMAIN_GRP *disp_group_info) 1926{ 1927 uint32 len_sam_name; 1928 uint32 i; 1929 1930 ZERO_STRUCTP(sam); 1931 1932 DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries)); 1933 1934 if (num_entries==0) 1935 return NT_STATUS_OK; 1936 1937 if (!(sam->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries))) 1938 return NT_STATUS_NO_MEMORY; 1939 1940 if (!(sam->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries))) 1941 return NT_STATUS_NO_MEMORY; 1942 1943 ZERO_STRUCTP(sam->sam); 1944 ZERO_STRUCTP(sam->str); 1945 1946 for (i = 0; i < num_entries; i++) { 1947 DOMAIN_GRP *grp = &disp_group_info[i+start_idx]; 1948 1949 DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i)); 1950 1951 len_sam_name = strlen(grp->name); 1952 1953 init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name); 1954 init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name); 1955 } 1956 1957 return NT_STATUS_OK; 1958} 1959 1960/******************************************************************* 1961reads or writes a structure. 1962********************************************************************/ 1963 1964static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam, 1965 uint32 num_entries, 1966 prs_struct *ps, int depth) 1967{ 1968 uint32 i; 1969 1970 if (sam == NULL) 1971 return False; 1972 1973 prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5"); 1974 depth++; 1975 1976 if(!prs_align(ps)) 1977 return False; 1978 1979 if (UNMARSHALLING(ps) && num_entries > 0) { 1980 1981 if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) { 1982 DEBUG(0, ("out of memory allocating SAM_ENTRY5\n")); 1983 return False; 1984 } 1985 1986 if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) { 1987 DEBUG(0, ("out of memory allocating SAM_STR5\n")); 1988 return False; 1989 } 1990 } 1991 1992 for (i = 0; i < num_entries; i++) { 1993 if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth)) 1994 return False; 1995 } 1996 1997 for (i = 0; i < num_entries; i++) { 1998 if(!smb_io_string2("grp_name", &sam->str[i].grp_name, 1999 sam->sam[i].hdr_grp_name.buffer, ps, depth)) 2000 return False; 2001 } 2002 2003 return True; 2004} 2005 2006/******************************************************************* 2007inits a SAMR_R_QUERY_DISPINFO structure. 2008********************************************************************/ 2009 2010void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u, 2011 uint32 num_entries, uint32 total_size, uint32 data_size, 2012 uint16 switch_level, SAM_DISPINFO_CTR * ctr, 2013 NTSTATUS status) 2014{ 2015 DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level)); 2016 2017 r_u->total_size = total_size; 2018 2019 r_u->data_size = data_size; 2020 2021 r_u->switch_level = switch_level; 2022 r_u->num_entries = num_entries; 2023 2024 if (num_entries==0) 2025 r_u->ptr_entries = 0; 2026 else 2027 r_u->ptr_entries = 1; 2028 2029 r_u->num_entries2 = num_entries; 2030 r_u->ctr = ctr; 2031 2032 r_u->status = status; 2033} 2034 2035/******************************************************************* 2036reads or writes a structure. 2037********************************************************************/ 2038 2039BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u, 2040 prs_struct *ps, int depth) 2041{ 2042 if (r_u == NULL) 2043 return False; 2044 2045 prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo"); 2046 depth++; 2047 2048 if(!prs_align(ps)) 2049 return False; 2050 2051 if(!prs_uint32("total_size ", ps, depth, &r_u->total_size)) 2052 return False; 2053 if(!prs_uint32("data_size ", ps, depth, &r_u->data_size)) 2054 return False; 2055 if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level)) 2056 return False; 2057 if(!prs_align(ps)) 2058 return False; 2059 2060 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) 2061 return False; 2062 if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries)) 2063 return False; 2064 2065 if (r_u->ptr_entries==0) { 2066 if(!prs_align(ps)) 2067 return False; 2068 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2069 return False; 2070 2071 return True; 2072 } 2073 2074 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) 2075 return False; 2076 2077 switch (r_u->switch_level) { 2078 case 0x1: 2079 if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1, 2080 r_u->num_entries, ps, depth)) 2081 return False; 2082 break; 2083 case 0x2: 2084 if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2, 2085 r_u->num_entries, ps, depth)) 2086 return False; 2087 break; 2088 case 0x3: 2089 if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3, 2090 r_u->num_entries, ps, depth)) 2091 return False; 2092 break; 2093 case 0x4: 2094 if(!sam_io_sam_dispinfo_4("user list", 2095 r_u->ctr->sam.info4, 2096 r_u->num_entries, ps, depth)) 2097 return False; 2098 break; 2099 case 0x5: 2100 if(!sam_io_sam_dispinfo_5("group list", 2101 r_u->ctr->sam.info5, 2102 r_u->num_entries, ps, depth)) 2103 return False; 2104 break; 2105 default: 2106 DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n")); 2107 break; 2108 } 2109 2110 if(!prs_align(ps)) 2111 return False; 2112 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2113 return False; 2114 2115 return True; 2116} 2117 2118/******************************************************************* 2119inits a SAMR_Q_OPEN_GROUP structure. 2120********************************************************************/ 2121 2122void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c, 2123 POLICY_HND *hnd, 2124 uint32 access_mask, uint32 rid) 2125{ 2126 DEBUG(5, ("init_samr_q_open_group\n")); 2127 2128 q_c->domain_pol = *hnd; 2129 q_c->access_mask = access_mask; 2130 q_c->rid_group = rid; 2131} 2132 2133/******************************************************************* 2134reads or writes a structure. 2135********************************************************************/ 2136 2137BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u, 2138 prs_struct *ps, int depth) 2139{ 2140 if (q_u == NULL) 2141 return False; 2142 2143 prs_debug(ps, depth, desc, "samr_io_q_open_group"); 2144 depth++; 2145 2146 if(!prs_align(ps)) 2147 return False; 2148 2149 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 2150 return False; 2151 2152 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 2153 return False; 2154 if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group)) 2155 return False; 2156 2157 return True; 2158} 2159 2160/******************************************************************* 2161reads or writes a structure. 2162********************************************************************/ 2163 2164BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u, 2165 prs_struct *ps, int depth) 2166{ 2167 if (r_u == NULL) 2168 return False; 2169 2170 prs_debug(ps, depth, desc, "samr_io_r_open_group"); 2171 depth++; 2172 2173 if(!prs_align(ps)) 2174 return False; 2175 2176 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 2177 return False; 2178 2179 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2180 return False; 2181 2182 return True; 2183} 2184 2185/******************************************************************* 2186inits a GROUP_INFO1 structure. 2187********************************************************************/ 2188 2189void init_samr_group_info1(GROUP_INFO1 * gr1, 2190 char *acct_name, char *acct_desc, 2191 uint32 num_members) 2192{ 2193 DEBUG(5, ("init_samr_group_info1\n")); 2194 2195 gr1->unknown_1 = 0x3; 2196 gr1->num_members = num_members; 2197 2198 init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE); 2199 init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name); 2200 init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 2201 init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc); 2202} 2203 2204/******************************************************************* 2205reads or writes a structure. 2206********************************************************************/ 2207 2208BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1, 2209 prs_struct *ps, int depth) 2210{ 2211 uint16 dummy = 1; 2212 2213 if (gr1 == NULL) 2214 return False; 2215 2216 prs_debug(ps, depth, desc, "samr_io_group_info1"); 2217 depth++; 2218 2219 if(!prs_uint16("level", ps, depth, &dummy)) 2220 return False; 2221 2222 if(!prs_align(ps)) 2223 return False; 2224 2225 if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth)) 2226 return False; 2227 2228 if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1)) 2229 return False; 2230 if(!prs_uint32("num_members", ps, depth, &gr1->num_members)) 2231 return False; 2232 2233 if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth)) 2234 return False; 2235 2236 if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name, 2237 gr1->hdr_acct_name.buffer, ps, depth)) 2238 return False; 2239 2240 if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc, 2241 gr1->hdr_acct_desc.buffer, ps, depth)) 2242 return False; 2243 2244 return True; 2245} 2246 2247/******************************************************************* 2248inits a GROUP_INFO2 structure. 2249********************************************************************/ 2250 2251void init_samr_group_info2(GROUP_INFO2 * gr2, const char *acct_name) 2252{ 2253 DEBUG(5, ("init_samr_group_info2\n")); 2254 2255 gr2->level = 2; 2256 init_unistr2(&gr2->uni_acct_name, acct_name, UNI_FLAGS_NONE); 2257 init_uni_hdr(&gr2->hdr_acct_name, &gr2->uni_acct_name); 2258} 2259 2260/******************************************************************* 2261reads or writes a structure. 2262********************************************************************/ 2263 2264BOOL samr_io_group_info2(const char *desc, GROUP_INFO2 *gr2, prs_struct *ps, int depth) 2265{ 2266 if (gr2 == NULL) 2267 return False; 2268 2269 prs_debug(ps, depth, desc, "samr_io_group_info2"); 2270 depth++; 2271 2272 if(!prs_uint16("hdr_level", ps, depth, &gr2->level)) 2273 return False; 2274 2275 if(!smb_io_unihdr("hdr_acct_name", &gr2->hdr_acct_name, ps, depth)) 2276 return False; 2277 if(!smb_io_unistr2("uni_acct_name", &gr2->uni_acct_name, 2278 gr2->hdr_acct_name.buffer, ps, depth)) 2279 return False; 2280 2281 return True; 2282} 2283 2284/******************************************************************* 2285inits a GROUP_INFO3 structure. 2286********************************************************************/ 2287 2288void init_samr_group_info3(GROUP_INFO3 *gr3) 2289{ 2290 DEBUG(5, ("init_samr_group_info3\n")); 2291 2292 gr3->unknown_1 = 0x3; 2293} 2294 2295/******************************************************************* 2296reads or writes a structure. 2297********************************************************************/ 2298 2299BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth) 2300{ 2301 if (gr3 == NULL) 2302 return False; 2303 2304 prs_debug(ps, depth, desc, "samr_io_group_info3"); 2305 depth++; 2306 2307 if(!prs_align(ps)) 2308 return False; 2309 2310 if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1)) 2311 return False; 2312 2313 return True; 2314} 2315 2316/******************************************************************* 2317inits a GROUP_INFO4 structure. 2318********************************************************************/ 2319 2320void init_samr_group_info4(GROUP_INFO4 * gr4, const char *acct_desc) 2321{ 2322 DEBUG(5, ("init_samr_group_info4\n")); 2323 2324 gr4->level = 4; 2325 init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 2326 init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc); 2327} 2328 2329/******************************************************************* 2330reads or writes a structure. 2331********************************************************************/ 2332 2333BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4, 2334 prs_struct *ps, int depth) 2335{ 2336 if (gr4 == NULL) 2337 return False; 2338 2339 prs_debug(ps, depth, desc, "samr_io_group_info4"); 2340 depth++; 2341 2342 if(!prs_uint16("hdr_level", ps, depth, &gr4->level)) 2343 return False; 2344 if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth)) 2345 return False; 2346 if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc, 2347 gr4->hdr_acct_desc.buffer, ps, depth)) 2348 return False; 2349 2350 return True; 2351} 2352 2353/******************************************************************* 2354reads or writes a structure. 2355********************************************************************/ 2356 2357static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr, 2358 prs_struct *ps, int depth) 2359{ 2360 if (UNMARSHALLING(ps)) 2361 *ctr = PRS_ALLOC_MEM(ps,GROUP_INFO_CTR,1); 2362 2363 if (*ctr == NULL) 2364 return False; 2365 2366 prs_debug(ps, depth, desc, "samr_group_info_ctr"); 2367 depth++; 2368 2369 if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1)) 2370 return False; 2371 2372 switch ((*ctr)->switch_value1) { 2373 case 1: 2374 if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth)) 2375 return False; 2376 break; 2377 case 2: 2378 if(!samr_io_group_info2("group_info2", &(*ctr)->group.info2, ps, depth)) 2379 return False; 2380 break; 2381 case 3: 2382 if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth)) 2383 return False; 2384 break; 2385 case 4: 2386 if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth)) 2387 return False; 2388 break; 2389 default: 2390 DEBUG(0,("samr_group_info_ctr: unsupported switch level\n")); 2391 break; 2392 } 2393 2394 return True; 2395} 2396 2397/******************************************************************* 2398inits a SAMR_Q_CREATE_DOM_GROUP structure. 2399********************************************************************/ 2400 2401void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e, 2402 POLICY_HND *pol, const char *acct_desc, 2403 uint32 access_mask) 2404{ 2405 DEBUG(5, ("init_samr_q_create_dom_group\n")); 2406 2407 q_e->pol = *pol; 2408 2409 init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 2410 init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc); 2411 2412 q_e->access_mask = access_mask; 2413} 2414 2415/******************************************************************* 2416reads or writes a structure. 2417********************************************************************/ 2418 2419BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e, 2420 prs_struct *ps, int depth) 2421{ 2422 if (q_e == NULL) 2423 return False; 2424 2425 prs_debug(ps, depth, desc, "samr_io_q_create_dom_group"); 2426 depth++; 2427 2428 if(!prs_align(ps)) 2429 return False; 2430 2431 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 2432 return False; 2433 2434 if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth)) 2435 return False; 2436 if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc, 2437 q_e->hdr_acct_desc.buffer, ps, depth)) 2438 return False; 2439 2440 if(!prs_align(ps)) 2441 return False; 2442 if(!prs_uint32("access", ps, depth, &q_e->access_mask)) 2443 return False; 2444 2445 return True; 2446} 2447 2448/******************************************************************* 2449reads or writes a structure. 2450********************************************************************/ 2451 2452BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u, 2453 prs_struct *ps, int depth) 2454{ 2455 if (r_u == NULL) 2456 return False; 2457 2458 prs_debug(ps, depth, desc, "samr_io_r_create_dom_group"); 2459 depth++; 2460 2461 if(!prs_align(ps)) 2462 return False; 2463 2464 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 2465 return False; 2466 2467 if(!prs_uint32("rid ", ps, depth, &r_u->rid)) 2468 return False; 2469 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2470 return False; 2471 2472 return True; 2473} 2474 2475/******************************************************************* 2476inits a SAMR_Q_DELETE_DOM_GROUP structure. 2477********************************************************************/ 2478 2479void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c, 2480 POLICY_HND *hnd) 2481{ 2482 DEBUG(5, ("init_samr_q_delete_dom_group\n")); 2483 2484 q_c->group_pol = *hnd; 2485} 2486 2487/******************************************************************* 2488reads or writes a structure. 2489********************************************************************/ 2490 2491BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u, 2492 prs_struct *ps, int depth) 2493{ 2494 if (q_u == NULL) 2495 return False; 2496 2497 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group"); 2498 depth++; 2499 2500 if(!prs_align(ps)) 2501 return False; 2502 2503 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth)) 2504 return False; 2505 2506 return True; 2507} 2508 2509/******************************************************************* 2510reads or writes a structure. 2511********************************************************************/ 2512 2513BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u, 2514 prs_struct *ps, int depth) 2515{ 2516 if (r_u == NULL) 2517 return False; 2518 2519 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group"); 2520 depth++; 2521 2522 if(!prs_align(ps)) 2523 return False; 2524 2525 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 2526 return False; 2527 2528 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2529 return False; 2530 2531 return True; 2532} 2533 2534/******************************************************************* 2535inits a SAMR_Q_DEL_GROUPMEM structure. 2536********************************************************************/ 2537 2538void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e, 2539 POLICY_HND *pol, uint32 rid) 2540{ 2541 DEBUG(5, ("init_samr_q_del_groupmem\n")); 2542 2543 q_e->pol = *pol; 2544 q_e->rid = rid; 2545} 2546 2547/******************************************************************* 2548reads or writes a structure. 2549********************************************************************/ 2550 2551BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e, 2552 prs_struct *ps, int depth) 2553{ 2554 if (q_e == NULL) 2555 return False; 2556 2557 prs_debug(ps, depth, desc, "samr_io_q_del_groupmem"); 2558 depth++; 2559 2560 if(!prs_align(ps)) 2561 return False; 2562 2563 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 2564 return False; 2565 2566 if(!prs_uint32("rid", ps, depth, &q_e->rid)) 2567 return False; 2568 2569 return True; 2570} 2571 2572/******************************************************************* 2573inits a SAMR_R_DEL_GROUPMEM structure. 2574********************************************************************/ 2575 2576void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol, 2577 NTSTATUS status) 2578{ 2579 DEBUG(5, ("init_samr_r_del_groupmem\n")); 2580 2581 r_u->status = status; 2582} 2583 2584/******************************************************************* 2585reads or writes a structure. 2586********************************************************************/ 2587 2588BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u, 2589 prs_struct *ps, int depth) 2590{ 2591 if (r_u == NULL) 2592 return False; 2593 2594 prs_debug(ps, depth, desc, "samr_io_r_del_groupmem"); 2595 depth++; 2596 2597 if(!prs_align(ps)) 2598 return False; 2599 2600 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2601 return False; 2602 2603 return True; 2604} 2605 2606/******************************************************************* 2607inits a SAMR_Q_ADD_GROUPMEM structure. 2608********************************************************************/ 2609 2610void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e, 2611 POLICY_HND *pol, uint32 rid) 2612{ 2613 DEBUG(5, ("init_samr_q_add_groupmem\n")); 2614 2615 q_e->pol = *pol; 2616 q_e->rid = rid; 2617 q_e->unknown = 0x0005; 2618} 2619 2620/******************************************************************* 2621reads or writes a structure. 2622********************************************************************/ 2623 2624BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e, 2625 prs_struct *ps, int depth) 2626{ 2627 if (q_e == NULL) 2628 return False; 2629 2630 prs_debug(ps, depth, desc, "samr_io_q_add_groupmem"); 2631 depth++; 2632 2633 if(!prs_align(ps)) 2634 return False; 2635 2636 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 2637 return False; 2638 2639 if(!prs_uint32("rid ", ps, depth, &q_e->rid)) 2640 return False; 2641 if(!prs_uint32("unknown", ps, depth, &q_e->unknown)) 2642 return False; 2643 2644 return True; 2645} 2646 2647/******************************************************************* 2648inits a SAMR_R_ADD_GROUPMEM structure. 2649********************************************************************/ 2650 2651void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol, 2652 NTSTATUS status) 2653{ 2654 DEBUG(5, ("init_samr_r_add_groupmem\n")); 2655 2656 r_u->status = status; 2657} 2658 2659/******************************************************************* 2660reads or writes a structure. 2661********************************************************************/ 2662 2663BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u, 2664 prs_struct *ps, int depth) 2665{ 2666 if (r_u == NULL) 2667 return False; 2668 2669 prs_debug(ps, depth, desc, "samr_io_r_add_groupmem"); 2670 depth++; 2671 2672 if(!prs_align(ps)) 2673 return False; 2674 2675 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2676 return False; 2677 2678 return True; 2679} 2680 2681/******************************************************************* 2682inits a SAMR_Q_SET_GROUPINFO structure. 2683********************************************************************/ 2684 2685void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e, 2686 POLICY_HND *pol, GROUP_INFO_CTR * ctr) 2687{ 2688 DEBUG(5, ("init_samr_q_set_groupinfo\n")); 2689 2690 q_e->pol = *pol; 2691 q_e->ctr = ctr; 2692} 2693 2694/******************************************************************* 2695reads or writes a structure. 2696********************************************************************/ 2697 2698BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e, 2699 prs_struct *ps, int depth) 2700{ 2701 if (q_e == NULL) 2702 return False; 2703 2704 prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo"); 2705 depth++; 2706 2707 if(!prs_align(ps)) 2708 return False; 2709 2710 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 2711 return False; 2712 2713 if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth)) 2714 return False; 2715 2716 return True; 2717} 2718 2719/******************************************************************* 2720inits a SAMR_R_SET_GROUPINFO structure. 2721********************************************************************/ 2722 2723void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status) 2724{ 2725 DEBUG(5, ("init_samr_r_set_groupinfo\n")); 2726 2727 r_u->status = status; 2728} 2729 2730/******************************************************************* 2731reads or writes a structure. 2732********************************************************************/ 2733 2734BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u, 2735 prs_struct *ps, int depth) 2736{ 2737 if (r_u == NULL) 2738 return False; 2739 2740 prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo"); 2741 depth++; 2742 2743 if(!prs_align(ps)) 2744 return False; 2745 2746 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2747 return False; 2748 2749 return True; 2750} 2751 2752/******************************************************************* 2753inits a SAMR_Q_QUERY_GROUPINFO structure. 2754********************************************************************/ 2755 2756void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e, 2757 POLICY_HND *pol, uint16 switch_level) 2758{ 2759 DEBUG(5, ("init_samr_q_query_groupinfo\n")); 2760 2761 q_e->pol = *pol; 2762 2763 q_e->switch_level = switch_level; 2764} 2765 2766/******************************************************************* 2767reads or writes a structure. 2768********************************************************************/ 2769 2770BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e, 2771 prs_struct *ps, int depth) 2772{ 2773 if (q_e == NULL) 2774 return False; 2775 2776 prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo"); 2777 depth++; 2778 2779 if(!prs_align(ps)) 2780 return False; 2781 2782 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 2783 return False; 2784 2785 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) 2786 return False; 2787 2788 return True; 2789} 2790 2791/******************************************************************* 2792inits a SAMR_R_QUERY_GROUPINFO structure. 2793********************************************************************/ 2794 2795void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u, 2796 GROUP_INFO_CTR * ctr, NTSTATUS status) 2797{ 2798 DEBUG(5, ("init_samr_r_query_groupinfo\n")); 2799 2800 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0; 2801 r_u->ctr = ctr; 2802 r_u->status = status; 2803} 2804 2805/******************************************************************* 2806reads or writes a structure. 2807********************************************************************/ 2808 2809BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u, 2810 prs_struct *ps, int depth) 2811{ 2812 if (r_u == NULL) 2813 return False; 2814 2815 prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo"); 2816 depth++; 2817 2818 if(!prs_align(ps)) 2819 return False; 2820 2821 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 2822 return False; 2823 2824 if (r_u->ptr != 0) { 2825 if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth)) 2826 return False; 2827 } 2828 2829 if(!prs_align(ps)) 2830 return False; 2831 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2832 return False; 2833 2834 return True; 2835} 2836 2837/******************************************************************* 2838inits a SAMR_Q_QUERY_GROUPMEM structure. 2839********************************************************************/ 2840 2841void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd) 2842{ 2843 DEBUG(5, ("init_samr_q_query_groupmem\n")); 2844 2845 q_c->group_pol = *hnd; 2846} 2847 2848/******************************************************************* 2849reads or writes a structure. 2850********************************************************************/ 2851 2852BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u, 2853 prs_struct *ps, int depth) 2854{ 2855 if (q_u == NULL) 2856 return False; 2857 2858 prs_debug(ps, depth, desc, "samr_io_q_query_groupmem"); 2859 depth++; 2860 2861 if(!prs_align(ps)) 2862 return False; 2863 2864 if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth)) 2865 return False; 2866 2867 return True; 2868} 2869 2870/******************************************************************* 2871inits a SAMR_R_QUERY_GROUPMEM structure. 2872********************************************************************/ 2873 2874void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u, 2875 uint32 num_entries, uint32 *rid, 2876 uint32 *attr, NTSTATUS status) 2877{ 2878 DEBUG(5, ("init_samr_r_query_groupmem\n")); 2879 2880 if (NT_STATUS_IS_OK(status)) { 2881 r_u->ptr = 1; 2882 r_u->num_entries = num_entries; 2883 2884 r_u->ptr_attrs = attr != NULL ? 1 : 0; 2885 r_u->ptr_rids = rid != NULL ? 1 : 0; 2886 2887 r_u->num_rids = num_entries; 2888 r_u->rid = rid; 2889 2890 r_u->num_attrs = num_entries; 2891 r_u->attr = attr; 2892 } else { 2893 r_u->ptr = 0; 2894 r_u->num_entries = 0; 2895 } 2896 2897 r_u->status = status; 2898} 2899 2900/******************************************************************* 2901reads or writes a structure. 2902********************************************************************/ 2903 2904BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u, 2905 prs_struct *ps, int depth) 2906{ 2907 uint32 i; 2908 2909 if (r_u == NULL) 2910 return False; 2911 2912 if (UNMARSHALLING(ps)) 2913 ZERO_STRUCTP(r_u); 2914 2915 prs_debug(ps, depth, desc, "samr_io_r_query_groupmem"); 2916 depth++; 2917 2918 if(!prs_align(ps)) 2919 return False; 2920 2921 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 2922 return False; 2923 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) 2924 return False; 2925 2926 if (r_u->ptr != 0) { 2927 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids)) 2928 return False; 2929 if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs)) 2930 return False; 2931 2932 if (r_u->ptr_rids != 0) { 2933 if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids)) 2934 return False; 2935 if (UNMARSHALLING(ps) && r_u->num_rids != 0) { 2936 r_u->rid = PRS_ALLOC_MEM(ps,uint32,r_u->num_rids); 2937 if (r_u->rid == NULL) 2938 return False; 2939 } 2940 2941 for (i = 0; i < r_u->num_rids; i++) { 2942 if(!prs_uint32("", ps, depth, &r_u->rid[i])) 2943 return False; 2944 } 2945 } 2946 2947 if (r_u->ptr_attrs != 0) { 2948 if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs)) 2949 return False; 2950 2951 if (UNMARSHALLING(ps) && r_u->num_attrs != 0) { 2952 r_u->attr = PRS_ALLOC_MEM(ps,uint32,r_u->num_attrs); 2953 if (r_u->attr == NULL) 2954 return False; 2955 } 2956 2957 for (i = 0; i < r_u->num_attrs; i++) { 2958 if(!prs_uint32("", ps, depth, &r_u->attr[i])) 2959 return False; 2960 } 2961 } 2962 } 2963 2964 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 2965 return False; 2966 2967 return True; 2968} 2969 2970/******************************************************************* 2971inits a SAMR_Q_QUERY_USERGROUPS structure. 2972********************************************************************/ 2973 2974void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u, 2975 POLICY_HND *hnd) 2976{ 2977 DEBUG(5, ("init_samr_q_query_usergroups\n")); 2978 2979 q_u->pol = *hnd; 2980} 2981 2982/******************************************************************* 2983reads or writes a structure. 2984********************************************************************/ 2985 2986BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u, 2987 prs_struct *ps, int depth) 2988{ 2989 if (q_u == NULL) 2990 return False; 2991 2992 prs_debug(ps, depth, desc, "samr_io_q_query_usergroups"); 2993 depth++; 2994 2995 if(!prs_align(ps)) 2996 return False; 2997 2998 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 2999 return False; 3000 3001 return True; 3002} 3003 3004/******************************************************************* 3005inits a SAMR_R_QUERY_USERGROUPS structure. 3006********************************************************************/ 3007 3008void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u, 3009 uint32 num_gids, DOM_GID * gid, 3010 NTSTATUS status) 3011{ 3012 DEBUG(5, ("init_samr_r_query_usergroups\n")); 3013 3014 if (NT_STATUS_IS_OK(status)) { 3015 r_u->ptr_0 = 1; 3016 r_u->num_entries = num_gids; 3017 r_u->ptr_1 = (num_gids != 0) ? 1 : 0; 3018 r_u->num_entries2 = num_gids; 3019 3020 r_u->gid = gid; 3021 } else { 3022 r_u->ptr_0 = 0; 3023 r_u->num_entries = 0; 3024 r_u->ptr_1 = 0; 3025 r_u->gid = NULL; 3026 } 3027 3028 r_u->status = status; 3029} 3030 3031/******************************************************************* 3032reads or writes a structure. 3033********************************************************************/ 3034 3035BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid, 3036 prs_struct *ps, int depth) 3037{ 3038 uint32 i; 3039 if (gid == NULL) 3040 return False; 3041 3042 prs_debug(ps, depth, desc, "samr_io_gids"); 3043 depth++; 3044 3045 if(!prs_align(ps)) 3046 return False; 3047 3048 if(!prs_uint32("num_gids", ps, depth, num_gids)) 3049 return False; 3050 3051 if ((*num_gids) != 0) { 3052 if (UNMARSHALLING(ps)) { 3053 (*gid) = PRS_ALLOC_MEM(ps,DOM_GID,*num_gids); 3054 } 3055 3056 if ((*gid) == NULL) { 3057 return False; 3058 } 3059 3060 for (i = 0; i < (*num_gids); i++) { 3061 if(!smb_io_gid("gids", &(*gid)[i], ps, depth)) 3062 return False; 3063 } 3064 } 3065 3066 return True; 3067} 3068 3069/******************************************************************* 3070reads or writes a structure. 3071********************************************************************/ 3072 3073BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u, 3074 prs_struct *ps, int depth) 3075{ 3076 if (r_u == NULL) 3077 return False; 3078 3079 prs_debug(ps, depth, desc, "samr_io_r_query_usergroups"); 3080 depth++; 3081 3082 if(!prs_align(ps)) 3083 return False; 3084 3085 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) 3086 return False; 3087 3088 if (r_u->ptr_0 != 0) { 3089 if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) 3090 return False; 3091 if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1)) 3092 return False; 3093 3094 if (r_u->num_entries != 0 && r_u->ptr_1 != 0) { 3095 if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth)) 3096 return False; 3097 } 3098 } 3099 3100 if(!prs_align(ps)) 3101 return False; 3102 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3103 return False; 3104 3105 return True; 3106} 3107 3108/******************************************************************* 3109inits a SAMR_Q_ENUM_DOMAINS structure. 3110********************************************************************/ 3111 3112void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e, 3113 POLICY_HND *pol, 3114 uint32 start_idx, uint32 size) 3115{ 3116 DEBUG(5, ("init_samr_q_enum_domains\n")); 3117 3118 q_e->pol = *pol; 3119 3120 q_e->start_idx = start_idx; 3121 q_e->max_size = size; 3122} 3123 3124/******************************************************************* 3125reads or writes a structure. 3126********************************************************************/ 3127 3128BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e, 3129 prs_struct *ps, int depth) 3130{ 3131 if (q_e == NULL) 3132 return False; 3133 3134 prs_debug(ps, depth, desc, "samr_io_q_enum_domains"); 3135 depth++; 3136 3137 if(!prs_align(ps)) 3138 return False; 3139 3140 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 3141 return False; 3142 3143 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) 3144 return False; 3145 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) 3146 return False; 3147 3148 return True; 3149} 3150 3151/******************************************************************* 3152inits a SAMR_R_ENUM_DOMAINS structure. 3153********************************************************************/ 3154 3155void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u, 3156 uint32 next_idx, uint32 num_sam_entries) 3157{ 3158 DEBUG(5, ("init_samr_r_enum_domains\n")); 3159 3160 r_u->next_idx = next_idx; 3161 3162 if (num_sam_entries != 0) { 3163 r_u->ptr_entries1 = 1; 3164 r_u->ptr_entries2 = 1; 3165 r_u->num_entries2 = num_sam_entries; 3166 r_u->num_entries3 = num_sam_entries; 3167 3168 r_u->num_entries4 = num_sam_entries; 3169 } else { 3170 r_u->ptr_entries1 = 0; 3171 r_u->num_entries2 = num_sam_entries; 3172 r_u->ptr_entries2 = 1; 3173 } 3174} 3175 3176/******************************************************************* 3177reads or writes a structure. 3178********************************************************************/ 3179 3180BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u, 3181 prs_struct *ps, int depth) 3182{ 3183 uint32 i; 3184 3185 if (r_u == NULL) 3186 return False; 3187 3188 prs_debug(ps, depth, desc, "samr_io_r_enum_domains"); 3189 depth++; 3190 3191 if(!prs_align(ps)) 3192 return False; 3193 3194 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) 3195 return False; 3196 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) 3197 return False; 3198 3199 if (r_u->ptr_entries1 != 0) { 3200 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) 3201 return False; 3202 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) 3203 return False; 3204 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) 3205 return False; 3206 3207 if (UNMARSHALLING(ps)) { 3208 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2); 3209 r_u->uni_dom_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2); 3210 } 3211 3212 if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) { 3213 DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n")); 3214 r_u->num_entries4 = 0; 3215 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; 3216 return False; 3217 } 3218 3219 for (i = 0; i < r_u->num_entries2; i++) { 3220 fstring tmp; 3221 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i); 3222 if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth)) 3223 return False; 3224 } 3225 3226 for (i = 0; i < r_u->num_entries2; i++) { 3227 fstring tmp; 3228 slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i); 3229 if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i], 3230 r_u->sam[i].hdr_name.buffer, ps, 3231 depth)) 3232 return False; 3233 } 3234 3235 } 3236 3237 if(!prs_align(ps)) 3238 return False; 3239 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) 3240 return False; 3241 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3242 return False; 3243 3244 return True; 3245} 3246 3247/******************************************************************* 3248inits a SAMR_Q_ENUM_DOM_GROUPS structure. 3249********************************************************************/ 3250 3251void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e, 3252 POLICY_HND *pol, 3253 uint32 start_idx, uint32 size) 3254{ 3255 DEBUG(5, ("init_samr_q_enum_dom_groups\n")); 3256 3257 q_e->pol = *pol; 3258 3259 q_e->start_idx = start_idx; 3260 q_e->max_size = size; 3261} 3262 3263/******************************************************************* 3264reads or writes a structure. 3265********************************************************************/ 3266 3267BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e, 3268 prs_struct *ps, int depth) 3269{ 3270 if (q_e == NULL) 3271 return False; 3272 3273 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups"); 3274 depth++; 3275 3276 if(!prs_align(ps)) 3277 return False; 3278 3279 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth)) 3280 return False; 3281 3282 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) 3283 return False; 3284 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) 3285 return False; 3286 3287 return True; 3288} 3289 3290/******************************************************************* 3291inits a SAMR_R_ENUM_DOM_GROUPS structure. 3292********************************************************************/ 3293 3294void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u, 3295 uint32 next_idx, uint32 num_sam_entries) 3296{ 3297 DEBUG(5, ("init_samr_r_enum_dom_groups\n")); 3298 3299 r_u->next_idx = next_idx; 3300 3301 if (num_sam_entries != 0) { 3302 r_u->ptr_entries1 = 1; 3303 r_u->ptr_entries2 = 1; 3304 r_u->num_entries2 = num_sam_entries; 3305 r_u->num_entries3 = num_sam_entries; 3306 3307 r_u->num_entries4 = num_sam_entries; 3308 } else { 3309 r_u->ptr_entries1 = 0; 3310 r_u->num_entries2 = num_sam_entries; 3311 r_u->ptr_entries2 = 1; 3312 } 3313} 3314 3315/******************************************************************* 3316reads or writes a structure. 3317********************************************************************/ 3318 3319BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u, 3320 prs_struct *ps, int depth) 3321{ 3322 uint32 i; 3323 3324 if (r_u == NULL) 3325 return False; 3326 3327 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups"); 3328 depth++; 3329 3330 if(!prs_align(ps)) 3331 return False; 3332 3333 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) 3334 return False; 3335 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) 3336 return False; 3337 3338 if (r_u->ptr_entries1 != 0) { 3339 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) 3340 return False; 3341 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) 3342 return False; 3343 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) 3344 return False; 3345 3346 if (UNMARSHALLING(ps)) { 3347 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2); 3348 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2); 3349 } 3350 3351 if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) { 3352 DEBUG(0, 3353 ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n")); 3354 r_u->num_entries4 = 0; 3355 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; 3356 return False; 3357 } 3358 3359 for (i = 0; i < r_u->num_entries2; i++) { 3360 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) 3361 return False; 3362 } 3363 3364 for (i = 0; i < r_u->num_entries2; i++) { 3365 if(!smb_io_unistr2("", &r_u->uni_grp_name[i], 3366 r_u->sam[i].hdr_name.buffer, ps, depth)) 3367 return False; 3368 } 3369 } 3370 3371 if(!prs_align(ps)) 3372 return False; 3373 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) 3374 return False; 3375 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3376 return False; 3377 3378 return True; 3379} 3380 3381/******************************************************************* 3382inits a SAMR_Q_ENUM_DOM_ALIASES structure. 3383********************************************************************/ 3384 3385void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e, 3386 POLICY_HND *pol, uint32 start_idx, 3387 uint32 size) 3388{ 3389 DEBUG(5, ("init_samr_q_enum_dom_aliases\n")); 3390 3391 q_e->pol = *pol; 3392 3393 q_e->start_idx = start_idx; 3394 q_e->max_size = size; 3395} 3396 3397 3398/******************************************************************* 3399reads or writes a structure. 3400********************************************************************/ 3401 3402BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e, 3403 prs_struct *ps, int depth) 3404{ 3405 if (q_e == NULL) 3406 return False; 3407 3408 prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases"); 3409 depth++; 3410 3411 if(!prs_align(ps)) 3412 return False; 3413 3414 if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) 3415 return False; 3416 3417 if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) 3418 return False; 3419 if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) 3420 return False; 3421 3422 return True; 3423} 3424 3425/******************************************************************* 3426inits a SAMR_R_ENUM_DOM_ALIASES structure. 3427********************************************************************/ 3428 3429void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries) 3430{ 3431 DEBUG(5, ("init_samr_r_enum_dom_aliases\n")); 3432 3433 r_u->next_idx = next_idx; 3434 3435 if (num_sam_entries != 0) { 3436 r_u->ptr_entries1 = 1; 3437 r_u->ptr_entries2 = 1; 3438 r_u->num_entries2 = num_sam_entries; 3439 r_u->num_entries3 = num_sam_entries; 3440 3441 r_u->num_entries4 = num_sam_entries; 3442 } else { 3443 r_u->ptr_entries1 = 0; 3444 r_u->num_entries2 = num_sam_entries; 3445 r_u->ptr_entries2 = 1; 3446 } 3447} 3448 3449/******************************************************************* 3450reads or writes a structure. 3451********************************************************************/ 3452 3453BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u, 3454 prs_struct *ps, int depth) 3455{ 3456 uint32 i; 3457 3458 if (r_u == NULL) 3459 return False; 3460 3461 prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases"); 3462 depth++; 3463 3464 if(!prs_align(ps)) 3465 return False; 3466 3467 if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) 3468 return False; 3469 if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) 3470 return False; 3471 3472 if (r_u->ptr_entries1 != 0) { 3473 if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) 3474 return False; 3475 if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) 3476 return False; 3477 if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) 3478 return False; 3479 3480 if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) { 3481 r_u->sam = PRS_ALLOC_MEM(ps,SAM_ENTRY,r_u->num_entries2); 3482 r_u->uni_grp_name = PRS_ALLOC_MEM(ps,UNISTR2,r_u->num_entries2); 3483 } 3484 3485 if (r_u->num_entries2 != 0 && 3486 (r_u->sam == NULL || r_u->uni_grp_name == NULL)) { 3487 DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n")); 3488 r_u->num_entries4 = 0; 3489 r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; 3490 return False; 3491 } 3492 3493 for (i = 0; i < r_u->num_entries2; i++) { 3494 if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) 3495 return False; 3496 } 3497 3498 for (i = 0; i < r_u->num_entries2; i++) { 3499 if(!smb_io_unistr2("", &r_u->uni_grp_name[i], 3500 r_u->sam[i].hdr_name.buffer, ps, 3501 depth)) 3502 return False; 3503 } 3504 } 3505 3506 if(!prs_align(ps)) 3507 return False; 3508 if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) 3509 return False; 3510 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3511 return False; 3512 3513 return True; 3514} 3515 3516/******************************************************************* 3517inits a ALIAS_INFO1 structure. 3518********************************************************************/ 3519 3520void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc) 3521{ 3522 DEBUG(5, ("init_samr_alias_info1\n")); 3523 3524 init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE); 3525 init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name); 3526 3527 al1->num_member=num_member; 3528 3529 init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 3530 init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name); 3531} 3532 3533/******************************************************************* 3534reads or writes a structure. 3535********************************************************************/ 3536 3537BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1, 3538 prs_struct *ps, int depth) 3539{ 3540 if (al1 == NULL) 3541 return False; 3542 3543 prs_debug(ps, depth, desc, "samr_io_alias_info1"); 3544 depth++; 3545 3546 if(!prs_align(ps)) 3547 return False; 3548 3549 if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth)) 3550 return False; 3551 if(!prs_uint32("num_member", ps, depth, &al1->num_member)) 3552 return False; 3553 if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth)) 3554 return False; 3555 3556 if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name, 3557 al1->hdr_acct_name.buffer, ps, depth)) 3558 return False; 3559 3560 if(!prs_align(ps)) 3561 return False; 3562 3563 if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc, 3564 al1->hdr_acct_desc.buffer, ps, depth)) 3565 return False; 3566 3567 return True; 3568} 3569 3570/******************************************************************* 3571inits a ALIAS_INFO3 structure. 3572********************************************************************/ 3573 3574void init_samr_alias_info3(ALIAS_INFO3 * al3, const char *acct_desc) 3575{ 3576 DEBUG(5, ("init_samr_alias_info3\n")); 3577 3578 init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 3579 init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc); 3580} 3581 3582/******************************************************************* 3583reads or writes a structure. 3584********************************************************************/ 3585 3586BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3, 3587 prs_struct *ps, int depth) 3588{ 3589 if (al3 == NULL) 3590 return False; 3591 3592 prs_debug(ps, depth, desc, "samr_io_alias_info3"); 3593 depth++; 3594 3595 if(!prs_align(ps)) 3596 return False; 3597 3598 if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth)) 3599 return False; 3600 if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc, 3601 al3->hdr_acct_desc.buffer, ps, depth)) 3602 return False; 3603 3604 return True; 3605} 3606 3607/******************************************************************* 3608reads or writes a structure. 3609********************************************************************/ 3610 3611BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr, 3612 prs_struct *ps, int depth) 3613{ 3614 if (ctr == NULL) 3615 return False; 3616 3617 prs_debug(ps, depth, desc, "samr_alias_info_ctr"); 3618 depth++; 3619 3620 if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1)) 3621 return False; 3622 if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2)) 3623 return False; 3624 3625 switch (ctr->switch_value1) { 3626 case 1: 3627 if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth)) 3628 return False; 3629 break; 3630 case 3: 3631 if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth)) 3632 return False; 3633 break; 3634 default: 3635 DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n")); 3636 break; 3637 } 3638 3639 return True; 3640} 3641 3642/******************************************************************* 3643inits a SAMR_Q_QUERY_ALIASINFO structure. 3644********************************************************************/ 3645 3646void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e, 3647 POLICY_HND *pol, uint16 switch_level) 3648{ 3649 DEBUG(5, ("init_samr_q_query_aliasinfo\n")); 3650 3651 q_e->pol = *pol; 3652 q_e->switch_level = switch_level; 3653} 3654 3655/******************************************************************* 3656reads or writes a structure. 3657********************************************************************/ 3658 3659BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e, 3660 prs_struct *ps, int depth) 3661{ 3662 if (q_e == NULL) 3663 return False; 3664 3665 prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo"); 3666 depth++; 3667 3668 if(!prs_align(ps)) 3669 return False; 3670 3671 if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth)) 3672 return False; 3673 3674 if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) 3675 return False; 3676 3677 return True; 3678} 3679 3680/******************************************************************* 3681inits a SAMR_R_QUERY_ALIASINFO structure. 3682********************************************************************/ 3683 3684void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u, 3685 ALIAS_INFO_CTR * ctr, NTSTATUS status) 3686{ 3687 DEBUG(5, ("init_samr_r_query_aliasinfo\n")); 3688 3689 r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0; 3690 r_u->ctr = *ctr; 3691 r_u->status = status; 3692} 3693 3694/******************************************************************* 3695reads or writes a structure. 3696********************************************************************/ 3697 3698BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u, 3699 prs_struct *ps, int depth) 3700{ 3701 if (r_u == NULL) 3702 return False; 3703 3704 prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo"); 3705 depth++; 3706 3707 if(!prs_align(ps)) 3708 return False; 3709 3710 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 3711 return False; 3712 3713 if (r_u->ptr != 0) { 3714 if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth)) 3715 return False; 3716 } 3717 3718 if(!prs_align(ps)) 3719 return False; 3720 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3721 return False; 3722 3723 return True; 3724} 3725 3726/******************************************************************* 3727inits a SAMR_Q_SET_ALIASINFO structure. 3728********************************************************************/ 3729 3730void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u, 3731 POLICY_HND *hnd, ALIAS_INFO_CTR * ctr) 3732{ 3733 DEBUG(5, ("init_samr_q_set_aliasinfo\n")); 3734 3735 q_u->alias_pol = *hnd; 3736 q_u->ctr = *ctr; 3737} 3738 3739/******************************************************************* 3740reads or writes a structure. 3741********************************************************************/ 3742 3743BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u, 3744 prs_struct *ps, int depth) 3745{ 3746 if (q_u == NULL) 3747 return False; 3748 3749 prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo"); 3750 depth++; 3751 3752 if(!prs_align(ps)) 3753 return False; 3754 3755 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 3756 return False; 3757 if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth)) 3758 return False; 3759 3760 return True; 3761} 3762 3763/******************************************************************* 3764reads or writes a structure. 3765********************************************************************/ 3766 3767BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u, 3768 prs_struct *ps, int depth) 3769{ 3770 if (r_u == NULL) 3771 return False; 3772 3773 prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo"); 3774 depth++; 3775 3776 if(!prs_align(ps)) 3777 return False; 3778 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3779 return False; 3780 3781 return True; 3782} 3783 3784/******************************************************************* 3785inits a SAMR_Q_QUERY_USERALIASES structure. 3786********************************************************************/ 3787 3788void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u, 3789 POLICY_HND *hnd, 3790 uint32 num_sids, 3791 uint32 *ptr_sid, DOM_SID2 * sid) 3792{ 3793 DEBUG(5, ("init_samr_q_query_useraliases\n")); 3794 3795 q_u->pol = *hnd; 3796 3797 q_u->num_sids1 = num_sids; 3798 q_u->ptr = 1; 3799 q_u->num_sids2 = num_sids; 3800 3801 q_u->ptr_sid = ptr_sid; 3802 q_u->sid = sid; 3803} 3804 3805/******************************************************************* 3806reads or writes a SAMR_Q_QUERY_USERALIASES structure. 3807********************************************************************/ 3808 3809BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u, 3810 prs_struct *ps, int depth) 3811{ 3812 fstring tmp; 3813 uint32 i; 3814 3815 if (q_u == NULL) 3816 return False; 3817 3818 prs_debug(ps, depth, desc, "samr_io_q_query_useraliases"); 3819 depth++; 3820 3821 if(!prs_align(ps)) 3822 return False; 3823 3824 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 3825 return False; 3826 3827 if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1)) 3828 return False; 3829 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) 3830 return False; 3831 3832 if (q_u->ptr==0) 3833 return True; 3834 3835 if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2)) 3836 return False; 3837 3838 if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) { 3839 q_u->ptr_sid = PRS_ALLOC_MEM(ps,uint32,q_u->num_sids2); 3840 if (q_u->ptr_sid == NULL) 3841 return False; 3842 3843 q_u->sid = PRS_ALLOC_MEM(ps, DOM_SID2, q_u->num_sids2); 3844 if (q_u->sid == NULL) 3845 return False; 3846 } 3847 3848 for (i = 0; i < q_u->num_sids2; i++) { 3849 slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i); 3850 if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i])) 3851 return False; 3852 } 3853 3854 for (i = 0; i < q_u->num_sids2; i++) { 3855 if (q_u->ptr_sid[i] != 0) { 3856 slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i); 3857 if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth)) 3858 return False; 3859 } 3860 } 3861 3862 return True; 3863} 3864 3865/******************************************************************* 3866inits a SAMR_R_QUERY_USERALIASES structure. 3867********************************************************************/ 3868 3869void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u, 3870 uint32 num_rids, uint32 *rid, 3871 NTSTATUS status) 3872{ 3873 DEBUG(5, ("init_samr_r_query_useraliases\n")); 3874 3875 if (NT_STATUS_IS_OK(status)) { 3876 r_u->num_entries = num_rids; 3877 r_u->ptr = 1; 3878 r_u->num_entries2 = num_rids; 3879 3880 r_u->rid = rid; 3881 } else { 3882 r_u->num_entries = 0; 3883 r_u->ptr = 0; 3884 r_u->num_entries2 = 0; 3885 } 3886 3887 r_u->status = status; 3888} 3889 3890/******************************************************************* 3891reads or writes a structure. 3892********************************************************************/ 3893 3894BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid, 3895 prs_struct *ps, int depth) 3896{ 3897 fstring tmp; 3898 uint32 i; 3899 if (rid == NULL) 3900 return False; 3901 3902 prs_debug(ps, depth, desc, "samr_io_rids"); 3903 depth++; 3904 3905 if(!prs_align(ps)) 3906 return False; 3907 3908 if(!prs_uint32("num_rids", ps, depth, num_rids)) 3909 return False; 3910 3911 if ((*num_rids) != 0) { 3912 if (UNMARSHALLING(ps)) { 3913 /* reading */ 3914 (*rid) = PRS_ALLOC_MEM(ps,uint32, *num_rids); 3915 } 3916 if ((*rid) == NULL) 3917 return False; 3918 3919 for (i = 0; i < (*num_rids); i++) { 3920 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i); 3921 if(!prs_uint32(tmp, ps, depth, &((*rid)[i]))) 3922 return False; 3923 } 3924 } 3925 3926 return True; 3927} 3928 3929/******************************************************************* 3930reads or writes a structure. 3931********************************************************************/ 3932 3933BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u, 3934 prs_struct *ps, int depth) 3935{ 3936 if (r_u == NULL) 3937 return False; 3938 3939 prs_debug(ps, depth, desc, "samr_io_r_query_useraliases"); 3940 depth++; 3941 3942 if(!prs_align(ps)) 3943 return False; 3944 3945 if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries)) 3946 return False; 3947 if(!prs_uint32("ptr ", ps, depth, &r_u->ptr)) 3948 return False; 3949 3950 if (r_u->ptr != 0) { 3951 if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth)) 3952 return False; 3953 } 3954 3955 if(!prs_align(ps)) 3956 return False; 3957 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 3958 return False; 3959 3960 return True; 3961} 3962 3963/******************************************************************* 3964inits a SAMR_Q_OPEN_ALIAS structure. 3965********************************************************************/ 3966 3967void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol, 3968 uint32 access_mask, uint32 rid) 3969{ 3970 DEBUG(5, ("init_samr_q_open_alias\n")); 3971 3972 q_u->dom_pol = *pol; 3973 q_u->access_mask = access_mask; 3974 q_u->rid_alias = rid; 3975} 3976 3977/******************************************************************* 3978reads or writes a structure. 3979********************************************************************/ 3980 3981BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u, 3982 prs_struct *ps, int depth) 3983{ 3984 if (q_u == NULL) 3985 return False; 3986 3987 prs_debug(ps, depth, desc, "samr_io_q_open_alias"); 3988 depth++; 3989 3990 if(!prs_align(ps)) 3991 return False; 3992 3993 if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth)) 3994 return False; 3995 3996 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 3997 return False; 3998 if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias)) 3999 return False; 4000 4001 return True; 4002} 4003 4004/******************************************************************* 4005reads or writes a structure. 4006********************************************************************/ 4007 4008BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u, 4009 prs_struct *ps, int depth) 4010{ 4011 if (r_u == NULL) 4012 return False; 4013 4014 prs_debug(ps, depth, desc, "samr_io_r_open_alias"); 4015 depth++; 4016 4017 if(!prs_align(ps)) 4018 return False; 4019 4020 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 4021 return False; 4022 4023 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4024 return False; 4025 4026 return True; 4027} 4028 4029/******************************************************************* 4030inits a SAMR_Q_LOOKUP_RIDS structure. 4031********************************************************************/ 4032 4033void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u, 4034 POLICY_HND *pol, uint32 flags, 4035 uint32 num_rids, uint32 *rid) 4036{ 4037 DEBUG(5, ("init_samr_q_lookup_rids\n")); 4038 4039 q_u->pol = *pol; 4040 4041 q_u->num_rids1 = num_rids; 4042 q_u->flags = flags; 4043 q_u->ptr = 0; 4044 q_u->num_rids2 = num_rids; 4045 q_u->rid = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids ); 4046 if (q_u->rid == NULL) { 4047 q_u->num_rids1 = 0; 4048 q_u->num_rids2 = 0; 4049 } else { 4050 memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0])); 4051 } 4052} 4053 4054/******************************************************************* 4055reads or writes a structure. 4056********************************************************************/ 4057 4058BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u, 4059 prs_struct *ps, int depth) 4060{ 4061 uint32 i; 4062 fstring tmp; 4063 4064 if (q_u == NULL) 4065 return False; 4066 4067 prs_debug(ps, depth, desc, "samr_io_q_lookup_rids"); 4068 depth++; 4069 4070 if (UNMARSHALLING(ps)) 4071 ZERO_STRUCTP(q_u); 4072 4073 if(!prs_align(ps)) 4074 return False; 4075 4076 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 4077 return False; 4078 4079 if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1)) 4080 return False; 4081 if(!prs_uint32("flags ", ps, depth, &q_u->flags)) 4082 return False; 4083 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) 4084 return False; 4085 if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2)) 4086 return False; 4087 4088 if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) { 4089 q_u->rid = PRS_ALLOC_MEM(ps, uint32, q_u->num_rids2); 4090 if (q_u->rid == NULL) 4091 return False; 4092 } 4093 4094 for (i = 0; i < q_u->num_rids2; i++) { 4095 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i); 4096 if(!prs_uint32(tmp, ps, depth, &q_u->rid[i])) 4097 return False; 4098 } 4099 4100 return True; 4101} 4102 4103/******************************************************************* 4104inits a SAMR_R_LOOKUP_RIDS structure. 4105********************************************************************/ 4106 4107void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u, 4108 uint32 num_names, UNIHDR * hdr_name, 4109 UNISTR2 *uni_name, uint32 *type) 4110{ 4111 DEBUG(5, ("init_samr_r_lookup_rids\n")); 4112 4113 r_u->hdr_name = NULL; 4114 r_u->uni_name = NULL; 4115 r_u->type = NULL; 4116 4117 if (num_names != 0) { 4118 r_u->num_names1 = num_names; 4119 r_u->ptr_names = 1; 4120 r_u->num_names2 = num_names; 4121 4122 r_u->num_types1 = num_names; 4123 r_u->ptr_types = 1; 4124 r_u->num_types2 = num_names; 4125 4126 r_u->hdr_name = hdr_name; 4127 r_u->uni_name = uni_name; 4128 r_u->type = type; 4129 } else { 4130 r_u->num_names1 = num_names; 4131 r_u->ptr_names = 0; 4132 r_u->num_names2 = num_names; 4133 4134 r_u->num_types1 = num_names; 4135 r_u->ptr_types = 0; 4136 r_u->num_types2 = num_names; 4137 } 4138} 4139 4140/******************************************************************* 4141reads or writes a structure. 4142********************************************************************/ 4143 4144BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u, 4145 prs_struct *ps, int depth) 4146{ 4147 uint32 i; 4148 fstring tmp; 4149 if (r_u == NULL) 4150 return False; 4151 4152 prs_debug(ps, depth, desc, "samr_io_r_lookup_rids"); 4153 depth++; 4154 4155 if(!prs_align(ps)) 4156 return False; 4157 4158 if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1)) 4159 return False; 4160 if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names)) 4161 return False; 4162 4163 if (r_u->ptr_names != 0) { 4164 4165 if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2)) 4166 return False; 4167 4168 4169 if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) { 4170 r_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, r_u->num_names2); 4171 if (r_u->hdr_name == NULL) 4172 return False; 4173 4174 r_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, r_u->num_names2); 4175 if (r_u->uni_name == NULL) 4176 return False; 4177 } 4178 4179 for (i = 0; i < r_u->num_names2; i++) { 4180 slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i); 4181 if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth)) 4182 return False; 4183 } 4184 for (i = 0; i < r_u->num_names2; i++) { 4185 slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i); 4186 if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth)) 4187 return False; 4188 } 4189 4190 } 4191 4192 if(!prs_align(ps)) 4193 return False; 4194 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1)) 4195 return False; 4196 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types)) 4197 return False; 4198 4199 if (r_u->ptr_types != 0) { 4200 4201 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2)) 4202 return False; 4203 4204 if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) { 4205 r_u->type = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2); 4206 if (r_u->type == NULL) 4207 return False; 4208 } 4209 4210 for (i = 0; i < r_u->num_types2; i++) { 4211 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i); 4212 if(!prs_uint32(tmp, ps, depth, &r_u->type[i])) 4213 return False; 4214 } 4215 } 4216 4217 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4218 return False; 4219 4220 return True; 4221} 4222 4223/******************************************************************* 4224inits a SAMR_Q_OPEN_ALIAS structure. 4225********************************************************************/ 4226 4227void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd) 4228{ 4229 DEBUG(5, ("init_samr_q_delete_alias\n")); 4230 4231 q_u->alias_pol = *hnd; 4232} 4233 4234/******************************************************************* 4235reads or writes a structure. 4236********************************************************************/ 4237 4238BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u, 4239 prs_struct *ps, int depth) 4240{ 4241 if (q_u == NULL) 4242 return False; 4243 4244 prs_debug(ps, depth, desc, "samr_io_q_delete_alias"); 4245 depth++; 4246 4247 if(!prs_align(ps)) 4248 return False; 4249 4250 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 4251 return False; 4252 4253 return True; 4254} 4255 4256/******************************************************************* 4257reads or writes a structure. 4258********************************************************************/ 4259 4260BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u, 4261 prs_struct *ps, int depth) 4262{ 4263 if (r_u == NULL) 4264 return False; 4265 4266 prs_debug(ps, depth, desc, "samr_io_r_delete_alias"); 4267 depth++; 4268 4269 if(!prs_align(ps)) 4270 return False; 4271 4272 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 4273 return False; 4274 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4275 return False; 4276 4277 return True; 4278} 4279 4280/******************************************************************* 4281inits a SAMR_Q_CREATE_DOM_ALIAS structure. 4282********************************************************************/ 4283 4284void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u, 4285 POLICY_HND *hnd, const char *acct_desc) 4286{ 4287 DEBUG(5, ("init_samr_q_create_dom_alias\n")); 4288 4289 q_u->dom_pol = *hnd; 4290 4291 init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE); 4292 init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc); 4293 4294 q_u->access_mask = MAXIMUM_ALLOWED_ACCESS; 4295} 4296 4297/******************************************************************* 4298reads or writes a structure. 4299********************************************************************/ 4300 4301BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u, 4302 prs_struct *ps, int depth) 4303{ 4304 if (q_u == NULL) 4305 return False; 4306 4307 prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias"); 4308 depth++; 4309 4310 if(!prs_align(ps)) 4311 return False; 4312 4313 if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth)) 4314 return False; 4315 4316 if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth)) 4317 return False; 4318 if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc, 4319 q_u->hdr_acct_desc.buffer, ps, depth)) 4320 return False; 4321 4322 if(!prs_align(ps)) 4323 return False; 4324 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 4325 return False; 4326 4327 return True; 4328} 4329 4330/******************************************************************* 4331reads or writes a structure. 4332********************************************************************/ 4333 4334BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u, 4335 prs_struct *ps, int depth) 4336{ 4337 if (r_u == NULL) 4338 return False; 4339 4340 prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias"); 4341 depth++; 4342 4343 if(!prs_align(ps)) 4344 return False; 4345 4346 if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth)) 4347 return False; 4348 4349 if(!prs_uint32("rid", ps, depth, &r_u->rid)) 4350 return False; 4351 4352 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4353 return False; 4354 4355 return True; 4356} 4357 4358/******************************************************************* 4359inits a SAMR_Q_ADD_ALIASMEM structure. 4360********************************************************************/ 4361 4362void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd, 4363 DOM_SID *sid) 4364{ 4365 DEBUG(5, ("init_samr_q_add_aliasmem\n")); 4366 4367 q_u->alias_pol = *hnd; 4368 init_dom_sid2(&q_u->sid, sid); 4369} 4370 4371/******************************************************************* 4372reads or writes a structure. 4373********************************************************************/ 4374 4375BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u, 4376 prs_struct *ps, int depth) 4377{ 4378 if (q_u == NULL) 4379 return False; 4380 4381 prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem"); 4382 depth++; 4383 4384 if(!prs_align(ps)) 4385 return False; 4386 4387 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 4388 return False; 4389 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth)) 4390 return False; 4391 4392 return True; 4393} 4394 4395/******************************************************************* 4396reads or writes a structure. 4397********************************************************************/ 4398 4399BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u, 4400 prs_struct *ps, int depth) 4401{ 4402 if (r_u == NULL) 4403 return False; 4404 4405 prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem"); 4406 depth++; 4407 4408 if(!prs_align(ps)) 4409 return False; 4410 4411 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4412 return False; 4413 4414 return True; 4415} 4416 4417/******************************************************************* 4418inits a SAMR_Q_DEL_ALIASMEM structure. 4419********************************************************************/ 4420 4421void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd, 4422 DOM_SID *sid) 4423{ 4424 DEBUG(5, ("init_samr_q_del_aliasmem\n")); 4425 4426 q_u->alias_pol = *hnd; 4427 init_dom_sid2(&q_u->sid, sid); 4428} 4429 4430/******************************************************************* 4431reads or writes a structure. 4432********************************************************************/ 4433 4434BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u, 4435 prs_struct *ps, int depth) 4436{ 4437 if (q_u == NULL) 4438 return False; 4439 4440 prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem"); 4441 depth++; 4442 4443 if(!prs_align(ps)) 4444 return False; 4445 4446 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 4447 return False; 4448 if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth)) 4449 return False; 4450 4451 return True; 4452} 4453 4454/******************************************************************* 4455reads or writes a structure. 4456********************************************************************/ 4457 4458BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u, 4459 prs_struct *ps, int depth) 4460{ 4461 if (r_u == NULL) 4462 return False; 4463 4464 prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem"); 4465 depth++; 4466 4467 if(!prs_align(ps)) 4468 return False; 4469 4470 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4471 return False; 4472 4473 return True; 4474} 4475 4476/******************************************************************* 4477inits a SAMR_Q_DELETE_DOM_ALIAS structure. 4478********************************************************************/ 4479 4480void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c, 4481 POLICY_HND *hnd) 4482{ 4483 DEBUG(5, ("init_samr_q_delete_dom_alias\n")); 4484 4485 q_c->alias_pol = *hnd; 4486} 4487 4488/******************************************************************* 4489reads or writes a structure. 4490********************************************************************/ 4491 4492BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u, 4493 prs_struct *ps, int depth) 4494{ 4495 if (q_u == NULL) 4496 return False; 4497 4498 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias"); 4499 depth++; 4500 4501 if(!prs_align(ps)) 4502 return False; 4503 4504 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 4505 return False; 4506 4507 return True; 4508} 4509 4510/******************************************************************* 4511inits a SAMR_R_DELETE_DOM_ALIAS structure. 4512********************************************************************/ 4513 4514void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u, 4515 NTSTATUS status) 4516{ 4517 DEBUG(5, ("init_samr_r_delete_dom_alias\n")); 4518 4519 r_u->status = status; 4520} 4521 4522/******************************************************************* 4523reads or writes a structure. 4524********************************************************************/ 4525 4526BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u, 4527 prs_struct *ps, int depth) 4528{ 4529 if (r_u == NULL) 4530 return False; 4531 4532 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias"); 4533 depth++; 4534 4535 if(!prs_align(ps)) 4536 return False; 4537 4538 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4539 return False; 4540 4541 return True; 4542} 4543 4544/******************************************************************* 4545inits a SAMR_Q_QUERY_ALIASMEM structure. 4546********************************************************************/ 4547 4548void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c, 4549 POLICY_HND *hnd) 4550{ 4551 DEBUG(5, ("init_samr_q_query_aliasmem\n")); 4552 4553 q_c->alias_pol = *hnd; 4554} 4555 4556/******************************************************************* 4557reads or writes a structure. 4558********************************************************************/ 4559 4560BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u, 4561 prs_struct *ps, int depth) 4562{ 4563 if (q_u == NULL) 4564 return False; 4565 4566 prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem"); 4567 depth++; 4568 4569 if(!prs_align(ps)) 4570 return False; 4571 4572 if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) 4573 return False; 4574 4575 return True; 4576} 4577 4578/******************************************************************* 4579inits a SAMR_R_QUERY_ALIASMEM structure. 4580********************************************************************/ 4581 4582void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u, 4583 uint32 num_sids, DOM_SID2 * sid, 4584 NTSTATUS status) 4585{ 4586 DEBUG(5, ("init_samr_r_query_aliasmem\n")); 4587 4588 if (NT_STATUS_IS_OK(status)) { 4589 r_u->num_sids = num_sids; 4590 r_u->ptr = (num_sids != 0) ? 1 : 0; 4591 r_u->num_sids1 = num_sids; 4592 4593 r_u->sid = sid; 4594 } else { 4595 r_u->ptr = 0; 4596 r_u->num_sids = 0; 4597 } 4598 4599 r_u->status = status; 4600} 4601 4602/******************************************************************* 4603reads or writes a structure. 4604********************************************************************/ 4605 4606BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u, 4607 prs_struct *ps, int depth) 4608{ 4609 uint32 i; 4610 4611 if (r_u == NULL) 4612 return False; 4613 4614 prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem"); 4615 depth++; 4616 4617 if(!prs_align(ps)) 4618 return False; 4619 4620 if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids)) 4621 return False; 4622 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 4623 return False; 4624 4625 if (r_u->ptr != 0 && r_u->num_sids != 0) { 4626 uint32 *ptr_sid = NULL; 4627 4628 if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1)) 4629 return False; 4630 4631 ptr_sid = TALLOC_ARRAY(ps->mem_ctx, uint32, r_u->num_sids1); 4632 if (!ptr_sid) { 4633 return False; 4634 } 4635 4636 for (i = 0; i < r_u->num_sids1; i++) { 4637 ptr_sid[i] = 1; 4638 if(!prs_uint32("ptr_sid", ps, depth, &ptr_sid[i])) 4639 return False; 4640 } 4641 4642 if (UNMARSHALLING(ps)) { 4643 r_u->sid = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, r_u->num_sids1); 4644 } 4645 4646 for (i = 0; i < r_u->num_sids1; i++) { 4647 if (ptr_sid[i] != 0) { 4648 if(!smb_io_dom_sid2("sid", &r_u->sid[i], ps, depth)) 4649 return False; 4650 } 4651 } 4652 } 4653 4654 if(!prs_align(ps)) 4655 return False; 4656 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4657 return False; 4658 4659 return True; 4660} 4661 4662/******************************************************************* 4663inits a SAMR_Q_LOOKUP_NAMES structure. 4664********************************************************************/ 4665 4666NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u, 4667 POLICY_HND *pol, uint32 flags, 4668 uint32 num_names, const char **name) 4669{ 4670 uint32 i; 4671 4672 DEBUG(5, ("init_samr_q_lookup_names\n")); 4673 4674 q_u->pol = *pol; 4675 4676 q_u->num_names1 = num_names; 4677 q_u->flags = flags; 4678 q_u->ptr = 0; 4679 q_u->num_names2 = num_names; 4680 4681 if (!(q_u->hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names))) 4682 return NT_STATUS_NO_MEMORY; 4683 4684 if (!(q_u->uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_names))) 4685 return NT_STATUS_NO_MEMORY; 4686 4687 for (i = 0; i < num_names; i++) { 4688 init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */ 4689 init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */ 4690 } 4691 4692 return NT_STATUS_OK; 4693} 4694 4695/******************************************************************* 4696reads or writes a structure. 4697********************************************************************/ 4698 4699BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u, 4700 prs_struct *ps, int depth) 4701{ 4702 uint32 i; 4703 4704 if (q_u == NULL) 4705 return False; 4706 4707 prs_debug(ps, depth, desc, "samr_io_q_lookup_names"); 4708 depth++; 4709 4710 if (UNMARSHALLING(ps)) 4711 ZERO_STRUCTP(q_u); 4712 4713 if(!prs_align(ps)) 4714 return False; 4715 4716 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 4717 return False; 4718 4719 if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1)) 4720 return False; 4721 if(!prs_uint32("flags ", ps, depth, &q_u->flags)) 4722 return False; 4723 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) 4724 return False; 4725 if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2)) 4726 return False; 4727 4728 if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) { 4729 q_u->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_u->num_names2); 4730 q_u->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_u->num_names2); 4731 if (!q_u->hdr_name || !q_u->uni_name) 4732 return False; 4733 } 4734 4735 for (i = 0; i < q_u->num_names2; i++) { 4736 if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth)) 4737 return False; 4738 } 4739 4740 for (i = 0; i < q_u->num_names2; i++) { 4741 if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth)) 4742 return False; 4743 } 4744 4745 return True; 4746} 4747 4748/******************************************************************* 4749inits a SAMR_R_LOOKUP_NAMES structure. 4750********************************************************************/ 4751 4752NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u, 4753 uint32 num_rids, 4754 uint32 *rid, uint32 *type, 4755 NTSTATUS status) 4756{ 4757 DEBUG(5, ("init_samr_r_lookup_names\n")); 4758 4759 if (NT_STATUS_IS_OK(status) && (num_rids != 0)) { 4760 uint32 i; 4761 4762 r_u->num_types1 = num_rids; 4763 r_u->ptr_types = 1; 4764 r_u->num_types2 = num_rids; 4765 4766 r_u->num_rids1 = num_rids; 4767 r_u->ptr_rids = 1; 4768 r_u->num_rids2 = num_rids; 4769 4770 if (!(r_u->rids = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids))) 4771 return NT_STATUS_NO_MEMORY; 4772 if (!(r_u->types = TALLOC_ZERO_ARRAY(ctx, uint32, num_rids))) 4773 return NT_STATUS_NO_MEMORY; 4774 4775 if (!r_u->rids || !r_u->types) 4776 goto empty; 4777 4778 for (i = 0; i < num_rids; i++) { 4779 r_u->rids[i] = rid[i]; 4780 r_u->types[i] = type[i]; 4781 } 4782 } else { 4783 4784 empty: 4785 r_u->num_types1 = 0; 4786 r_u->ptr_types = 0; 4787 r_u->num_types2 = 0; 4788 4789 r_u->num_rids1 = 0; 4790 r_u->ptr_rids = 0; 4791 r_u->num_rids2 = 0; 4792 4793 r_u->rids = NULL; 4794 r_u->types = NULL; 4795 } 4796 4797 r_u->status = status; 4798 4799 return NT_STATUS_OK; 4800} 4801 4802/******************************************************************* 4803reads or writes a structure. 4804********************************************************************/ 4805 4806BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u, 4807 prs_struct *ps, int depth) 4808{ 4809 uint32 i; 4810 fstring tmp; 4811 4812 if (r_u == NULL) 4813 return False; 4814 4815 prs_debug(ps, depth, desc, "samr_io_r_lookup_names"); 4816 depth++; 4817 4818 if (UNMARSHALLING(ps)) 4819 ZERO_STRUCTP(r_u); 4820 4821 if(!prs_align(ps)) 4822 return False; 4823 4824 if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1)) 4825 return False; 4826 if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids)) 4827 return False; 4828 4829 if (r_u->ptr_rids != 0) { 4830 if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2)) 4831 return False; 4832 4833 if (r_u->num_rids2 != r_u->num_rids1) { 4834 /* RPC fault */ 4835 return False; 4836 } 4837 4838 if (UNMARSHALLING(ps)) 4839 r_u->rids = PRS_ALLOC_MEM(ps, uint32, r_u->num_rids2); 4840 4841 if (!r_u->rids) { 4842 DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n")); 4843 return False; 4844 } 4845 4846 for (i = 0; i < r_u->num_rids2; i++) { 4847 slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i); 4848 if(!prs_uint32(tmp, ps, depth, &r_u->rids[i])) 4849 return False; 4850 } 4851 } 4852 4853 if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1)) 4854 return False; 4855 if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types)) 4856 return False; 4857 4858 if (r_u->ptr_types != 0) { 4859 if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2)) 4860 return False; 4861 4862 if (r_u->num_types2 != r_u->num_types1) { 4863 /* RPC fault */ 4864 return False; 4865 } 4866 4867 if (UNMARSHALLING(ps)) 4868 r_u->types = PRS_ALLOC_MEM(ps, uint32, r_u->num_types2); 4869 4870 if (!r_u->types) { 4871 DEBUG(0, ("NULL types in samr_io_r_lookup_names\n")); 4872 return False; 4873 } 4874 4875 for (i = 0; i < r_u->num_types2; i++) { 4876 slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i); 4877 if(!prs_uint32(tmp, ps, depth, &r_u->types[i])) 4878 return False; 4879 } 4880 } 4881 4882 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4883 return False; 4884 4885 return True; 4886} 4887 4888/******************************************************************* 4889inits a SAMR_Q_DELETE_DOM_USER structure. 4890********************************************************************/ 4891 4892void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c, 4893 POLICY_HND *hnd) 4894{ 4895 DEBUG(5, ("init_samr_q_delete_dom_user\n")); 4896 4897 q_c->user_pol = *hnd; 4898} 4899 4900/******************************************************************* 4901reads or writes a structure. 4902********************************************************************/ 4903 4904BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u, 4905 prs_struct *ps, int depth) 4906{ 4907 if (q_u == NULL) 4908 return False; 4909 4910 prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user"); 4911 depth++; 4912 4913 if(!prs_align(ps)) 4914 return False; 4915 4916 if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth)) 4917 return False; 4918 4919 return True; 4920} 4921 4922/******************************************************************* 4923reads or writes a structure. 4924********************************************************************/ 4925 4926BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u, 4927 prs_struct *ps, int depth) 4928{ 4929 if (r_u == NULL) 4930 return False; 4931 4932 prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user"); 4933 depth++; 4934 4935 if(!prs_align(ps)) 4936 return False; 4937 4938 if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) 4939 return False; 4940 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 4941 return False; 4942 4943 return True; 4944} 4945 4946/******************************************************************* 4947reads or writes a structure. 4948********************************************************************/ 4949 4950void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u, 4951 POLICY_HND *pol, 4952 uint32 access_mask, uint32 rid) 4953{ 4954 DEBUG(5, ("samr_init_samr_q_open_user\n")); 4955 4956 q_u->domain_pol = *pol; 4957 q_u->access_mask = access_mask; 4958 q_u->user_rid = rid; 4959} 4960 4961/******************************************************************* 4962reads or writes a structure. 4963********************************************************************/ 4964 4965BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u, 4966 prs_struct *ps, int depth) 4967{ 4968 if (q_u == NULL) 4969 return False; 4970 4971 prs_debug(ps, depth, desc, "samr_io_q_open_user"); 4972 depth++; 4973 4974 if(!prs_align(ps)) 4975 return False; 4976 4977 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 4978 return False; 4979 4980 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 4981 return False; 4982 if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid)) 4983 return False; 4984 4985 return True; 4986} 4987 4988/******************************************************************* 4989reads or writes a structure. 4990********************************************************************/ 4991 4992BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u, 4993 prs_struct *ps, int depth) 4994{ 4995 if (r_u == NULL) 4996 return False; 4997 4998 prs_debug(ps, depth, desc, "samr_io_r_open_user"); 4999 depth++; 5000 5001 if(!prs_align(ps)) 5002 return False; 5003 5004 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth)) 5005 return False; 5006 5007 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 5008 return False; 5009 5010 return True; 5011} 5012 5013 5014/******************************************************************* 5015reads or writes a structure. 5016********************************************************************/ 5017 5018void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u, 5019 POLICY_HND *pol, 5020 const char *name, 5021 uint32 acb_info, uint32 access_mask) 5022{ 5023 DEBUG(5, ("samr_init_samr_q_create_user\n")); 5024 5025 q_u->domain_pol = *pol; 5026 5027 init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE); 5028 init_uni_hdr(&q_u->hdr_name, &q_u->uni_name); 5029 5030 q_u->acb_info = acb_info; 5031 q_u->access_mask = access_mask; 5032} 5033 5034/******************************************************************* 5035reads or writes a structure. 5036********************************************************************/ 5037 5038BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u, 5039 prs_struct *ps, int depth) 5040{ 5041 if (q_u == NULL) 5042 return False; 5043 5044 prs_debug(ps, depth, desc, "samr_io_q_create_user"); 5045 depth++; 5046 5047 if(!prs_align(ps)) 5048 return False; 5049 5050 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 5051 return False; 5052 5053 if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth)) 5054 return False; 5055 if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth)) 5056 return False; 5057 5058 if(!prs_align(ps)) 5059 return False; 5060 if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info)) 5061 return False; 5062 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 5063 return False; 5064 5065 return True; 5066} 5067 5068/******************************************************************* 5069reads or writes a structure. 5070********************************************************************/ 5071 5072BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u, 5073 prs_struct *ps, int depth) 5074{ 5075 if (r_u == NULL) 5076 return False; 5077 5078 prs_debug(ps, depth, desc, "samr_io_r_create_user"); 5079 depth++; 5080 5081 if(!prs_align(ps)) 5082 return False; 5083 5084 if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth)) 5085 return False; 5086 5087 if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted)) 5088 return False; 5089 if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid)) 5090 return False; 5091 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 5092 return False; 5093 5094 return True; 5095} 5096 5097/******************************************************************* 5098inits a SAMR_Q_QUERY_USERINFO structure. 5099********************************************************************/ 5100 5101void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u, 5102 POLICY_HND *hnd, uint16 switch_value) 5103{ 5104 DEBUG(5, ("init_samr_q_query_userinfo\n")); 5105 5106 q_u->pol = *hnd; 5107 q_u->switch_value = switch_value; 5108} 5109 5110/******************************************************************* 5111reads or writes a structure. 5112********************************************************************/ 5113 5114BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u, 5115 prs_struct *ps, int depth) 5116{ 5117 if (q_u == NULL) 5118 return False; 5119 5120 prs_debug(ps, depth, desc, "samr_io_q_query_userinfo"); 5121 depth++; 5122 5123 if(!prs_align(ps)) 5124 return False; 5125 5126 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 5127 return False; 5128 5129 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */ 5130 return False; 5131 5132 return True; 5133} 5134 5135/******************************************************************* 5136reads or writes a LOGON_HRS structure. 5137********************************************************************/ 5138 5139static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs, 5140 prs_struct *ps, int depth) 5141{ 5142 if (hrs == NULL) 5143 return False; 5144 5145 prs_debug(ps, depth, desc, "sam_io_logon_hrs"); 5146 depth++; 5147 5148 if(!prs_align(ps)) 5149 return False; 5150 5151 if(!prs_uint32("maxlen", ps, depth, &hrs->max_len)) 5152 return False; 5153 5154 if(!prs_uint32("offset", ps, depth, &hrs->offset)) 5155 return False; 5156 5157 if(!prs_uint32("len ", ps, depth, &hrs->len)) 5158 return False; 5159 5160 if (hrs->len > sizeof(hrs->hours)) { 5161 DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len)); 5162 hrs->len = sizeof(hrs->hours); 5163 } 5164 5165 if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len)) 5166 return False; 5167 5168 return True; 5169} 5170 5171/******************************************************************* 5172inits a SAM_USER_INFO_12 structure. 5173********************************************************************/ 5174 5175void init_sam_user_info12(SAM_USER_INFO_12 * usr, 5176 const uint8 lm_pwd[16], const uint8 nt_pwd[16]) 5177{ 5178 DEBUG(5, ("init_sam_user_info12\n")); 5179 5180 usr->lm_pwd_active = 5181 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0; 5182 usr->nt_pwd_active = 5183 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0; 5184} 5185 5186/******************************************************************* 5187reads or writes a structure. 5188********************************************************************/ 5189 5190static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u, 5191 prs_struct *ps, int depth) 5192{ 5193 if (u == NULL) 5194 return False; 5195 5196 prs_debug(ps, depth, desc, "samr_io_r_user_info12"); 5197 depth++; 5198 5199 if(!prs_align(ps)) 5200 return False; 5201 5202 if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd))) 5203 return False; 5204 if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd))) 5205 return False; 5206 5207 if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active)) 5208 return False; 5209 if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active)) 5210 return False; 5211 5212 return True; 5213} 5214 5215/******************************************************************* 5216inits a SAM_USER_INFO_7 structure. 5217********************************************************************/ 5218 5219void init_sam_user_info7(SAM_USER_INFO_7 * usr, const char *name) 5220{ 5221 DEBUG(5, ("init_sam_user_info7\n")); 5222 5223 init_unistr2(&usr->uni_name, name, UNI_FLAGS_NONE); /* unicode string for name */ 5224 init_uni_hdr(&usr->hdr_name, &usr->uni_name); /* unicode header for name */ 5225 5226} 5227 5228/******************************************************************* 5229reads or writes a structure. 5230********************************************************************/ 5231 5232static BOOL sam_io_user_info7(const char *desc, SAM_USER_INFO_7 * usr, 5233 prs_struct *ps, int depth) 5234{ 5235 if (usr == NULL) 5236 return False; 5237 5238 prs_debug(ps, depth, desc, "samr_io_r_user_info7"); 5239 depth++; 5240 5241 if(!prs_align(ps)) 5242 return False; 5243 5244 if(!smb_io_unihdr("unihdr", &usr->hdr_name, ps, depth)) 5245 return False; 5246 5247 if(!smb_io_unistr2("unistr2", &usr->uni_name, True, ps, depth)) 5248 return False; 5249 5250 return True; 5251} 5252 5253/******************************************************************* 5254inits a SAM_USER_INFO_10 structure. 5255********************************************************************/ 5256 5257void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info) 5258{ 5259 DEBUG(5, ("init_sam_user_info10\n")); 5260 5261 usr->acb_info = acb_info; 5262} 5263 5264/******************************************************************* 5265reads or writes a structure. 5266********************************************************************/ 5267 5268static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr, 5269 prs_struct *ps, int depth) 5270{ 5271 if (usr == NULL) 5272 return False; 5273 5274 prs_debug(ps, depth, desc, "samr_io_r_user_info10"); 5275 depth++; 5276 5277 if(!prs_align(ps)) 5278 return False; 5279 5280 if(!prs_uint32("acb_info", ps, depth, &usr->acb_info)) 5281 return False; 5282 5283 return True; 5284} 5285 5286/******************************************************************* 5287inits a SAM_USER_INFO_11 structure. 5288********************************************************************/ 5289 5290void init_sam_user_info11(SAM_USER_INFO_11 * usr, 5291 NTTIME * expiry, 5292 char *mach_acct, 5293 uint32 rid_user, uint32 rid_group, uint16 acct_ctrl) 5294{ 5295 DEBUG(5, ("init_sam_user_info11\n")); 5296 5297 memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */ 5298 ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */ 5299 5300 usr->padding_2 = 0; /* 0 - padding 4 bytes */ 5301 5302 usr->ptr_1 = 1; /* pointer */ 5303 ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */ 5304 usr->padding_4 = 0; /* 0 - padding 4 bytes */ 5305 5306 usr->ptr_2 = 1; /* pointer */ 5307 usr->padding_5 = 0; /* 0 - padding 4 bytes */ 5308 5309 usr->ptr_3 = 1; /* pointer */ 5310 ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */ 5311 5312 usr->rid_user = rid_user; 5313 usr->rid_group = rid_group; 5314 5315 usr->acct_ctrl = acct_ctrl; 5316 usr->unknown_3 = 0x0000; 5317 5318 usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */ 5319 usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */ 5320 5321 ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */ 5322 usr->padding_8 = 0; /* 0 - padding 4 bytes */ 5323 5324 init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */ 5325 init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */ 5326} 5327 5328/******************************************************************* 5329reads or writes a structure. 5330********************************************************************/ 5331 5332static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr, 5333 prs_struct *ps, int depth) 5334{ 5335 if (usr == NULL) 5336 return False; 5337 5338 prs_debug(ps, depth, desc, "samr_io_r_unknown_11"); 5339 depth++; 5340 5341 if(!prs_align(ps)) 5342 return False; 5343 5344 if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0))) 5345 return False; 5346 5347 if(!smb_io_time("time", &usr->expiry, ps, depth)) 5348 return False; 5349 5350 if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1))) 5351 return False; 5352 5353 if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth)) 5354 return False; 5355 5356 if(!prs_uint32("padding_2", ps, depth, &usr->padding_2)) 5357 return False; 5358 5359 if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1)) 5360 return False; 5361 if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3))) 5362 return False; 5363 5364 if(!prs_uint32("padding_4", ps, depth, &usr->padding_4)) 5365 return False; 5366 5367 if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2)) 5368 return False; 5369 if(!prs_uint32("padding_5", ps, depth, &usr->padding_5)) 5370 return False; 5371 5372 if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3)) 5373 return False; 5374 if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6))) 5375 return False; 5376 5377 if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user)) 5378 return False; 5379 if(!prs_uint32("rid_group", ps, depth, &usr->rid_group)) 5380 return False; 5381 if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl)) 5382 return False; 5383 if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3)) 5384 return False; 5385 if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4)) 5386 return False; 5387 if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5)) 5388 return False; 5389 5390 if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7))) 5391 return False; 5392 5393 if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8))) 5394 return False; 5395 5396 if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth)) 5397 return False; 5398 5399 if(!prs_align(ps)) 5400 return False; 5401 5402 if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9))) 5403 return False; 5404 5405 return True; 5406} 5407 5408/************************************************************************* 5409 init_sam_user_infoa 5410 *************************************************************************/ 5411 5412void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len) 5413{ 5414 DEBUG(10, ("init_sam_user_info24:\n")); 5415 memcpy(usr->pass, newpass, sizeof(usr->pass)); 5416 usr->pw_len = pw_len; 5417} 5418 5419/******************************************************************* 5420reads or writes a structure. 5421********************************************************************/ 5422 5423static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr, 5424 prs_struct *ps, int depth) 5425{ 5426 if (usr == NULL) 5427 return False; 5428 5429 prs_debug(ps, depth, desc, "sam_io_user_info24"); 5430 depth++; 5431 5432 if(!prs_align(ps)) 5433 return False; 5434 5435 if(!prs_uint8s(False, "password", ps, depth, usr->pass, 5436 sizeof(usr->pass))) 5437 return False; 5438 5439 if (MARSHALLING(ps) && (usr->pw_len != 0)) { 5440 if (!prs_uint16("pw_len", ps, depth, &usr->pw_len)) 5441 return False; 5442 } 5443 if(!prs_align(ps)) 5444 return False; 5445 5446 return True; 5447} 5448 5449/************************************************************************* 5450 init_sam_user_info23 5451 5452 unknown_6 = 0x0000 04ec 5453 5454 *************************************************************************/ 5455 5456void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */ 5457 NTTIME * logoff_time, /* all zeros */ 5458 NTTIME * kickoff_time, /* all zeros */ 5459 NTTIME * pass_last_set_time, /* all zeros */ 5460 NTTIME * pass_can_change_time, /* all zeros */ 5461 NTTIME * pass_must_change_time, /* all zeros */ 5462 UNISTR2 *user_name, 5463 UNISTR2 *full_name, 5464 UNISTR2 *home_dir, 5465 UNISTR2 *dir_drive, 5466 UNISTR2 *log_scr, 5467 UNISTR2 *prof_path, 5468 UNISTR2 *desc, 5469 UNISTR2 *wkstas, 5470 UNISTR2 *unk_str, 5471 UNISTR2 *mung_dial, 5472 uint32 user_rid, /* 0x0000 0000 */ 5473 uint32 group_rid, 5474 uint32 acb_info, 5475 uint32 fields_present, 5476 uint16 logon_divs, 5477 LOGON_HRS * hrs, 5478 uint16 bad_password_count, 5479 uint16 logon_count, 5480 char newpass[516]) 5481{ 5482 usr->logon_time = *logon_time; /* all zeros */ 5483 usr->logoff_time = *logoff_time; /* all zeros */ 5484 usr->kickoff_time = *kickoff_time; /* all zeros */ 5485 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */ 5486 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */ 5487 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */ 5488 5489 ZERO_STRUCT(usr->nt_pwd); 5490 ZERO_STRUCT(usr->lm_pwd); 5491 5492 usr->user_rid = user_rid; /* 0x0000 0000 */ 5493 usr->group_rid = group_rid; 5494 usr->acb_info = acb_info; 5495 usr->fields_present = fields_present; /* 09f8 27fa */ 5496 5497 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ 5498 usr->ptr_logon_hrs = hrs ? 1 : 0; 5499 5500 if (nt_time_is_zero(pass_must_change_time)) { 5501 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; 5502 } else { 5503 usr->passmustchange=0; 5504 } 5505 5506 ZERO_STRUCT(usr->padding1); 5507 ZERO_STRUCT(usr->padding2); 5508 5509 usr->bad_password_count = bad_password_count; 5510 usr->logon_count = logon_count; 5511 5512 memcpy(usr->pass, newpass, sizeof(usr->pass)); 5513 5514 copy_unistr2(&usr->uni_user_name, user_name); 5515 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name); 5516 5517 copy_unistr2(&usr->uni_full_name, full_name); 5518 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name); 5519 5520 copy_unistr2(&usr->uni_home_dir, home_dir); 5521 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir); 5522 5523 copy_unistr2(&usr->uni_dir_drive, dir_drive); 5524 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive); 5525 5526 copy_unistr2(&usr->uni_logon_script, log_scr); 5527 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script); 5528 5529 copy_unistr2(&usr->uni_profile_path, prof_path); 5530 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path); 5531 5532 copy_unistr2(&usr->uni_acct_desc, desc); 5533 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc); 5534 5535 copy_unistr2(&usr->uni_workstations, wkstas); 5536 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations); 5537 5538 copy_unistr2(&usr->uni_unknown_str, unk_str); 5539 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str); 5540 5541 copy_unistr2(&usr->uni_munged_dial, mung_dial); 5542 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); 5543 5544 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); 5545} 5546 5547/************************************************************************* 5548 init_sam_user_info23 5549 5550 unknown_6 = 0x0000 04ec 5551 5552 *************************************************************************/ 5553 5554void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */ 5555 NTTIME * logoff_time, /* all zeros */ 5556 NTTIME * kickoff_time, /* all zeros */ 5557 NTTIME * pass_last_set_time, /* all zeros */ 5558 NTTIME * pass_can_change_time, /* all zeros */ 5559 NTTIME * pass_must_change_time, /* all zeros */ 5560 char *user_name, /* NULL */ 5561 char *full_name, 5562 char *home_dir, char *dir_drive, char *log_scr, 5563 char *prof_path, const char *desc, char *wkstas, 5564 char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */ 5565 uint32 group_rid, uint32 acb_info, 5566 uint32 fields_present, uint16 logon_divs, 5567 LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count, 5568 char newpass[516]) 5569{ 5570 DATA_BLOB blob = base64_decode_data_blob(mung_dial); 5571 5572 usr->logon_time = *logon_time; /* all zeros */ 5573 usr->logoff_time = *logoff_time; /* all zeros */ 5574 usr->kickoff_time = *kickoff_time; /* all zeros */ 5575 usr->pass_last_set_time = *pass_last_set_time; /* all zeros */ 5576 usr->pass_can_change_time = *pass_can_change_time; /* all zeros */ 5577 usr->pass_must_change_time = *pass_must_change_time; /* all zeros */ 5578 5579 ZERO_STRUCT(usr->nt_pwd); 5580 ZERO_STRUCT(usr->lm_pwd); 5581 5582 usr->user_rid = user_rid; /* 0x0000 0000 */ 5583 usr->group_rid = group_rid; 5584 usr->acb_info = acb_info; 5585 usr->fields_present = fields_present; /* 09f8 27fa */ 5586 5587 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ 5588 usr->ptr_logon_hrs = hrs ? 1 : 0; 5589 5590 if (nt_time_is_zero(pass_must_change_time)) { 5591 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; 5592 } else { 5593 usr->passmustchange=0; 5594 } 5595 5596 ZERO_STRUCT(usr->padding1); 5597 ZERO_STRUCT(usr->padding2); 5598 5599 usr->bad_password_count = bad_password_count; 5600 usr->logon_count = logon_count; 5601 5602 memcpy(usr->pass, newpass, sizeof(usr->pass)); 5603 5604 init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE); 5605 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name); 5606 5607 init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE); 5608 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name); 5609 5610 init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE); 5611 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir); 5612 5613 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE); 5614 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive); 5615 5616 init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE); 5617 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script); 5618 5619 init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE); 5620 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path); 5621 5622 init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE); 5623 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc); 5624 5625 init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE); 5626 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations); 5627 5628 init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE); 5629 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str); 5630 5631 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob); 5632 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); 5633 5634 data_blob_free(&blob); 5635 5636 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); 5637} 5638 5639/******************************************************************* 5640reads or writes a structure. 5641********************************************************************/ 5642 5643static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr, 5644 prs_struct *ps, int depth) 5645{ 5646 if (usr == NULL) 5647 return False; 5648 5649 prs_debug(ps, depth, desc, "sam_io_user_info23"); 5650 depth++; 5651 5652 if(!prs_align(ps)) 5653 return False; 5654 5655 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) 5656 return False; 5657 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) 5658 return False; 5659 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) 5660 return False; 5661 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth)) 5662 return False; 5663 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth)) 5664 return False; 5665 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) 5666 return False; 5667 5668 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ 5669 return False; 5670 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ 5671 return False; 5672 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ 5673 return False; 5674 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ 5675 return False; 5676 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ 5677 return False; 5678 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ 5679 return False; 5680 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ 5681 return False; 5682 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ 5683 return False; 5684 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ 5685 return False; 5686 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ 5687 return False; 5688 5689 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) 5690 return False; 5691 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) 5692 return False; 5693 5694 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ 5695 return False; 5696 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ 5697 return False; 5698 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) 5699 return False; 5700 5701 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present)) 5702 return False; 5703 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */ 5704 return False; 5705 if(!prs_align(ps)) 5706 return False; 5707 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs)) 5708 return False; 5709 5710 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count)) 5711 return False; 5712 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) 5713 return False; 5714 5715 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1))) 5716 return False; 5717 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange)) 5718 return False; 5719 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2)) 5720 return False; 5721 5722 5723 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass))) 5724 return False; 5725 5726 /* here begins pointed-to data */ 5727 5728 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ 5729 return False; 5730 5731 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ 5732 return False; 5733 5734 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ 5735 return False; 5736 5737 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ 5738 return False; 5739 5740 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ 5741 return False; 5742 5743 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ 5744 return False; 5745 5746 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ 5747 return False; 5748 5749 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ 5750 return False; 5751 5752 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ 5753 return False; 5754 5755 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth)) 5756 return False; 5757 5758 /* ok, this is only guess-work (as usual) */ 5759 if (usr->ptr_logon_hrs) { 5760 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) 5761 return False; 5762 } 5763 5764 return True; 5765} 5766 5767/******************************************************************* 5768 reads or writes a structure. 5769 NB. This structure is *definately* incorrect. It's my best guess 5770 currently for W2K SP2. The password field is encrypted in a different 5771 way than normal... And there are definately other problems. JRA. 5772********************************************************************/ 5773 5774static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth) 5775{ 5776 if (usr == NULL) 5777 return False; 5778 5779 prs_debug(ps, depth, desc, "sam_io_user_info25"); 5780 depth++; 5781 5782 if(!prs_align(ps)) 5783 return False; 5784 5785 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) 5786 return False; 5787 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) 5788 return False; 5789 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) 5790 return False; 5791 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth)) 5792 return False; 5793 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth)) 5794 return False; 5795 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) 5796 return False; 5797 5798 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ 5799 return False; 5800 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ 5801 return False; 5802 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ 5803 return False; 5804 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ 5805 return False; 5806 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ 5807 return False; 5808 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ 5809 return False; 5810 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ 5811 return False; 5812 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ 5813 return False; 5814 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ 5815 return False; 5816 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ 5817 return False; 5818 5819 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) 5820 return False; 5821 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) 5822 return False; 5823 5824 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ 5825 return False; 5826 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ 5827 return False; 5828 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) 5829 return False; 5830 5831 if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6)) 5832 return False; 5833 5834 if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass))) 5835 return False; 5836 5837 /* here begins pointed-to data */ 5838 5839 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ 5840 return False; 5841 5842 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ 5843 return False; 5844 5845 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ 5846 return False; 5847 5848 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ 5849 return False; 5850 5851 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ 5852 return False; 5853 5854 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ 5855 return False; 5856 5857 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ 5858 return False; 5859 5860 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ 5861 return False; 5862 5863 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ 5864 return False; 5865 5866 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth)) 5867 return False; 5868 5869#if 0 /* JRA - unknown... */ 5870 /* ok, this is only guess-work (as usual) */ 5871 if (usr->ptr_logon_hrs) { 5872 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) 5873 return False; 5874 } 5875#endif 5876 5877 return True; 5878} 5879 5880 5881/************************************************************************* 5882 init_sam_user_info21W 5883 5884 unknown_6 = 0x0000 04ec 5885 5886 *************************************************************************/ 5887 5888void init_sam_user_info21W(SAM_USER_INFO_21 * usr, 5889 NTTIME * logon_time, 5890 NTTIME * logoff_time, 5891 NTTIME * kickoff_time, 5892 NTTIME * pass_last_set_time, 5893 NTTIME * pass_can_change_time, 5894 NTTIME * pass_must_change_time, 5895 UNISTR2 *user_name, 5896 UNISTR2 *full_name, 5897 UNISTR2 *home_dir, 5898 UNISTR2 *dir_drive, 5899 UNISTR2 *log_scr, 5900 UNISTR2 *prof_path, 5901 UNISTR2 *desc, 5902 UNISTR2 *wkstas, 5903 UNISTR2 *unk_str, 5904 UNISTR2 *mung_dial, 5905 uchar lm_pwd[16], 5906 uchar nt_pwd[16], 5907 uint32 user_rid, 5908 uint32 group_rid, 5909 uint32 acb_info, 5910 uint32 fields_present, 5911 uint16 logon_divs, 5912 LOGON_HRS * hrs, 5913 uint16 bad_password_count, 5914 uint16 logon_count) 5915{ 5916 usr->logon_time = *logon_time; 5917 usr->logoff_time = *logoff_time; 5918 usr->kickoff_time = *kickoff_time; 5919 usr->pass_last_set_time = *pass_last_set_time; 5920 usr->pass_can_change_time = *pass_can_change_time; 5921 usr->pass_must_change_time = *pass_must_change_time; 5922 5923 memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)); 5924 memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)); 5925 5926 usr->user_rid = user_rid; 5927 usr->group_rid = group_rid; 5928 usr->acb_info = acb_info; 5929 usr->fields_present = fields_present; /* 0x00ff ffff */ 5930 5931 usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ 5932 usr->ptr_logon_hrs = hrs ? 1 : 0; 5933 usr->bad_password_count = bad_password_count; 5934 usr->logon_count = logon_count; 5935 5936 if (nt_time_is_zero(pass_must_change_time)) { 5937 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; 5938 } else { 5939 usr->passmustchange=0; 5940 } 5941 5942 ZERO_STRUCT(usr->padding1); 5943 ZERO_STRUCT(usr->padding2); 5944 5945 copy_unistr2(&usr->uni_user_name, user_name); 5946 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name); 5947 5948 copy_unistr2(&usr->uni_full_name, full_name); 5949 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name); 5950 5951 copy_unistr2(&usr->uni_home_dir, home_dir); 5952 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir); 5953 5954 copy_unistr2(&usr->uni_dir_drive, dir_drive); 5955 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive); 5956 5957 copy_unistr2(&usr->uni_logon_script, log_scr); 5958 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script); 5959 5960 copy_unistr2(&usr->uni_profile_path, prof_path); 5961 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path); 5962 5963 copy_unistr2(&usr->uni_acct_desc, desc); 5964 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc); 5965 5966 copy_unistr2(&usr->uni_workstations, wkstas); 5967 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations); 5968 5969 copy_unistr2(&usr->uni_unknown_str, unk_str); 5970 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str); 5971 5972 copy_unistr2(&usr->uni_munged_dial, mung_dial); 5973 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); 5974 5975 memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); 5976} 5977 5978/************************************************************************* 5979 init_sam_user_info21 5980 5981 unknown_6 = 0x0000 04ec 5982 5983 *************************************************************************/ 5984 5985NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid) 5986{ 5987 NTTIME logon_time, logoff_time, kickoff_time, 5988 pass_last_set_time, pass_can_change_time, 5989 pass_must_change_time; 5990 5991 const char* user_name = pdb_get_username(pw); 5992 const char* full_name = pdb_get_fullname(pw); 5993 const char* home_dir = pdb_get_homedir(pw); 5994 const char* dir_drive = pdb_get_dir_drive(pw); 5995 const char* logon_script = pdb_get_logon_script(pw); 5996 const char* profile_path = pdb_get_profile_path(pw); 5997 const char* description = pdb_get_acct_desc(pw); 5998 const char* workstations = pdb_get_workstations(pw); 5999 const char* munged_dial = pdb_get_munged_dial(pw); 6000 DATA_BLOB munged_dial_blob; 6001 6002 uint32 user_rid; 6003 const DOM_SID *user_sid; 6004 6005 uint32 group_rid; 6006 const DOM_SID *group_sid; 6007 6008 if (munged_dial) { 6009 munged_dial_blob = base64_decode_data_blob(munged_dial); 6010 } else { 6011 munged_dial_blob = data_blob(NULL, 0); 6012 } 6013 6014 /* Create NTTIME structs */ 6015 unix_to_nt_time (&logon_time, pdb_get_logon_time(pw)); 6016 unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw)); 6017 unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw)); 6018 unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw)); 6019 unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw)); 6020 unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw)); 6021 6022 /* structure assignment */ 6023 usr->logon_time = logon_time; 6024 usr->logoff_time = logoff_time; 6025 usr->kickoff_time = kickoff_time; 6026 usr->pass_last_set_time = pass_last_set_time; 6027 usr->pass_can_change_time = pass_can_change_time; 6028 usr->pass_must_change_time = pass_must_change_time; 6029 6030 ZERO_STRUCT(usr->nt_pwd); 6031 ZERO_STRUCT(usr->lm_pwd); 6032 6033 user_sid = pdb_get_user_sid(pw); 6034 6035 if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { 6036 fstring user_sid_string; 6037 fstring domain_sid_string; 6038 DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with " 6039 "the domain sid %s. Failing operation.\n", 6040 user_name, 6041 sid_to_string(user_sid_string, user_sid), 6042 sid_to_string(domain_sid_string, domain_sid))); 6043 data_blob_free(&munged_dial_blob); 6044 return NT_STATUS_UNSUCCESSFUL; 6045 } 6046 6047 group_sid = pdb_get_group_sid(pw); 6048 6049 if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) { 6050 fstring group_sid_string; 6051 fstring domain_sid_string; 6052 DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n" 6053 "which conflicts with the domain sid %s. Failing operation.\n", 6054 user_name, 6055 sid_to_string(group_sid_string, group_sid), 6056 sid_to_string(domain_sid_string, domain_sid))); 6057 data_blob_free(&munged_dial_blob); 6058 return NT_STATUS_UNSUCCESSFUL; 6059 } 6060 6061 usr->user_rid = user_rid; 6062 usr->group_rid = group_rid; 6063 usr->acb_info = pdb_get_acct_ctrl(pw); 6064 6065 /* 6066 Look at a user on a real NT4 PDC with usrmgr, press 6067 'ok'. Then you will see that fields_present is set to 6068 0x08f827fa. Look at the user immediately after that again, 6069 and you will see that 0x00fffff is returned. This solves 6070 the problem that you get access denied after having looked 6071 at the user. 6072 -- Volker 6073 */ 6074 usr->fields_present = pdb_build_fields_present(pw); 6075 6076 usr->logon_divs = pdb_get_logon_divs(pw); 6077 usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0; 6078 usr->bad_password_count = pdb_get_bad_password_count(pw); 6079 usr->logon_count = pdb_get_logon_count(pw); 6080 6081 if (pdb_get_pass_must_change_time(pw) == 0) { 6082 usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; 6083 } else { 6084 usr->passmustchange=0; 6085 } 6086 6087 ZERO_STRUCT(usr->padding1); 6088 ZERO_STRUCT(usr->padding2); 6089 6090 init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE); 6091 init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name); 6092 6093 init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE); 6094 init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name); 6095 6096 init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE); 6097 init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir); 6098 6099 init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE); 6100 init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive); 6101 6102 init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE); 6103 init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script); 6104 6105 init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE); 6106 init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path); 6107 6108 init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE); 6109 init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc); 6110 6111 init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE); 6112 init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations); 6113 6114 init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE); 6115 init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str); 6116 6117 init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob); 6118 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); 6119 data_blob_free(&munged_dial_blob); 6120 6121 if (pdb_get_hours(pw)) { 6122 usr->logon_hrs.max_len = 1260; 6123 usr->logon_hrs.offset = 0; 6124 usr->logon_hrs.len = pdb_get_hours_len(pw); 6125 memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN); 6126 } else { 6127 usr->logon_hrs.max_len = 1260; 6128 usr->logon_hrs.offset = 0; 6129 usr->logon_hrs.len = 0; 6130 memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs)); 6131 } 6132 6133 return NT_STATUS_OK; 6134} 6135 6136/******************************************************************* 6137reads or writes a structure. 6138********************************************************************/ 6139 6140static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr, 6141 prs_struct *ps, int depth) 6142{ 6143 if (usr == NULL) 6144 return False; 6145 6146 prs_debug(ps, depth, desc, "sam_io_user_info21"); 6147 depth++; 6148 6149 if(!prs_align(ps)) 6150 return False; 6151 6152 if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) 6153 return False; 6154 if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) 6155 return False; 6156 if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth)) 6157 return False; 6158 if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) 6159 return False; 6160 if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth)) 6161 return False; 6162 if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) 6163 return False; 6164 6165 if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ 6166 return False; 6167 if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ 6168 return False; 6169 if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ 6170 return False; 6171 if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ 6172 return False; 6173 if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ 6174 return False; 6175 if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ 6176 return False; 6177 if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ 6178 return False; 6179 if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ 6180 return False; 6181 if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ 6182 return False; 6183 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ 6184 return False; 6185 6186 if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) 6187 return False; 6188 if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) 6189 return False; 6190 6191 if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ 6192 return False; 6193 if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ 6194 return False; 6195 if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) 6196 return False; 6197 6198 if(!prs_uint32("fields_present ", ps, depth, &usr->fields_present)) 6199 return False; 6200 if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */ 6201 return False; 6202 if(!prs_align(ps)) 6203 return False; 6204 if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs)) 6205 return False; 6206 6207 if(!prs_uint16("bad_password_count ", ps, depth, &usr->bad_password_count)) 6208 return False; 6209 if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) 6210 return False; 6211 6212 if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1))) 6213 return False; 6214 if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange)) 6215 return False; 6216 if(!prs_uint8("padding2 ", ps, depth, &usr->padding2)) 6217 return False; 6218 6219 /* here begins pointed-to data */ 6220 6221 if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ 6222 return False; 6223 if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ 6224 return False; 6225 if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ 6226 return False; 6227 if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ 6228 return False; 6229 if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ 6230 return False; 6231 if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ 6232 return False; 6233 if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ 6234 return False; 6235 if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ 6236 return False; 6237 if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ 6238 return False; 6239 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */ 6240 return False; 6241 6242 /* ok, this is only guess-work (as usual) */ 6243 if (usr->ptr_logon_hrs) { 6244 if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) 6245 return False; 6246 } 6247 6248 return True; 6249} 6250 6251void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw) 6252{ 6253 const char *munged_dial = pdb_get_munged_dial(pw); 6254 DATA_BLOB blob = base64_decode_data_blob(munged_dial); 6255 6256 init_unistr2_from_datablob(&usr->uni_munged_dial, &blob); 6257 init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); 6258 data_blob_free(&blob); 6259} 6260 6261/******************************************************************* 6262reads or writes a structure. 6263********************************************************************/ 6264 6265static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr, 6266 prs_struct *ps, int depth) 6267{ 6268 if (usr == NULL) 6269 return False; 6270 6271 prs_debug(ps, depth, desc, "sam_io_user_info20"); 6272 depth++; 6273 6274 if(!prs_align(ps)) 6275 return False; 6276 6277 if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ 6278 return False; 6279 6280 if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */ 6281 return False; 6282 6283 return True; 6284} 6285 6286/******************************************************************* 6287inits a SAM_USERINFO_CTR structure. 6288********************************************************************/ 6289 6290NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr, 6291 uint16 switch_value, 6292 SAM_USER_INFO_21 * usr) 6293{ 6294 DEBUG(5, ("make_samr_userinfo_ctr_usr21\n")); 6295 6296 ctr->switch_value = switch_value; 6297 ctr->info.id = NULL; 6298 6299 switch (switch_value) { 6300 case 0x10: 6301 ctr->info.id10 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_10); 6302 if (ctr->info.id10 == NULL) 6303 return NT_STATUS_NO_MEMORY; 6304 6305 init_sam_user_info10(ctr->info.id10, usr->acb_info); 6306 break; 6307#if 0 6308/* whoops - got this wrong. i think. or don't understand what's happening. */ 6309 case 0x11: 6310 { 6311 NTTIME expire; 6312 info = (void *)&id11; 6313 6314 expire.low = 0xffffffff; 6315 expire.high = 0x7fffffff; 6316 6317 ctr->info.id = TALLOC_ZERO_P(ctx,SAM_USER_INFO_11); 6318 init_sam_user_info11(ctr->info.id11, &expire, 6319 "BROOKFIELDS$", /* name */ 6320 0x03ef, /* user rid */ 6321 0x201, /* group rid */ 6322 0x0080); /* acb info */ 6323 6324 break; 6325 } 6326#endif 6327 case 0x12: 6328 ctr->info.id12 = TALLOC_ZERO_P(ctx,SAM_USER_INFO_12); 6329 if (ctr->info.id12 == NULL) 6330 return NT_STATUS_NO_MEMORY; 6331 6332 init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd); 6333 break; 6334 case 21: 6335 { 6336 SAM_USER_INFO_21 *cusr; 6337 cusr = TALLOC_ZERO_P(ctx,SAM_USER_INFO_21); 6338 ctr->info.id21 = cusr; 6339 if (ctr->info.id21 == NULL) 6340 return NT_STATUS_NO_MEMORY; 6341 memcpy(cusr, usr, sizeof(*usr)); 6342 memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd)); 6343 memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd)); 6344 break; 6345 } 6346 default: 6347 DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n")); 6348 return NT_STATUS_INVALID_INFO_CLASS; 6349 } 6350 6351 return NT_STATUS_OK; 6352} 6353 6354/******************************************************************* 6355inits a SAM_USERINFO_CTR structure. 6356********************************************************************/ 6357 6358static void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, DATA_BLOB *sess_key, 6359 uint16 switch_value, void *info) 6360{ 6361 DEBUG(5, ("init_samr_userinfo_ctr\n")); 6362 6363 ctr->switch_value = switch_value; 6364 ctr->info.id = info; 6365 6366 switch (switch_value) { 6367 case 0x18: 6368 SamOEMhashBlob(ctr->info.id24->pass, 516, sess_key); 6369 dump_data(100, (char *)sess_key->data, sess_key->length); 6370 dump_data(100, (char *)ctr->info.id24->pass, 516); 6371 break; 6372 case 0x17: 6373 SamOEMhashBlob(ctr->info.id23->pass, 516, sess_key); 6374 dump_data(100, (char *)sess_key->data, sess_key->length); 6375 dump_data(100, (char *)ctr->info.id23->pass, 516); 6376 break; 6377 case 0x07: 6378 break; 6379 default: 6380 DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level: %d\n", switch_value)); 6381 } 6382} 6383 6384/******************************************************************* 6385reads or writes a structure. 6386********************************************************************/ 6387 6388static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr, 6389 prs_struct *ps, int depth) 6390{ 6391 BOOL ret; 6392 SAM_USERINFO_CTR *ctr; 6393 6394 prs_debug(ps, depth, desc, "samr_io_userinfo_ctr"); 6395 depth++; 6396 6397 if (UNMARSHALLING(ps)) { 6398 ctr = PRS_ALLOC_MEM(ps,SAM_USERINFO_CTR,1); 6399 if (ctr == NULL) 6400 return False; 6401 *ppctr = ctr; 6402 } else { 6403 ctr = *ppctr; 6404 } 6405 6406 /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */ 6407 6408 if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value)) 6409 return False; 6410 if(!prs_align(ps)) 6411 return False; 6412 6413 ret = False; 6414 6415 switch (ctr->switch_value) { 6416 case 0x07: 6417 if (UNMARSHALLING(ps)) 6418 ctr->info.id7 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_7,1); 6419 if (ctr->info.id7 == NULL) { 6420 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6421 return False; 6422 } 6423 ret = sam_io_user_info7("", ctr->info.id7, ps, depth); 6424 break; 6425 case 0x10: 6426 if (UNMARSHALLING(ps)) 6427 ctr->info.id10 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_10,1); 6428 if (ctr->info.id10 == NULL) { 6429 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6430 return False; 6431 } 6432 ret = sam_io_user_info10("", ctr->info.id10, ps, depth); 6433 break; 6434 case 0x11: 6435 if (UNMARSHALLING(ps)) 6436 ctr->info.id11 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_11,1); 6437 6438 if (ctr->info.id11 == NULL) { 6439 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6440 return False; 6441 } 6442 ret = sam_io_user_info11("", ctr->info.id11, ps, depth); 6443 break; 6444 case 0x12: 6445 if (UNMARSHALLING(ps)) 6446 ctr->info.id12 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_12,1); 6447 6448 if (ctr->info.id12 == NULL) { 6449 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6450 return False; 6451 } 6452 ret = sam_io_user_info12("", ctr->info.id12, ps, depth); 6453 break; 6454 case 20: 6455 if (UNMARSHALLING(ps)) 6456 ctr->info.id20 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_20,1); 6457 6458 if (ctr->info.id20 == NULL) { 6459 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6460 return False; 6461 } 6462 ret = sam_io_user_info20("", ctr->info.id20, ps, depth); 6463 break; 6464 case 21: 6465 if (UNMARSHALLING(ps)) 6466 ctr->info.id21 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_21,1); 6467 6468 if (ctr->info.id21 == NULL) { 6469 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6470 return False; 6471 } 6472 ret = sam_io_user_info21("", ctr->info.id21, ps, depth); 6473 break; 6474 case 23: 6475 if (UNMARSHALLING(ps)) 6476 ctr->info.id23 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_23,1); 6477 6478 if (ctr->info.id23 == NULL) { 6479 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6480 return False; 6481 } 6482 ret = sam_io_user_info23("", ctr->info.id23, ps, depth); 6483 break; 6484 case 24: 6485 if (UNMARSHALLING(ps)) 6486 ctr->info.id24 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_24,1); 6487 6488 if (ctr->info.id24 == NULL) { 6489 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6490 return False; 6491 } 6492 ret = sam_io_user_info24("", ctr->info.id24, ps, depth); 6493 break; 6494 case 25: 6495 if (UNMARSHALLING(ps)) 6496 ctr->info.id25 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_25,1); 6497 6498 if (ctr->info.id25 == NULL) { 6499 DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); 6500 return False; 6501 } 6502 ret = sam_io_user_info25("", ctr->info.id25, ps, depth); 6503 break; 6504 default: 6505 DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value)); 6506 ret = False; 6507 break; 6508 } 6509 6510 return ret; 6511} 6512 6513/******************************************************************* 6514inits a SAMR_R_QUERY_USERINFO structure. 6515********************************************************************/ 6516 6517void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u, 6518 SAM_USERINFO_CTR * ctr, NTSTATUS status) 6519{ 6520 DEBUG(5, ("init_samr_r_query_userinfo\n")); 6521 6522 r_u->ptr = 0; 6523 r_u->ctr = NULL; 6524 6525 if (NT_STATUS_IS_OK(status)) { 6526 r_u->ptr = 1; 6527 r_u->ctr = ctr; 6528 } 6529 6530 r_u->status = status; /* return status */ 6531} 6532 6533/******************************************************************* 6534reads or writes a structure. 6535********************************************************************/ 6536 6537BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u, 6538 prs_struct *ps, int depth) 6539{ 6540 if (r_u == NULL) 6541 return False; 6542 6543 prs_debug(ps, depth, desc, "samr_io_r_query_userinfo"); 6544 depth++; 6545 6546 if(!prs_align(ps)) 6547 return False; 6548 6549 if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) 6550 return False; 6551 6552 if (r_u->ptr != 0) { 6553 if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth)) 6554 return False; 6555 } 6556 6557 if(!prs_align(ps)) 6558 return False; 6559 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6560 return False; 6561 6562 return True; 6563} 6564 6565/******************************************************************* 6566inits a SAMR_Q_SET_USERINFO structure. 6567********************************************************************/ 6568 6569void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u, 6570 POLICY_HND *hnd, DATA_BLOB *sess_key, 6571 uint16 switch_value, void *info) 6572{ 6573 DEBUG(5, ("init_samr_q_set_userinfo\n")); 6574 6575 q_u->pol = *hnd; 6576 q_u->switch_value = switch_value; 6577 init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info); 6578} 6579 6580/******************************************************************* 6581reads or writes a structure. 6582********************************************************************/ 6583 6584BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u, 6585 prs_struct *ps, int depth) 6586{ 6587 if (q_u == NULL) 6588 return False; 6589 6590 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo"); 6591 depth++; 6592 6593 if(!prs_align(ps)) 6594 return False; 6595 6596 smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); 6597 6598 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) 6599 return False; 6600 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth)) 6601 return False; 6602 6603 return True; 6604} 6605 6606/******************************************************************* 6607inits a SAMR_R_SET_USERINFO structure. 6608********************************************************************/ 6609 6610void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status) 6611{ 6612 DEBUG(5, ("init_samr_r_set_userinfo\n")); 6613 6614 r_u->status = status; /* return status */ 6615} 6616 6617/******************************************************************* 6618reads or writes a structure. 6619********************************************************************/ 6620 6621BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u, 6622 prs_struct *ps, int depth) 6623{ 6624 if (r_u == NULL) 6625 return False; 6626 6627 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo"); 6628 depth++; 6629 6630 if(!prs_align(ps)) 6631 return False; 6632 6633 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6634 return False; 6635 6636 return True; 6637} 6638 6639/******************************************************************* 6640inits a SAMR_Q_SET_USERINFO2 structure. 6641********************************************************************/ 6642 6643void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u, 6644 POLICY_HND *hnd, DATA_BLOB *sess_key, 6645 uint16 switch_value, SAM_USERINFO_CTR * ctr) 6646{ 6647 DEBUG(5, ("init_samr_q_set_userinfo2\n")); 6648 6649 q_u->pol = *hnd; 6650 q_u->switch_value = switch_value; 6651 q_u->ctr = ctr; 6652 6653 if (q_u->ctr != NULL) 6654 q_u->ctr->switch_value = switch_value; 6655 6656 switch (switch_value) { 6657 case 0x12: 6658 SamOEMhashBlob(ctr->info.id12->lm_pwd, 16, sess_key); 6659 SamOEMhashBlob(ctr->info.id12->nt_pwd, 16, sess_key); 6660 dump_data(100, (char *)sess_key->data, sess_key->length); 6661 dump_data(100, (char *)ctr->info.id12->lm_pwd, 16); 6662 dump_data(100, (char *)ctr->info.id12->nt_pwd, 16); 6663 break; 6664 } 6665} 6666 6667/******************************************************************* 6668reads or writes a structure. 6669********************************************************************/ 6670 6671BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u, 6672 prs_struct *ps, int depth) 6673{ 6674 if (q_u == NULL) 6675 return False; 6676 6677 prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2"); 6678 depth++; 6679 6680 if(!prs_align(ps)) 6681 return False; 6682 6683 if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) 6684 return False; 6685 6686 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) 6687 return False; 6688 if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth)) 6689 return False; 6690 6691 return True; 6692} 6693 6694/******************************************************************* 6695inits a SAMR_R_SET_USERINFO2 structure. 6696********************************************************************/ 6697 6698void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status) 6699{ 6700 DEBUG(5, ("init_samr_r_set_userinfo2\n")); 6701 6702 r_u->status = status; /* return status */ 6703} 6704 6705/******************************************************************* 6706reads or writes a structure. 6707********************************************************************/ 6708 6709BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u, 6710 prs_struct *ps, int depth) 6711{ 6712 if (r_u == NULL) 6713 return False; 6714 6715 prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2"); 6716 depth++; 6717 6718 if(!prs_align(ps)) 6719 return False; 6720 6721 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6722 return False; 6723 6724 return True; 6725} 6726 6727/******************************************************************* 6728inits a SAMR_Q_CONNECT structure. 6729********************************************************************/ 6730 6731void init_samr_q_connect(SAMR_Q_CONNECT * q_u, 6732 char *srv_name, uint32 access_mask) 6733{ 6734 DEBUG(5, ("init_samr_q_connect\n")); 6735 6736 /* make PDC server name \\server */ 6737 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0; 6738 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE); 6739 6740 /* example values: 0x0000 0002 */ 6741 q_u->access_mask = access_mask; 6742} 6743 6744/******************************************************************* 6745reads or writes a structure. 6746********************************************************************/ 6747 6748BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u, 6749 prs_struct *ps, int depth) 6750{ 6751 if (q_u == NULL) 6752 return False; 6753 6754 prs_debug(ps, depth, desc, "samr_io_q_connect"); 6755 depth++; 6756 6757 if(!prs_align(ps)) 6758 return False; 6759 6760 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name)) 6761 return False; 6762 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth)) 6763 return False; 6764 6765 if(!prs_align(ps)) 6766 return False; 6767 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 6768 return False; 6769 6770 return True; 6771} 6772 6773/******************************************************************* 6774reads or writes a structure. 6775********************************************************************/ 6776 6777BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u, 6778 prs_struct *ps, int depth) 6779{ 6780 if (r_u == NULL) 6781 return False; 6782 6783 prs_debug(ps, depth, desc, "samr_io_r_connect"); 6784 depth++; 6785 6786 if(!prs_align(ps)) 6787 return False; 6788 6789 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) 6790 return False; 6791 6792 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6793 return False; 6794 6795 return True; 6796} 6797 6798/******************************************************************* 6799inits a SAMR_Q_CONNECT4 structure. 6800********************************************************************/ 6801 6802void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u, 6803 char *srv_name, uint32 access_mask) 6804{ 6805 DEBUG(5, ("init_samr_q_connect\n")); 6806 6807 /* make PDC server name \\server */ 6808 q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0; 6809 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE); 6810 6811 /* Only value we've seen, possibly an address type ? */ 6812 q_u->unk_0 = 2; 6813 6814 /* example values: 0x0000 0002 */ 6815 q_u->access_mask = access_mask; 6816} 6817 6818/******************************************************************* 6819reads or writes a structure. 6820********************************************************************/ 6821 6822BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u, 6823 prs_struct *ps, int depth) 6824{ 6825 if (q_u == NULL) 6826 return False; 6827 6828 prs_debug(ps, depth, desc, "samr_io_q_connect4"); 6829 depth++; 6830 6831 if(!prs_align(ps)) 6832 return False; 6833 6834 if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name)) 6835 return False; 6836 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth)) 6837 return False; 6838 6839 if(!prs_align(ps)) 6840 return False; 6841 if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0)) 6842 return False; 6843 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 6844 return False; 6845 6846 return True; 6847} 6848 6849/******************************************************************* 6850reads or writes a structure. 6851********************************************************************/ 6852 6853BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u, 6854 prs_struct *ps, int depth) 6855{ 6856 if (r_u == NULL) 6857 return False; 6858 6859 prs_debug(ps, depth, desc, "samr_io_r_connect4"); 6860 depth++; 6861 6862 if(!prs_align(ps)) 6863 return False; 6864 6865 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) 6866 return False; 6867 6868 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6869 return False; 6870 6871 return True; 6872} 6873 6874/******************************************************************* 6875inits a SAMR_Q_CONNECT_ANON structure. 6876********************************************************************/ 6877 6878void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u) 6879{ 6880 DEBUG(5, ("init_samr_q_connect_anon\n")); 6881 6882 q_u->ptr = 1; 6883 q_u->unknown_0 = 0x5c; /* server name (?!!) */ 6884 q_u->unknown_1 = 0x01; 6885 q_u->access_mask = 0x20; 6886} 6887 6888/******************************************************************* 6889reads or writes a structure. 6890********************************************************************/ 6891 6892BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u, 6893 prs_struct *ps, int depth) 6894{ 6895 if (q_u == NULL) 6896 return False; 6897 6898 prs_debug(ps, depth, desc, "samr_io_q_connect_anon"); 6899 depth++; 6900 6901 if(!prs_align(ps)) 6902 return False; 6903 6904 if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) 6905 return False; 6906 if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0)) 6907 return False; 6908 if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1)) 6909 return False; 6910 if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) 6911 return False; 6912 6913 return True; 6914} 6915 6916/******************************************************************* 6917reads or writes a structure. 6918********************************************************************/ 6919 6920BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u, 6921 prs_struct *ps, int depth) 6922{ 6923 if (r_u == NULL) 6924 return False; 6925 6926 prs_debug(ps, depth, desc, "samr_io_r_connect_anon"); 6927 depth++; 6928 6929 if(!prs_align(ps)) 6930 return False; 6931 6932 if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) 6933 return False; 6934 6935 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 6936 return False; 6937 6938 return True; 6939} 6940 6941/******************************************************************* 6942inits a SAMR_Q_GET_DOM_PWINFO structure. 6943********************************************************************/ 6944 6945void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u, 6946 char *srv_name) 6947{ 6948 DEBUG(5, ("init_samr_q_get_dom_pwinfo\n")); 6949 6950 q_u->ptr = 1; 6951 init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE); 6952 init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name); 6953} 6954 6955/******************************************************************* 6956reads or writes a structure. 6957********************************************************************/ 6958 6959BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u, 6960 prs_struct *ps, int depth) 6961{ 6962 if (q_u == NULL) 6963 return False; 6964 6965 prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo"); 6966 depth++; 6967 6968 if(!prs_align(ps)) 6969 return False; 6970 6971 if(!prs_uint32("ptr", ps, depth, &q_u->ptr)) 6972 return False; 6973 if (q_u->ptr != 0) { 6974 if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth)) 6975 return False; 6976 if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth)) 6977 return False; 6978 } 6979 6980 return True; 6981} 6982 6983/******************************************************************* 6984reads or writes a structure. 6985********************************************************************/ 6986 6987BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u, 6988 prs_struct *ps, int depth) 6989{ 6990 if (r_u == NULL) 6991 return False; 6992 6993 prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo"); 6994 depth++; 6995 6996 if(!prs_align(ps)) 6997 return False; 6998 6999 /* 7000 * see the Samba4 IDL for what these actually are. 7001 */ 7002 7003 if(!prs_uint16("unk_0", ps, depth, &r_u->unk_0)) 7004 return False; 7005 if(!prs_align(ps)) 7006 return False; 7007 if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1)) 7008 return False; 7009 7010 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 7011 return False; 7012 7013 return True; 7014} 7015 7016/******************************************************************* 7017make a SAMR_ENC_PASSWD structure. 7018********************************************************************/ 7019 7020void init_enc_passwd(SAMR_ENC_PASSWD * pwd, const char pass[512]) 7021{ 7022 ZERO_STRUCTP(pwd); 7023 7024 if (pass == NULL) { 7025 pwd->ptr = 0; 7026 } else { 7027 pwd->ptr = 1; 7028 memcpy(pwd->pass, pass, sizeof(pwd->pass)); 7029 } 7030} 7031 7032/******************************************************************* 7033reads or writes a SAMR_ENC_PASSWD structure. 7034********************************************************************/ 7035 7036BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd, 7037 prs_struct *ps, int depth) 7038{ 7039 if (pwd == NULL) 7040 return False; 7041 7042 prs_debug(ps, depth, desc, "samr_io_enc_passwd"); 7043 depth++; 7044 7045 if(!prs_align(ps)) 7046 return False; 7047 7048 if(!prs_uint32("ptr", ps, depth, &pwd->ptr)) 7049 return False; 7050 7051 if (pwd->ptr != 0) { 7052 if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass))) 7053 return False; 7054 } 7055 7056 return True; 7057} 7058 7059/******************************************************************* 7060inits a SAMR_ENC_HASH structure. 7061********************************************************************/ 7062 7063void init_enc_hash(SAMR_ENC_HASH * hsh, const uchar hash[16]) 7064{ 7065 ZERO_STRUCTP(hsh); 7066 7067 if (hash == NULL) { 7068 hsh->ptr = 0; 7069 } else { 7070 hsh->ptr = 1; 7071 memcpy(hsh->hash, hash, sizeof(hsh->hash)); 7072 } 7073} 7074 7075/******************************************************************* 7076reads or writes a SAMR_ENC_HASH structure. 7077********************************************************************/ 7078 7079BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh, 7080 prs_struct *ps, int depth) 7081{ 7082 if (hsh == NULL) 7083 return False; 7084 7085 prs_debug(ps, depth, desc, "samr_io_enc_hash"); 7086 depth++; 7087 7088 if(!prs_align(ps)) 7089 return False; 7090 7091 if(!prs_uint32("ptr ", ps, depth, &hsh->ptr)) 7092 return False; 7093 if (hsh->ptr != 0) { 7094 if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash))) 7095 return False; 7096 } 7097 7098 return True; 7099} 7100 7101/******************************************************************* 7102inits a SAMR_R_GET_DOM_PWINFO structure. 7103********************************************************************/ 7104 7105void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u, 7106 const char *dest_host, const char *user_name, 7107 const char nt_newpass[516], 7108 const uchar nt_oldhash[16], 7109 const char lm_newpass[516], 7110 const uchar lm_oldhash[16]) 7111{ 7112 DEBUG(5, ("init_samr_q_chgpasswd_user\n")); 7113 7114 q_u->ptr_0 = 1; 7115 init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE); 7116 init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host); 7117 7118 init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE); 7119 init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name); 7120 7121 init_enc_passwd(&q_u->nt_newpass, nt_newpass); 7122 init_enc_hash(&q_u->nt_oldhash, nt_oldhash); 7123 7124 q_u->unknown = 0x01; 7125 7126 init_enc_passwd(&q_u->lm_newpass, lm_newpass); 7127 init_enc_hash(&q_u->lm_oldhash, lm_oldhash); 7128} 7129 7130/******************************************************************* 7131reads or writes a structure. 7132********************************************************************/ 7133 7134BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u, 7135 prs_struct *ps, int depth) 7136{ 7137 if (q_u == NULL) 7138 return False; 7139 7140 prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user"); 7141 depth++; 7142 7143 if(!prs_align(ps)) 7144 return False; 7145 7146 if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0)) 7147 return False; 7148 7149 if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth)) 7150 return False; 7151 if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth)) 7152 return False; 7153 7154 if(!prs_align(ps)) 7155 return False; 7156 if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth)) 7157 return False; 7158 if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth)) 7159 return False; 7160 7161 if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth)) 7162 return False; 7163 if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth)) 7164 return False; 7165 7166 if(!prs_uint32("unknown", ps, depth, &q_u->unknown)) 7167 return False; 7168 7169 if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth)) 7170 return False; 7171 if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth)) 7172 return False; 7173 7174 return True; 7175} 7176 7177/******************************************************************* 7178inits a SAMR_R_CHGPASSWD_USER structure. 7179********************************************************************/ 7180 7181void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status) 7182{ 7183 DEBUG(5, ("init_r_chgpasswd_user\n")); 7184 7185 r_u->status = status; 7186} 7187 7188/******************************************************************* 7189reads or writes a structure. 7190********************************************************************/ 7191 7192BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u, 7193 prs_struct *ps, int depth) 7194{ 7195 if (r_u == NULL) 7196 return False; 7197 7198 prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user"); 7199 depth++; 7200 7201 if(!prs_align(ps)) 7202 return False; 7203 7204 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 7205 return False; 7206 7207 return True; 7208} 7209 7210/******************************************************************* 7211reads or writes a structure. 7212********************************************************************/ 7213 7214void init_samr_q_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u, 7215 POLICY_HND *domain_pol, uint16 switch_value) 7216{ 7217 DEBUG(5, ("init_samr_q_unknown_2e\n")); 7218 7219 q_u->domain_pol = *domain_pol; 7220 q_u->switch_value = switch_value; 7221} 7222 7223/******************************************************************* 7224reads or writes a structure. 7225********************************************************************/ 7226 7227BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u, 7228 prs_struct *ps, int depth) 7229{ 7230 if (q_u == NULL) 7231 return False; 7232 7233 prs_debug(ps, depth, desc, "samr_io_q_unknown_2e"); 7234 depth++; 7235 7236 if(!prs_align(ps)) 7237 return False; 7238 7239 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 7240 return False; 7241 7242 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) 7243 return False; 7244 7245 return True; 7246} 7247 7248/******************************************************************* 7249inits a SAMR_R_QUERY_DOMAIN_INFO structure. 7250********************************************************************/ 7251 7252void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u, 7253 uint16 switch_value, SAM_UNK_CTR * ctr, 7254 NTSTATUS status) 7255{ 7256 DEBUG(5, ("init_samr_r_samr_unknown_2e\n")); 7257 7258 r_u->ptr_0 = 0; 7259 r_u->switch_value = 0; 7260 r_u->status = status; /* return status */ 7261 7262 if (NT_STATUS_IS_OK(status)) { 7263 r_u->switch_value = switch_value; 7264 r_u->ptr_0 = 1; 7265 r_u->ctr = ctr; 7266 } 7267} 7268 7269/******************************************************************* 7270reads or writes a structure. 7271********************************************************************/ 7272 7273BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u, 7274 prs_struct *ps, int depth) 7275{ 7276 if (r_u == NULL) 7277 return False; 7278 7279 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e"); 7280 depth++; 7281 7282 if(!prs_align(ps)) 7283 return False; 7284 7285 if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) 7286 return False; 7287 7288 if (r_u->ptr_0 != 0 && r_u->ctr != NULL) { 7289 if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) 7290 return False; 7291 if(!prs_align(ps)) 7292 return False; 7293 7294 switch (r_u->switch_value) { 7295 case 0x0c: 7296 if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth)) 7297 return False; 7298 break; 7299 case 0x07: 7300 if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth)) 7301 return False; 7302 break; 7303 case 0x06: 7304 if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth)) 7305 return False; 7306 break; 7307 case 0x05: 7308 if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth)) 7309 return False; 7310 break; 7311 case 0x03: 7312 if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth)) 7313 return False; 7314 break; 7315 case 0x02: 7316 if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth)) 7317 return False; 7318 break; 7319 case 0x01: 7320 if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth)) 7321 return False; 7322 break; 7323 default: 7324 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n", 7325 r_u->switch_value)); 7326 r_u->status = NT_STATUS_INVALID_INFO_CLASS; 7327 return False; 7328 } 7329 } 7330 7331 if(!prs_align(ps)) 7332 return False; 7333 7334 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 7335 return False; 7336 7337 return True; 7338} 7339 7340 7341/******************************************************************* 7342reads or writes a structure. 7343********************************************************************/ 7344 7345void init_samr_q_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u, 7346 POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr) 7347{ 7348 DEBUG(5, ("init_samr_q_set_domain_info\n")); 7349 7350 q_u->domain_pol = *domain_pol; 7351 q_u->switch_value0 = switch_value; 7352 7353 q_u->switch_value = switch_value; 7354 q_u->ctr = ctr; 7355 7356} 7357 7358/******************************************************************* 7359reads or writes a structure. 7360********************************************************************/ 7361 7362BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u, 7363 prs_struct *ps, int depth) 7364{ 7365 if (q_u == NULL) 7366 return False; 7367 7368 prs_debug(ps, depth, desc, "samr_io_q_set_domain_info"); 7369 depth++; 7370 7371 if(!prs_align(ps)) 7372 return False; 7373 7374 if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) 7375 return False; 7376 7377 if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0)) 7378 return False; 7379 7380 if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) 7381 return False; 7382 7383 if(!prs_align(ps)) 7384 return False; 7385 7386 if ((q_u->ctr = PRS_ALLOC_MEM(ps, SAM_UNK_CTR, 1)) == NULL) 7387 return False; 7388 7389 switch (q_u->switch_value) { 7390 7391 case 0x0c: 7392 if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth)) 7393 return False; 7394 break; 7395 case 0x07: 7396 if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth)) 7397 return False; 7398 break; 7399 case 0x06: 7400 if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth)) 7401 return False; 7402 break; 7403 case 0x05: 7404 if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth)) 7405 return False; 7406 break; 7407 case 0x03: 7408 if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth)) 7409 return False; 7410 break; 7411 case 0x02: 7412 if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth)) 7413 return False; 7414 break; 7415 case 0x01: 7416 if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth)) 7417 return False; 7418 break; 7419 default: 7420 DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n", 7421 q_u->switch_value)); 7422 return False; 7423 } 7424 7425 return True; 7426} 7427 7428/******************************************************************* 7429inits a SAMR_R_QUERY_DOMAIN_INFO structure. 7430********************************************************************/ 7431 7432void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status) 7433{ 7434 DEBUG(5, ("init_samr_r_set_domain_info\n")); 7435 7436 r_u->status = status; /* return status */ 7437} 7438 7439/******************************************************************* 7440reads or writes a structure. 7441********************************************************************/ 7442 7443BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u, 7444 prs_struct *ps, int depth) 7445{ 7446 if (r_u == NULL) 7447 return False; 7448 7449 prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e"); 7450 depth++; 7451 7452 if(!prs_align(ps)) 7453 return False; 7454 7455 if(!prs_ntstatus("status", ps, depth, &r_u->status)) 7456 return False; 7457 7458 return True; 7459} 7460