Changeset 745 for trunk/server/source3/rpcclient/cmd_lsarpc.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/rpcclient/cmd_lsarpc.c
r414 r745 11 11 the Free Software Foundation; either version 3 of the License, or 12 12 (at your option) any later version. 13 13 14 14 This program is distributed in the hope that it will be useful, 15 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17 GNU General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 24 24 #include "rpcclient.h" 25 25 #include "../libcli/auth/libcli_auth.h" 26 #include "../librpc/gen_ndr/cli_lsa.h" 26 #include "../librpc/gen_ndr/ndr_lsa.h" 27 #include "../librpc/gen_ndr/ndr_lsa_c.h" 28 #include "rpc_client/cli_lsarpc.h" 29 #include "rpc_client/init_lsa.h" 30 #include "../libcli/security/security.h" 27 31 28 32 /* useful function to allow entering a name instead of a SID and … … 30 34 static NTSTATUS name_to_sid(struct rpc_pipe_client *cli, 31 35 TALLOC_CTX *mem_ctx, 32 DOM_SID*sid, const char *name)36 struct dom_sid *sid, const char *name) 33 37 { 34 38 struct policy_handle pol; 35 39 enum lsa_SidType *sid_types; 36 NTSTATUS result; 37 DOM_SID *sids; 40 NTSTATUS status, result; 41 struct dom_sid *sids; 42 struct dcerpc_binding_handle *b = cli->binding_handle; 38 43 39 44 /* maybe its a raw SID */ … … 43 48 } 44 49 45 result = rpccli_lsa_open_policy(cli, mem_ctx, True,50 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 46 51 SEC_FLAG_MAXIMUM_ALLOWED, 47 52 &pol); 48 if (!NT_STATUS_IS_OK( result))49 goto done; 50 51 result= rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);52 if (!NT_STATUS_IS_OK( result))53 goto done; 54 55 rpccli_lsa_Close(cli, mem_ctx, &pol);53 if (!NT_STATUS_IS_OK(status)) 54 goto done; 55 56 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types); 57 if (!NT_STATUS_IS_OK(status)) 58 goto done; 59 60 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 56 61 57 62 *sid = sids[0]; 58 63 59 64 done: 60 return result;65 return status; 61 66 } 62 67 … … 153 158 { 154 159 struct policy_handle pol; 155 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;160 NTSTATUS status, result; 156 161 union lsa_PolicyInformation *info = NULL; 162 struct dcerpc_binding_handle *b = cli->binding_handle; 157 163 158 164 uint32 info_class = 3; … … 168 174 switch (info_class) { 169 175 case 12: 170 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,176 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 171 177 SEC_FLAG_MAXIMUM_ALLOWED, 172 178 &pol); 173 179 174 if (!NT_STATUS_IS_OK( result))180 if (!NT_STATUS_IS_OK(status)) 175 181 goto done; 176 177 result = rpccli_lsa_QueryInfoPolicy2(cli, mem_ctx,182 183 status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx, 178 184 &pol, 179 185 info_class, 180 &info); 186 &info, 187 &result); 181 188 break; 182 189 default: 183 result = rpccli_lsa_open_policy(cli, mem_ctx, True,190 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 184 191 SEC_FLAG_MAXIMUM_ALLOWED, 185 192 &pol); 186 193 187 if (!NT_STATUS_IS_OK( result))194 if (!NT_STATUS_IS_OK(status)) 188 195 goto done; 189 190 result = rpccli_lsa_QueryInfoPolicy(cli, mem_ctx,196 197 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 191 198 &pol, 192 199 info_class, 193 &info); 194 } 195 200 &info, 201 &result); 202 } 203 204 if (!NT_STATUS_IS_OK(status)) { 205 goto done; 206 } 207 status = result; 196 208 if (NT_STATUS_IS_OK(result)) { 197 209 display_lsa_query_info(info, info_class); 198 210 } 199 211 200 rpccli_lsa_Close(cli, mem_ctx, &pol);201 202 done: 203 return result;212 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 213 214 done: 215 return status; 204 216 } 205 217 … … 211 223 { 212 224 struct policy_handle pol; 213 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;214 DOM_SID*sids;225 NTSTATUS status, result; 226 struct dom_sid *sids; 215 227 enum lsa_SidType *types; 216 228 int i; 229 struct dcerpc_binding_handle *b = cli->binding_handle; 217 230 218 231 if (argc == 1) { … … 221 234 } 222 235 223 result = rpccli_lsa_open_policy(cli, mem_ctx, True,236 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 224 237 SEC_FLAG_MAXIMUM_ALLOWED, 225 238 &pol); 226 239 227 if (!NT_STATUS_IS_OK( result))228 goto done; 229 230 result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,240 if (!NT_STATUS_IS_OK(status)) 241 goto done; 242 243 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, 231 244 (const char**)(argv + 1), NULL, 1, &sids, &types); 232 245 233 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=246 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 234 247 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 235 248 goto done; 236 249 237 result= NT_STATUS_OK;250 status = NT_STATUS_OK; 238 251 239 252 /* Print results */ … … 246 259 } 247 260 248 rpccli_lsa_Close(cli, mem_ctx, &pol);249 250 done: 251 return result;261 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 262 263 done: 264 return status; 252 265 } 253 266 … … 259 272 { 260 273 struct policy_handle pol; 261 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;262 DOM_SID*sids;274 NTSTATUS status, result; 275 struct dom_sid *sids; 263 276 enum lsa_SidType *types; 264 277 int i, level; 278 struct dcerpc_binding_handle *b = cli->binding_handle; 265 279 266 280 if (argc < 3) { … … 269 283 } 270 284 271 result = rpccli_lsa_open_policy(cli, mem_ctx, True,285 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 272 286 SEC_FLAG_MAXIMUM_ALLOWED, 273 287 &pol); 274 288 275 if (!NT_STATUS_IS_OK( result))289 if (!NT_STATUS_IS_OK(status)) 276 290 goto done; 277 291 278 292 level = atoi(argv[1]); 279 293 280 result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,294 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2, 281 295 (const char**)(argv + 2), NULL, level, &sids, &types); 282 296 283 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=297 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 284 298 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 285 299 goto done; 286 300 287 result= NT_STATUS_OK;301 status = NT_STATUS_OK; 288 302 289 303 /* Print results */ … … 296 310 } 297 311 298 rpccli_lsa_Close(cli, mem_ctx, &pol);299 300 done: 301 return result;312 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 313 314 done: 315 return status; 302 316 } 303 317 … … 306 320 const char **argv) 307 321 { 308 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;322 NTSTATUS status, result; 309 323 310 324 uint32_t num_names; … … 314 328 uint32_t count = 0; 315 329 int i; 330 struct dcerpc_binding_handle *b = cli->binding_handle; 316 331 317 332 if (argc == 1) { … … 330 345 } 331 346 332 result = rpccli_lsa_LookupNames4(cli, mem_ctx,347 status = dcerpc_lsa_LookupNames4(b, mem_ctx, 333 348 num_names, 334 349 names, … … 338 353 &count, 339 354 0, 340 0); 355 0, 356 &result); 357 if (!NT_STATUS_IS_OK(status)) { 358 return status; 359 } 341 360 if (!NT_STATUS_IS_OK(result)) { 342 361 return result; … … 351 370 } 352 371 353 return result;372 return status; 354 373 } 355 374 … … 360 379 { 361 380 struct policy_handle pol; 362 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;363 DOM_SID*sids;381 NTSTATUS status, result; 382 struct dom_sid *sids; 364 383 char **domains; 365 384 char **names; 366 385 enum lsa_SidType *types; 367 386 int i; 387 struct dcerpc_binding_handle *b = cli->binding_handle; 368 388 369 389 if (argc == 1) { … … 372 392 } 373 393 374 result = rpccli_lsa_open_policy(cli, mem_ctx, True,394 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 375 395 SEC_FLAG_MAXIMUM_ALLOWED, 376 396 &pol); 377 397 378 if (!NT_STATUS_IS_OK( result))398 if (!NT_STATUS_IS_OK(status)) 379 399 goto done; 380 400 381 401 /* Convert arguments to sids */ 382 402 383 sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);403 sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, argc - 1); 384 404 385 405 if (!sids) { … … 390 410 for (i = 0; i < argc - 1; i++) 391 411 if (!string_to_sid(&sids[i], argv[i + 1])) { 392 result= NT_STATUS_INVALID_SID;412 status = NT_STATUS_INVALID_SID; 393 413 goto done; 394 414 } … … 396 416 /* Lookup the SIDs */ 397 417 398 result = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,418 status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, 399 419 &domains, &names, &types); 400 420 401 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=421 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 402 422 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 403 423 goto done; 404 424 405 result= NT_STATUS_OK;425 status = NT_STATUS_OK; 406 426 407 427 /* Print results */ … … 416 436 } 417 437 418 rpccli_lsa_Close(cli, mem_ctx, &pol);419 420 done: 421 return result;438 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 439 440 done: 441 return status; 422 442 } 423 443 … … 428 448 int argc, const char **argv) 429 449 { 430 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;450 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result; 431 451 int i; 432 452 struct lsa_SidArray sids; … … 434 454 struct lsa_TransNameArray2 names; 435 455 uint32_t count = 0; 456 struct dcerpc_binding_handle *b = cli->binding_handle; 436 457 437 458 if (argc == 1) { … … 452 473 453 474 for (i = 0; i < sids.num_sids; i++) { 454 sids.sids[ 0].sid = string_sid_talloc(sids.sids, argv[i + 1]);455 if ( !sids.sids[0].sid) {456 result = NT_STATUS_INVALID_SID;475 sids.sids[i].sid = talloc(sids.sids, struct dom_sid); 476 if (sids.sids[i].sid == NULL) { 477 status = NT_STATUS_NO_MEMORY; 457 478 goto done; 458 479 } 480 if (!string_to_sid(sids.sids[i].sid, argv[i+1])) { 481 status = NT_STATUS_INVALID_SID; 482 goto done; 483 } 459 484 } 460 485 461 486 /* Lookup the SIDs */ 462 result = rpccli_lsa_LookupSids3(cli, mem_ctx,487 status = dcerpc_lsa_LookupSids3(b, mem_ctx, 463 488 &sids, 464 489 &domains, … … 467 492 &count, 468 493 0, 469 0); 470 494 0, 495 &result); 496 if (!NT_STATUS_IS_OK(status)) { 497 goto done; 498 } 471 499 if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 472 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 473 goto done; 474 475 result = NT_STATUS_OK; 500 NT_STATUS_V(STATUS_SOME_UNMAPPED)) { 501 status = result; 502 goto done; 503 } 504 505 status = NT_STATUS_OK; 476 506 477 507 /* Print results */ … … 487 517 488 518 done: 489 return result;519 return status; 490 520 } 491 521 … … 498 528 { 499 529 struct policy_handle pol; 500 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;530 NTSTATUS status, result; 501 531 struct lsa_DomainList domain_list; 532 struct dcerpc_binding_handle *b = cli->binding_handle; 502 533 503 534 /* defaults, but may be changed using params */ … … 515 546 } 516 547 517 result = rpccli_lsa_open_policy(cli, mem_ctx, True,548 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 518 549 LSA_POLICY_VIEW_LOCAL_INFORMATION, 519 550 &pol); 520 551 521 if (!NT_STATUS_IS_OK( result))522 goto done; 523 524 result= STATUS_MORE_ENTRIES;525 526 while (NT_STATUS_EQUAL( result, STATUS_MORE_ENTRIES)) {552 if (!NT_STATUS_IS_OK(status)) 553 goto done; 554 555 status = STATUS_MORE_ENTRIES; 556 557 while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { 527 558 528 559 /* Lookup list of trusted domains */ 529 560 530 result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,561 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 531 562 &pol, 532 563 &enum_ctx, 533 564 &domain_list, 534 max_size); 565 max_size, 566 &result); 567 if (!NT_STATUS_IS_OK(status)) { 568 goto done; 569 } 535 570 if (!NT_STATUS_IS_OK(result) && 536 571 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) && 537 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) 572 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { 573 status = result; 538 574 goto done; 575 } 539 576 540 577 /* Print results: list of names and sids returned in this … … 551 588 } 552 589 553 rpccli_lsa_Close(cli, mem_ctx, &pol);554 done: 555 return result;590 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 591 done: 592 return status; 556 593 } 557 594 … … 563 600 { 564 601 struct policy_handle pol; 565 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;602 NTSTATUS status, result; 566 603 struct lsa_PrivArray priv_array; 604 struct dcerpc_binding_handle *b = cli->binding_handle; 567 605 568 606 uint32 enum_context=0; … … 581 619 pref_max_length=atoi(argv[2]); 582 620 583 result = rpccli_lsa_open_policy(cli, mem_ctx, True,621 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 584 622 SEC_FLAG_MAXIMUM_ALLOWED, 585 623 &pol); 586 624 587 if (!NT_STATUS_IS_OK( result))588 goto done; 589 590 result = rpccli_lsa_EnumPrivs(cli, mem_ctx,625 if (!NT_STATUS_IS_OK(status)) 626 goto done; 627 628 status = dcerpc_lsa_EnumPrivs(b, mem_ctx, 591 629 &pol, 592 630 &enum_context, 593 631 &priv_array, 594 pref_max_length); 595 if (!NT_STATUS_IS_OK(result)) 596 goto done; 632 pref_max_length, 633 &result); 634 if (!NT_STATUS_IS_OK(status)) 635 goto done; 636 if (!NT_STATUS_IS_OK(result)) { 637 status = result; 638 goto done; 639 } 597 640 598 641 /* Print results */ … … 608 651 } 609 652 610 rpccli_lsa_Close(cli, mem_ctx, &pol);611 done: 612 return result;653 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 654 done: 655 return status; 613 656 } 614 657 … … 620 663 { 621 664 struct policy_handle pol; 622 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 665 NTSTATUS status, result; 666 struct dcerpc_binding_handle *b = cli->binding_handle; 623 667 624 668 uint16 lang_id=0; … … 633 677 } 634 678 635 result = rpccli_lsa_open_policy(cli, mem_ctx, True,679 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 636 680 SEC_FLAG_MAXIMUM_ALLOWED, 637 681 &pol); 638 682 639 if (!NT_STATUS_IS_OK( result))683 if (!NT_STATUS_IS_OK(status)) 640 684 goto done; 641 685 642 686 init_lsa_String(&lsa_name, argv[1]); 643 687 644 result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,688 status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx, 645 689 &pol, 646 690 &lsa_name, … … 648 692 lang_id_sys, 649 693 &description, 650 &lang_id_desc); 651 652 if (!NT_STATUS_IS_OK(result)) 653 goto done; 694 &lang_id_desc, 695 &result); 696 if (!NT_STATUS_IS_OK(status)) 697 goto done; 698 if (!NT_STATUS_IS_OK(result)) { 699 status = result; 700 goto done; 701 } 654 702 655 703 /* Print results */ 656 704 printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc); 657 705 658 rpccli_lsa_Close(cli, mem_ctx, &pol);659 done: 660 return result;706 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 707 done: 708 return status; 661 709 } 662 710 … … 668 716 { 669 717 struct policy_handle pol; 670 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 718 NTSTATUS status, result; 719 struct dcerpc_binding_handle *b = cli->binding_handle; 671 720 672 721 uint32 enum_context=0; … … 686 735 pref_max_length=atoi(argv[2]); 687 736 688 result = rpccli_lsa_open_policy(cli, mem_ctx, True,737 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 689 738 SEC_FLAG_MAXIMUM_ALLOWED, 690 739 &pol); 691 740 692 if (!NT_STATUS_IS_OK( result))693 goto done; 694 695 result = rpccli_lsa_EnumAccounts(cli, mem_ctx,741 if (!NT_STATUS_IS_OK(status)) 742 goto done; 743 744 status = dcerpc_lsa_EnumAccounts(b, mem_ctx, 696 745 &pol, 697 746 &enum_context, 698 747 &sid_array, 699 pref_max_length); 700 701 if (!NT_STATUS_IS_OK(result)) 702 goto done; 748 pref_max_length, 749 &result); 750 if (!NT_STATUS_IS_OK(status)) 751 goto done; 752 if (!NT_STATUS_IS_OK(result)) { 753 status = result; 754 goto done; 755 } 703 756 704 757 /* Print results */ … … 712 765 } 713 766 714 rpccli_lsa_Close(cli, mem_ctx, &pol);715 done: 716 return result;767 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 768 done: 769 return status; 717 770 } 718 771 … … 725 778 struct policy_handle dom_pol; 726 779 struct policy_handle user_pol; 727 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;780 NTSTATUS status, result; 728 781 uint32 des_access = 0x000f000f; 729 730 DOM_SID sid; 782 struct dcerpc_binding_handle *b = cli->binding_handle; 783 784 struct dom_sid sid; 731 785 732 786 if (argc != 2 ) { … … 735 789 } 736 790 737 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);738 if (!NT_STATUS_IS_OK( result))791 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 792 if (!NT_STATUS_IS_OK(status)) 739 793 goto done; 740 794 741 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,795 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 742 796 SEC_FLAG_MAXIMUM_ALLOWED, 743 797 &dom_pol); 744 798 745 if (!NT_STATUS_IS_OK( result))746 goto done; 747 748 result = rpccli_lsa_CreateAccount(cli, mem_ctx,799 if (!NT_STATUS_IS_OK(status)) 800 goto done; 801 802 status = dcerpc_lsa_CreateAccount(b, mem_ctx, 749 803 &dom_pol, 750 804 &sid, 751 805 des_access, 752 &user_pol); 753 754 if (!NT_STATUS_IS_OK(result)) 755 goto done; 806 &user_pol, 807 &result); 808 if (!NT_STATUS_IS_OK(status)) 809 goto done; 810 if (!NT_STATUS_IS_OK(result)) { 811 status = result; 812 goto done; 813 } 756 814 757 815 printf("Account for SID %s successfully created\n\n", argv[1]); 758 result= NT_STATUS_OK;759 760 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);761 done: 762 return result;816 status = NT_STATUS_OK; 817 818 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 819 done: 820 return status; 763 821 } 764 822 … … 772 830 struct policy_handle dom_pol; 773 831 struct policy_handle user_pol; 774 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;832 NTSTATUS status, result; 775 833 uint32 access_desired = 0x000f000f; 776 DOM_SIDsid;834 struct dom_sid sid; 777 835 struct lsa_PrivilegeSet *privs = NULL; 778 836 int i; 837 struct dcerpc_binding_handle *b = cli->binding_handle; 779 838 780 839 if (argc != 2 ) { … … 783 842 } 784 843 785 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);786 if (!NT_STATUS_IS_OK( result))844 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 845 if (!NT_STATUS_IS_OK(status)) 787 846 goto done; 788 847 789 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,848 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 790 849 SEC_FLAG_MAXIMUM_ALLOWED, 791 850 &dom_pol); 792 851 793 if (!NT_STATUS_IS_OK( result))794 goto done; 795 796 result = rpccli_lsa_OpenAccount(cli, mem_ctx,852 if (!NT_STATUS_IS_OK(status)) 853 goto done; 854 855 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 797 856 &dom_pol, 798 857 &sid, 799 858 access_desired, 800 &user_pol); 801 802 if (!NT_STATUS_IS_OK(result)) 803 goto done; 804 805 result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx, 859 &user_pol, 860 &result); 861 if (!NT_STATUS_IS_OK(status)) 862 goto done; 863 if (!NT_STATUS_IS_OK(result)) { 864 status = result; 865 goto done; 866 } 867 868 status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx, 806 869 &user_pol, 807 &privs); 808 809 if (!NT_STATUS_IS_OK(result)) 810 goto done; 870 &privs, 871 &result); 872 if (!NT_STATUS_IS_OK(status)) 873 goto done; 874 if (!NT_STATUS_IS_OK(result)) { 875 status = result; 876 goto done; 877 } 811 878 812 879 /* Print results */ … … 821 888 } 822 889 823 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);824 done: 825 return result;890 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 891 done: 892 return status; 826 893 } 827 894 … … 834 901 { 835 902 struct policy_handle dom_pol; 836 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;837 DOM_SIDsid;903 NTSTATUS status, result; 904 struct dom_sid sid; 838 905 struct lsa_RightSet rights; 906 struct dcerpc_binding_handle *b = cli->binding_handle; 839 907 840 908 int i; … … 845 913 } 846 914 847 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);848 if (!NT_STATUS_IS_OK( result))915 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 916 if (!NT_STATUS_IS_OK(status)) 849 917 goto done; 850 918 851 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,919 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 852 920 SEC_FLAG_MAXIMUM_ALLOWED, 853 921 &dom_pol); 854 922 855 if (!NT_STATUS_IS_OK( result))856 goto done; 857 858 result = rpccli_lsa_EnumAccountRights(cli, mem_ctx,923 if (!NT_STATUS_IS_OK(status)) 924 goto done; 925 926 status = dcerpc_lsa_EnumAccountRights(b, mem_ctx, 859 927 &dom_pol, 860 928 &sid, 861 &rights); 862 863 if (!NT_STATUS_IS_OK(result)) 864 goto done; 929 &rights, 930 &result); 931 if (!NT_STATUS_IS_OK(status)) 932 goto done; 933 if (!NT_STATUS_IS_OK(result)) { 934 status = result; 935 goto done; 936 } 865 937 866 938 printf("found %d privileges for SID %s\n", rights.count, … … 871 943 } 872 944 873 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);874 done: 875 return result;945 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 946 done: 947 return status; 876 948 } 877 949 … … 884 956 { 885 957 struct policy_handle dom_pol; 886 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;958 NTSTATUS status, result; 887 959 struct lsa_RightSet rights; 888 DOM_SIDsid;960 struct dom_sid sid; 889 961 int i; 962 struct dcerpc_binding_handle *b = cli->binding_handle; 890 963 891 964 if (argc < 3 ) { … … 894 967 } 895 968 896 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);897 if (!NT_STATUS_IS_OK( result))969 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 970 if (!NT_STATUS_IS_OK(status)) 898 971 goto done; 899 972 900 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,973 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 901 974 SEC_FLAG_MAXIMUM_ALLOWED, 902 975 &dom_pol); 903 976 904 if (!NT_STATUS_IS_OK( result))977 if (!NT_STATUS_IS_OK(status)) 905 978 goto done; 906 979 … … 916 989 } 917 990 918 result = rpccli_lsa_AddAccountRights(cli, mem_ctx,991 status = dcerpc_lsa_AddAccountRights(b, mem_ctx, 919 992 &dom_pol, 920 993 &sid, 921 &rights); 922 923 if (!NT_STATUS_IS_OK(result)) 924 goto done; 925 926 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 927 done: 928 return result; 994 &rights, 995 &result); 996 if (!NT_STATUS_IS_OK(status)) 997 goto done; 998 if (!NT_STATUS_IS_OK(result)) { 999 status = result; 1000 goto done; 1001 } 1002 1003 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1004 done: 1005 return status; 929 1006 } 930 1007 … … 937 1014 { 938 1015 struct policy_handle dom_pol; 939 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1016 NTSTATUS status, result; 940 1017 struct lsa_RightSet rights; 941 DOM_SIDsid;1018 struct dom_sid sid; 942 1019 int i; 1020 struct dcerpc_binding_handle *b = cli->binding_handle; 943 1021 944 1022 if (argc < 3 ) { … … 947 1025 } 948 1026 949 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);950 if (!NT_STATUS_IS_OK( result))1027 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1028 if (!NT_STATUS_IS_OK(status)) 951 1029 goto done; 952 1030 953 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1031 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 954 1032 SEC_FLAG_MAXIMUM_ALLOWED, 955 1033 &dom_pol); 956 1034 957 if (!NT_STATUS_IS_OK( result))1035 if (!NT_STATUS_IS_OK(status)) 958 1036 goto done; 959 1037 … … 969 1047 } 970 1048 971 result = rpccli_lsa_RemoveAccountRights(cli, mem_ctx,1049 status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx, 972 1050 &dom_pol, 973 1051 &sid, 974 1052 false, 975 &rights); 976 977 if (!NT_STATUS_IS_OK(result)) 978 goto done; 979 980 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 981 982 done: 983 return result; 1053 &rights, 1054 &result); 1055 if (!NT_STATUS_IS_OK(status)) 1056 goto done; 1057 if (!NT_STATUS_IS_OK(result)) { 1058 status = result; 1059 goto done; 1060 } 1061 1062 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1063 1064 done: 1065 return status; 984 1066 } 985 1067 … … 992 1074 { 993 1075 struct policy_handle pol; 994 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1076 NTSTATUS status, result; 995 1077 struct lsa_LUID luid; 996 1078 struct lsa_String name; 1079 struct dcerpc_binding_handle *b = cli->binding_handle; 997 1080 998 1081 if (argc != 2 ) { … … 1001 1084 } 1002 1085 1003 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1086 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1004 1087 SEC_FLAG_MAXIMUM_ALLOWED, 1005 1088 &pol); 1006 1089 1007 if (!NT_STATUS_IS_OK( result))1090 if (!NT_STATUS_IS_OK(status)) 1008 1091 goto done; 1009 1092 1010 1093 init_lsa_String(&name, argv[1]); 1011 1094 1012 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1095 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1013 1096 &pol, 1014 1097 &name, 1015 &luid); 1016 1017 if (!NT_STATUS_IS_OK(result)) 1018 goto done; 1098 &luid, 1099 &result); 1100 if (!NT_STATUS_IS_OK(status)) 1101 goto done; 1102 if (!NT_STATUS_IS_OK(result)) { 1103 status = result; 1104 goto done; 1105 } 1019 1106 1020 1107 /* Print results */ … … 1022 1109 printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low); 1023 1110 1024 rpccli_lsa_Close(cli, mem_ctx, &pol);1025 done: 1026 return result;1111 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1112 done: 1113 return status; 1027 1114 } 1028 1115 … … 1034 1121 { 1035 1122 struct policy_handle pol; 1036 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 1037 SEC_DESC_BUF *sdb; 1038 uint32 sec_info = DACL_SECURITY_INFORMATION; 1123 NTSTATUS status, result; 1124 struct sec_desc_buf *sdb; 1125 uint32 sec_info = SECINFO_DACL; 1126 struct dcerpc_binding_handle *b = cli->binding_handle; 1039 1127 1040 1128 if (argc < 1 || argc > 2) { … … 1043 1131 } 1044 1132 1045 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1133 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1046 1134 SEC_FLAG_MAXIMUM_ALLOWED, 1047 1135 &pol); … … 1050 1138 sscanf(argv[1], "%x", &sec_info); 1051 1139 1052 if (!NT_STATUS_IS_OK( result))1053 goto done; 1054 1055 result = rpccli_lsa_QuerySecurity(cli, mem_ctx,1140 if (!NT_STATUS_IS_OK(status)) 1141 goto done; 1142 1143 status = dcerpc_lsa_QuerySecurity(b, mem_ctx, 1056 1144 &pol, 1057 1145 sec_info, 1058 &sdb); 1059 if (!NT_STATUS_IS_OK(result)) 1060 goto done; 1146 &sdb, 1147 &result); 1148 if (!NT_STATUS_IS_OK(status)) 1149 goto done; 1150 if (!NT_STATUS_IS_OK(result)) { 1151 status = result; 1152 goto done; 1153 } 1061 1154 1062 1155 /* Print results */ … … 1064 1157 display_sec_desc(sdb->sd); 1065 1158 1066 rpccli_lsa_Close(cli, mem_ctx, &pol);1067 done: 1068 return result;1159 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1160 done: 1161 return status; 1069 1162 } 1070 1163 … … 1073 1166 { 1074 1167 char *pwd, *pwd_old; 1075 1168 1076 1169 DATA_BLOB data = data_blob_const(p->password->data, p->password->length); 1077 1170 DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length); … … 1080 1173 pwd = sess_decrypt_string(talloc_tos(), &data, &session_key_blob); 1081 1174 pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key_blob); 1082 1175 1083 1176 d_printf("Password:\t%s\n", pwd); 1084 1177 d_printf("Old Password:\t%s\n", pwd_old); … … 1115 1208 { 1116 1209 struct policy_handle pol; 1117 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1118 DOM_SIDdom_sid;1210 NTSTATUS status, result; 1211 struct dom_sid dom_sid; 1119 1212 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1120 1213 union lsa_TrustedDomainInfo *info = NULL; 1121 1214 enum lsa_TrustDomInfoEnum info_class = 1; 1122 1215 uint8_t nt_hash[16]; 1216 struct dcerpc_binding_handle *b = cli->binding_handle; 1123 1217 1124 1218 if (argc > 3 || argc < 2) { … … 1133 1227 info_class = atoi(argv[2]); 1134 1228 1135 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1136 1137 if (!NT_STATUS_IS_OK( result))1138 goto done; 1139 1140 result = rpccli_lsa_QueryTrustedDomainInfoBySid(cli, mem_ctx,1229 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1230 1231 if (!NT_STATUS_IS_OK(status)) 1232 goto done; 1233 1234 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx, 1141 1235 &pol, 1142 1236 &dom_sid, 1143 1237 info_class, 1144 &info); 1145 if (!NT_STATUS_IS_OK(result)) 1146 goto done; 1238 &info, 1239 &result); 1240 if (!NT_STATUS_IS_OK(status)) 1241 goto done; 1242 if (!NT_STATUS_IS_OK(result)) { 1243 status = result; 1244 goto done; 1245 } 1147 1246 1148 1247 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1154 1253 1155 1254 done: 1156 rpccli_lsa_Close(cli, mem_ctx, &pol);1157 1158 return result;1255 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1256 1257 return status; 1159 1258 } 1160 1259 … … 1164 1263 { 1165 1264 struct policy_handle pol; 1166 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1265 NTSTATUS status, result; 1167 1266 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1168 1267 union lsa_TrustedDomainInfo *info = NULL; … … 1170 1269 struct lsa_String trusted_domain; 1171 1270 uint8_t nt_hash[16]; 1271 struct dcerpc_binding_handle *b = cli->binding_handle; 1172 1272 1173 1273 if (argc > 3 || argc < 2) { … … 1179 1279 info_class = atoi(argv[2]); 1180 1280 1181 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1182 1183 if (!NT_STATUS_IS_OK( result))1281 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1282 1283 if (!NT_STATUS_IS_OK(status)) 1184 1284 goto done; 1185 1285 1186 1286 init_lsa_String(&trusted_domain, argv[1]); 1187 1287 1188 result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,1288 status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx, 1189 1289 &pol, 1190 1290 &trusted_domain, 1191 1291 info_class, 1192 &info); 1193 if (!NT_STATUS_IS_OK(result)) 1194 goto done; 1292 &info, 1293 &result); 1294 if (!NT_STATUS_IS_OK(status)) 1295 goto done; 1296 if (!NT_STATUS_IS_OK(result)) { 1297 status = result; 1298 goto done; 1299 } 1195 1300 1196 1301 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1202 1307 1203 1308 done: 1204 rpccli_lsa_Close(cli, mem_ctx, &pol);1205 1206 return result;1309 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1310 1311 return status; 1207 1312 } 1208 1313 … … 1212 1317 { 1213 1318 struct policy_handle pol, trustdom_pol; 1214 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1319 NTSTATUS status, result; 1215 1320 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1216 1321 union lsa_TrustedDomainInfo *info = NULL; 1217 DOM_SIDdom_sid;1322 struct dom_sid dom_sid; 1218 1323 enum lsa_TrustDomInfoEnum info_class = 1; 1219 1324 uint8_t nt_hash[16]; 1325 struct dcerpc_binding_handle *b = cli->binding_handle; 1220 1326 1221 1327 if (argc > 3 || argc < 2) { … … 1231 1337 info_class = atoi(argv[2]); 1232 1338 1233 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1234 1235 if (!NT_STATUS_IS_OK( result))1236 goto done; 1237 1238 result = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,1339 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1340 1341 if (!NT_STATUS_IS_OK(status)) 1342 goto done; 1343 1344 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx, 1239 1345 &pol, 1240 1346 &dom_sid, 1241 1347 access_mask, 1242 &trustdom_pol); 1243 1244 if (!NT_STATUS_IS_OK(result)) 1245 goto done; 1246 1247 result = rpccli_lsa_QueryTrustedDomainInfo(cli, mem_ctx, 1348 &trustdom_pol, 1349 &result); 1350 if (!NT_STATUS_IS_OK(status)) 1351 goto done; 1352 if (!NT_STATUS_IS_OK(result)) { 1353 status = result; 1354 goto done; 1355 } 1356 1357 status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx, 1248 1358 &trustdom_pol, 1249 1359 info_class, 1250 &info); 1251 1252 if (!NT_STATUS_IS_OK(result)) 1253 goto done; 1360 &info, 1361 &result); 1362 if (!NT_STATUS_IS_OK(status)) 1363 goto done; 1364 if (!NT_STATUS_IS_OK(result)) { 1365 status = result; 1366 goto done; 1367 } 1254 1368 1255 1369 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1261 1375 1262 1376 done: 1263 rpccli_lsa_Close(cli, mem_ctx, &pol);1264 1265 return result;1377 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1378 1379 return status; 1266 1380 } 1267 1381 … … 1271 1385 { 1272 1386 struct policy_handle pol; 1273 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1387 NTSTATUS status, result; 1274 1388 const char *servername = cli->desthost; 1275 1389 struct lsa_String *account_name = NULL; 1276 1390 struct lsa_String *authority_name = NULL; 1391 struct dcerpc_binding_handle *b = cli->binding_handle; 1277 1392 1278 1393 if (argc > 2) { … … 1281 1396 } 1282 1397 1283 result= rpccli_lsa_open_policy(cli, mem_ctx, true,1398 status = rpccli_lsa_open_policy(cli, mem_ctx, true, 1284 1399 SEC_FLAG_MAXIMUM_ALLOWED, 1285 1400 &pol); 1286 1401 1287 if (!NT_STATUS_IS_OK( result)) {1288 goto done; 1289 } 1290 1291 result = rpccli_lsa_GetUserName(cli, mem_ctx,1402 if (!NT_STATUS_IS_OK(status)) { 1403 goto done; 1404 } 1405 1406 status = dcerpc_lsa_GetUserName(b, mem_ctx, 1292 1407 servername, 1293 1408 &account_name, 1294 &authority_name); 1295 if (!NT_STATUS_IS_OK(result)) { 1409 &authority_name, 1410 &result); 1411 if (!NT_STATUS_IS_OK(status)) { 1412 goto done; 1413 } 1414 if (!NT_STATUS_IS_OK(result)) { 1415 status = result; 1296 1416 goto done; 1297 1417 } … … 1303 1423 ""); 1304 1424 1305 rpccli_lsa_Close(cli, mem_ctx, &pol);1306 done: 1307 return result;1425 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1426 done: 1427 return status; 1308 1428 } 1309 1429 … … 1313 1433 { 1314 1434 struct policy_handle dom_pol, user_pol; 1315 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1435 NTSTATUS status, result; 1316 1436 struct lsa_PrivilegeSet privs; 1317 1437 struct lsa_LUIDAttribute *set = NULL; 1318 DOM_SIDsid;1438 struct dom_sid sid; 1319 1439 int i; 1440 struct dcerpc_binding_handle *b = cli->binding_handle; 1320 1441 1321 1442 ZERO_STRUCT(privs); … … 1326 1447 } 1327 1448 1328 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);1329 if (!NT_STATUS_IS_OK( result)) {1330 goto done; 1331 } 1332 1333 result= rpccli_lsa_open_policy2(cli, mem_ctx, True,1449 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1450 if (!NT_STATUS_IS_OK(status)) { 1451 goto done; 1452 } 1453 1454 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1334 1455 SEC_FLAG_MAXIMUM_ALLOWED, 1335 1456 &dom_pol); 1336 1457 1337 if (!NT_STATUS_IS_OK( result)) {1338 goto done; 1339 } 1340 1341 result = rpccli_lsa_OpenAccount(cli, mem_ctx,1458 if (!NT_STATUS_IS_OK(status)) { 1459 goto done; 1460 } 1461 1462 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 1342 1463 &dom_pol, 1343 1464 &sid, 1344 1465 SEC_FLAG_MAXIMUM_ALLOWED, 1345 &user_pol); 1346 1347 if (!NT_STATUS_IS_OK(result)) { 1466 &user_pol, 1467 &result); 1468 if (!NT_STATUS_IS_OK(status)) { 1469 goto done; 1470 } 1471 if (!NT_STATUS_IS_OK(result)) { 1472 status = result; 1348 1473 goto done; 1349 1474 } … … 1356 1481 init_lsa_String(&priv_name, argv[i]); 1357 1482 1358 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1483 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1359 1484 &dom_pol, 1360 1485 &priv_name, 1361 &luid); 1486 &luid, 1487 &result); 1488 if (!NT_STATUS_IS_OK(status)) { 1489 continue; 1490 } 1362 1491 if (!NT_STATUS_IS_OK(result)) { 1492 status = result; 1363 1493 continue; 1364 1494 } … … 1378 1508 privs.set = set; 1379 1509 1380 result = rpccli_lsa_AddPrivilegesToAccount(cli, mem_ctx,1510 status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx, 1381 1511 &user_pol, 1382 &privs); 1383 1384 if (!NT_STATUS_IS_OK(result)) { 1385 goto done; 1386 } 1387 1388 rpccli_lsa_Close(cli, mem_ctx, &user_pol); 1389 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 1390 done: 1391 return result; 1512 &privs, 1513 &result); 1514 if (!NT_STATUS_IS_OK(status)) { 1515 goto done; 1516 } 1517 if (!NT_STATUS_IS_OK(result)) { 1518 status = result; 1519 goto done; 1520 } 1521 1522 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result); 1523 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1524 done: 1525 return status; 1392 1526 } 1393 1527 … … 1397 1531 { 1398 1532 struct policy_handle dom_pol, user_pol; 1399 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1533 NTSTATUS status, result; 1400 1534 struct lsa_PrivilegeSet privs; 1401 1535 struct lsa_LUIDAttribute *set = NULL; 1402 DOM_SIDsid;1536 struct dom_sid sid; 1403 1537 int i; 1538 struct dcerpc_binding_handle *b = cli->binding_handle; 1404 1539 1405 1540 ZERO_STRUCT(privs); … … 1410 1545 } 1411 1546 1412 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);1413 if (!NT_STATUS_IS_OK( result)) {1414 goto done; 1415 } 1416 1417 result= rpccli_lsa_open_policy2(cli, mem_ctx, True,1547 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1548 if (!NT_STATUS_IS_OK(status)) { 1549 goto done; 1550 } 1551 1552 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1418 1553 SEC_FLAG_MAXIMUM_ALLOWED, 1419 1554 &dom_pol); 1420 1555 1421 if (!NT_STATUS_IS_OK( result)) {1422 goto done; 1423 } 1424 1425 result = rpccli_lsa_OpenAccount(cli, mem_ctx,1556 if (!NT_STATUS_IS_OK(status)) { 1557 goto done; 1558 } 1559 1560 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 1426 1561 &dom_pol, 1427 1562 &sid, 1428 1563 SEC_FLAG_MAXIMUM_ALLOWED, 1429 &user_pol); 1430 1431 if (!NT_STATUS_IS_OK(result)) { 1564 &user_pol, 1565 &result); 1566 if (!NT_STATUS_IS_OK(status)) { 1567 goto done; 1568 } 1569 if (!NT_STATUS_IS_OK(result)) { 1570 status = result; 1432 1571 goto done; 1433 1572 } … … 1440 1579 init_lsa_String(&priv_name, argv[i]); 1441 1580 1442 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1581 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1443 1582 &dom_pol, 1444 1583 &priv_name, 1445 &luid); 1584 &luid, 1585 &result); 1586 if (!NT_STATUS_IS_OK(status)) { 1587 continue; 1588 } 1446 1589 if (!NT_STATUS_IS_OK(result)) { 1590 status = result; 1447 1591 continue; 1448 1592 } … … 1463 1607 1464 1608 1465 result = rpccli_lsa_RemovePrivilegesFromAccount(cli, mem_ctx,1609 status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx, 1466 1610 &user_pol, 1467 1611 false, 1468 &privs); 1469 1470 if (!NT_STATUS_IS_OK(result)) { 1471 goto done; 1472 } 1473 1474 rpccli_lsa_Close(cli, mem_ctx, &user_pol); 1475 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 1476 done: 1477 return result; 1612 &privs, 1613 &result); 1614 if (!NT_STATUS_IS_OK(status)) { 1615 goto done; 1616 } 1617 if (!NT_STATUS_IS_OK(result)) { 1618 status = result; 1619 goto done; 1620 } 1621 1622 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result); 1623 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1624 done: 1625 return status; 1478 1626 } 1479 1627 … … 1482 1630 const char **argv) 1483 1631 { 1484 NTSTATUS status ;1632 NTSTATUS status, result; 1485 1633 struct policy_handle handle, sec_handle; 1486 1634 struct lsa_String name; 1635 struct dcerpc_binding_handle *b = cli->binding_handle; 1487 1636 1488 1637 if (argc < 2) { … … 1501 1650 init_lsa_String(&name, argv[1]); 1502 1651 1503 status = rpccli_lsa_CreateSecret(cli, mem_ctx,1652 status = dcerpc_lsa_CreateSecret(b, mem_ctx, 1504 1653 &handle, 1505 1654 name, 1506 1655 SEC_FLAG_MAXIMUM_ALLOWED, 1507 &sec_handle); 1508 if (!NT_STATUS_IS_OK(status)) { 1656 &sec_handle, 1657 &result); 1658 if (!NT_STATUS_IS_OK(status)) { 1659 goto done; 1660 } 1661 if (!NT_STATUS_IS_OK(result)) { 1662 status = result; 1509 1663 goto done; 1510 1664 } … … 1512 1666 done: 1513 1667 if (is_valid_policy_hnd(&sec_handle)) { 1514 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1668 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1515 1669 } 1516 1670 if (is_valid_policy_hnd(&handle)) { 1517 rpccli_lsa_Close(cli, mem_ctx, &handle);1671 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1518 1672 } 1519 1673 … … 1525 1679 const char **argv) 1526 1680 { 1527 NTSTATUS status ;1681 NTSTATUS status, result; 1528 1682 struct policy_handle handle, sec_handle; 1529 1683 struct lsa_String name; 1684 struct dcerpc_binding_handle *b = cli->binding_handle; 1530 1685 1531 1686 if (argc < 2) { … … 1544 1699 init_lsa_String(&name, argv[1]); 1545 1700 1546 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1701 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1547 1702 &handle, 1548 1703 name, 1549 1704 SEC_FLAG_MAXIMUM_ALLOWED, 1550 &sec_handle); 1551 if (!NT_STATUS_IS_OK(status)) { 1552 goto done; 1553 } 1554 1555 status = rpccli_lsa_DeleteObject(cli, mem_ctx, 1556 &sec_handle); 1557 if (!NT_STATUS_IS_OK(status)) { 1705 &sec_handle, 1706 &result); 1707 if (!NT_STATUS_IS_OK(status)) { 1708 goto done; 1709 } 1710 if (!NT_STATUS_IS_OK(result)) { 1711 status = result; 1712 goto done; 1713 } 1714 1715 status = dcerpc_lsa_DeleteObject(b, mem_ctx, 1716 &sec_handle, 1717 &result); 1718 if (!NT_STATUS_IS_OK(status)) { 1719 goto done; 1720 } 1721 if (!NT_STATUS_IS_OK(result)) { 1722 status = result; 1558 1723 goto done; 1559 1724 } … … 1561 1726 done: 1562 1727 if (is_valid_policy_hnd(&sec_handle)) { 1563 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1728 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1564 1729 } 1565 1730 if (is_valid_policy_hnd(&handle)) { 1566 rpccli_lsa_Close(cli, mem_ctx, &handle);1731 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1567 1732 } 1568 1733 … … 1574 1739 const char **argv) 1575 1740 { 1576 NTSTATUS status ;1741 NTSTATUS status, result; 1577 1742 struct policy_handle handle, sec_handle; 1578 1743 struct lsa_String name; … … 1585 1750 DATA_BLOB old_blob = data_blob_null; 1586 1751 char *new_secret, *old_secret; 1752 struct dcerpc_binding_handle *b = cli->binding_handle; 1587 1753 1588 1754 if (argc < 2) { … … 1601 1767 init_lsa_String(&name, argv[1]); 1602 1768 1603 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1769 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1604 1770 &handle, 1605 1771 name, 1606 1772 SEC_FLAG_MAXIMUM_ALLOWED, 1607 &sec_handle); 1608 if (!NT_STATUS_IS_OK(status)) { 1773 &sec_handle, 1774 &result); 1775 if (!NT_STATUS_IS_OK(status)) { 1776 goto done; 1777 } 1778 if (!NT_STATUS_IS_OK(result)) { 1779 status = result; 1609 1780 goto done; 1610 1781 } … … 1613 1784 ZERO_STRUCT(old_val); 1614 1785 1615 status = rpccli_lsa_QuerySecret(cli, mem_ctx,1786 status = dcerpc_lsa_QuerySecret(b, mem_ctx, 1616 1787 &sec_handle, 1617 1788 &new_val, 1618 1789 &new_mtime, 1619 1790 &old_val, 1620 &old_mtime); 1621 if (!NT_STATUS_IS_OK(status)) { 1791 &old_mtime, 1792 &result); 1793 if (!NT_STATUS_IS_OK(status)) { 1794 goto done; 1795 } 1796 if (!NT_STATUS_IS_OK(result)) { 1797 status = result; 1622 1798 goto done; 1623 1799 } … … 1646 1822 done: 1647 1823 if (is_valid_policy_hnd(&sec_handle)) { 1648 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1824 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1649 1825 } 1650 1826 if (is_valid_policy_hnd(&handle)) { 1651 rpccli_lsa_Close(cli, mem_ctx, &handle);1827 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1652 1828 } 1653 1829 … … 1659 1835 const char **argv) 1660 1836 { 1661 NTSTATUS status ;1837 NTSTATUS status, result; 1662 1838 struct policy_handle handle, sec_handle; 1663 1839 struct lsa_String name; … … 1666 1842 DATA_BLOB enc_key; 1667 1843 DATA_BLOB session_key; 1844 struct dcerpc_binding_handle *b = cli->binding_handle; 1668 1845 1669 1846 if (argc < 3) { … … 1682 1859 init_lsa_String(&name, argv[1]); 1683 1860 1684 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1861 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1685 1862 &handle, 1686 1863 name, 1687 1864 SEC_FLAG_MAXIMUM_ALLOWED, 1688 &sec_handle); 1689 if (!NT_STATUS_IS_OK(status)) { 1865 &sec_handle, 1866 &result); 1867 if (!NT_STATUS_IS_OK(status)) { 1868 goto done; 1869 } 1870 if (!NT_STATUS_IS_OK(result)) { 1871 status = result; 1690 1872 goto done; 1691 1873 } … … 1705 1887 new_val.data = enc_key.data; 1706 1888 1707 status = rpccli_lsa_SetSecret(cli, mem_ctx,1889 status = dcerpc_lsa_SetSecret(b, mem_ctx, 1708 1890 &sec_handle, 1709 1891 &new_val, 1710 NULL); 1711 if (!NT_STATUS_IS_OK(status)) { 1892 NULL, 1893 &result); 1894 if (!NT_STATUS_IS_OK(status)) { 1895 goto done; 1896 } 1897 if (!NT_STATUS_IS_OK(result)) { 1898 status = result; 1712 1899 goto done; 1713 1900 } … … 1715 1902 done: 1716 1903 if (is_valid_policy_hnd(&sec_handle)) { 1717 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1904 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1718 1905 } 1719 1906 if (is_valid_policy_hnd(&handle)) { 1720 rpccli_lsa_Close(cli, mem_ctx, &handle);1907 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1721 1908 } 1722 1909 … … 1728 1915 const char **argv) 1729 1916 { 1730 NTSTATUS status ;1917 NTSTATUS status, result; 1731 1918 struct policy_handle handle; 1732 1919 struct lsa_String name; … … 1735 1922 DATA_BLOB blob = data_blob_null; 1736 1923 char *secret; 1924 struct dcerpc_binding_handle *b = cli->binding_handle; 1737 1925 1738 1926 if (argc < 2) { … … 1753 1941 ZERO_STRUCT(val); 1754 1942 1755 status = rpccli_lsa_RetrievePrivateData(cli, mem_ctx,1943 status = dcerpc_lsa_RetrievePrivateData(b, mem_ctx, 1756 1944 &handle, 1757 1945 &name, 1758 &val); 1759 if (!NT_STATUS_IS_OK(status)) { 1946 &val, 1947 &result); 1948 if (!NT_STATUS_IS_OK(status)) { 1949 goto done; 1950 } 1951 if (!NT_STATUS_IS_OK(result)) { 1952 status = result; 1760 1953 goto done; 1761 1954 } … … 1777 1970 done: 1778 1971 if (is_valid_policy_hnd(&handle)) { 1779 rpccli_lsa_Close(cli, mem_ctx, &handle);1972 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1780 1973 } 1781 1974 … … 1787 1980 const char **argv) 1788 1981 { 1789 NTSTATUS status ;1982 NTSTATUS status, result; 1790 1983 struct policy_handle handle; 1791 1984 struct lsa_String name; … … 1793 1986 DATA_BLOB session_key; 1794 1987 DATA_BLOB enc_key; 1988 struct dcerpc_binding_handle *b = cli->binding_handle; 1795 1989 1796 1990 if (argc < 3) { … … 1822 2016 val.data = enc_key.data; 1823 2017 1824 status = rpccli_lsa_StorePrivateData(cli, mem_ctx,2018 status = dcerpc_lsa_StorePrivateData(b, mem_ctx, 1825 2019 &handle, 1826 2020 &name, 1827 &val); 1828 if (!NT_STATUS_IS_OK(status)) { 2021 &val, 2022 &result); 2023 if (!NT_STATUS_IS_OK(status)) { 2024 goto done; 2025 } 2026 if (!NT_STATUS_IS_OK(result)) { 2027 status = result; 1829 2028 goto done; 1830 2029 } … … 1832 2031 done: 1833 2032 if (is_valid_policy_hnd(&handle)) { 1834 rpccli_lsa_Close(cli, mem_ctx, &handle);2033 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1835 2034 } 1836 2035 … … 1842 2041 const char **argv) 1843 2042 { 1844 NTSTATUS status ;2043 NTSTATUS status, result; 1845 2044 struct policy_handle handle, trustdom_handle; 2045 struct dom_sid sid; 1846 2046 struct lsa_DomainInfo info; 2047 struct dcerpc_binding_handle *b = cli->binding_handle; 1847 2048 1848 2049 if (argc < 3) { … … 1860 2061 1861 2062 init_lsa_StringLarge(&info.name, argv[1]); 1862 info.sid = string_sid_talloc(mem_ctx, argv[2]); 1863 1864 status = rpccli_lsa_CreateTrustedDomain(cli, mem_ctx, 2063 info.sid = &sid; 2064 string_to_sid(&sid, argv[2]); 2065 2066 status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx, 1865 2067 &handle, 1866 2068 &info, 1867 2069 SEC_FLAG_MAXIMUM_ALLOWED, 1868 &trustdom_handle); 1869 if (!NT_STATUS_IS_OK(status)) { 2070 &trustdom_handle, 2071 &result); 2072 if (!NT_STATUS_IS_OK(status)) { 2073 goto done; 2074 } 2075 if (!NT_STATUS_IS_OK(result)) { 2076 status = result; 1870 2077 goto done; 1871 2078 } … … 1873 2080 done: 1874 2081 if (is_valid_policy_hnd(&trustdom_handle)) { 1875 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);2082 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result); 1876 2083 } 1877 2084 1878 2085 if (is_valid_policy_hnd(&handle)) { 1879 rpccli_lsa_Close(cli, mem_ctx, &handle);2086 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1880 2087 } 1881 2088 … … 1887 2094 const char **argv) 1888 2095 { 1889 NTSTATUS status ;2096 NTSTATUS status, result; 1890 2097 struct policy_handle handle, trustdom_handle; 1891 2098 struct lsa_String name; 1892 2099 struct dom_sid *sid = NULL; 2100 struct dcerpc_binding_handle *b = cli->binding_handle; 1893 2101 1894 2102 if (argc < 2) { … … 1907 2115 init_lsa_String(&name, argv[1]); 1908 2116 1909 status = rpccli_lsa_OpenTrustedDomainByName(cli, mem_ctx,2117 status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx, 1910 2118 &handle, 1911 2119 name, 1912 2120 SEC_FLAG_MAXIMUM_ALLOWED, 1913 &trustdom_handle); 1914 if (NT_STATUS_IS_OK(status)) { 2121 &trustdom_handle, 2122 &result); 2123 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) { 1915 2124 goto delete_object; 1916 2125 } … … 1921 2130 int i; 1922 2131 1923 status = rpccli_lsa_EnumTrustDom(cli, mem_ctx,2132 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 1924 2133 &handle, 1925 2134 &resume_handle, 1926 2135 &domains, 1927 0xffff); 2136 0xffff, 2137 &result); 1928 2138 if (!NT_STATUS_IS_OK(status)) { 2139 goto done; 2140 } 2141 if (!NT_STATUS_IS_OK(result)) { 2142 status = result; 1929 2143 goto done; 1930 2144 } … … 1942 2156 } 1943 2157 1944 status = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,2158 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx, 1945 2159 &handle, 1946 2160 sid, 1947 2161 SEC_FLAG_MAXIMUM_ALLOWED, 1948 &trustdom_handle); 1949 if (!NT_STATUS_IS_OK(status)) { 2162 &trustdom_handle, 2163 &result); 2164 if (!NT_STATUS_IS_OK(status)) { 2165 goto done; 2166 } 2167 if (!NT_STATUS_IS_OK(result)) { 2168 status = result; 1950 2169 goto done; 1951 2170 } 1952 2171 1953 2172 delete_object: 1954 status = rpccli_lsa_DeleteObject(cli, mem_ctx, 1955 &trustdom_handle); 1956 if (!NT_STATUS_IS_OK(status)) { 2173 status = dcerpc_lsa_DeleteObject(b, mem_ctx, 2174 &trustdom_handle, 2175 &result); 2176 if (!NT_STATUS_IS_OK(status)) { 2177 goto done; 2178 } 2179 if (!NT_STATUS_IS_OK(result)) { 2180 status = result; 1957 2181 goto done; 1958 2182 } … … 1960 2184 done: 1961 2185 if (is_valid_policy_hnd(&trustdom_handle)) { 1962 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);2186 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result); 1963 2187 } 1964 2188 1965 2189 if (is_valid_policy_hnd(&handle)) { 1966 rpccli_lsa_Close(cli, mem_ctx, &handle);2190 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1967 2191 } 1968 2192
Note:
See TracChangeset
for help on using the changeset viewer.