Changeset 745 for trunk/server/source3/utils/net_util.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/utils/net_util.c
r454 r745 22 22 #include "includes.h" 23 23 #include "utils/net.h" 24 #include "../librpc/gen_ndr/cli_lsa.h" 25 #include "../librpc/gen_ndr/cli_dssetup.h" 24 #include "rpc_client/cli_pipe.h" 25 #include "../librpc/gen_ndr/ndr_lsa_c.h" 26 #include "rpc_client/cli_lsarpc.h" 27 #include "../librpc/gen_ndr/ndr_dssetup_c.h" 28 #include "secrets.h" 29 #include "../libcli/security/security.h" 30 #include "libsmb/libsmb.h" 26 31 27 32 NTSTATUS net_rpc_lookup_name(struct net_context *c, 28 33 TALLOC_CTX *mem_ctx, struct cli_state *cli, 29 34 const char *name, const char **ret_domain, 30 const char **ret_name, DOM_SID*ret_sid,35 const char **ret_name, struct dom_sid *ret_sid, 31 36 enum lsa_SidType *ret_type) 32 37 { 33 38 struct rpc_pipe_client *lsa_pipe = NULL; 34 39 struct policy_handle pol; 35 NTSTATUS result = NT_STATUS_OK;40 NTSTATUS status, result; 36 41 const char **dom_names; 37 DOM_SID*sids;42 struct dom_sid *sids; 38 43 enum lsa_SidType *types; 44 struct dcerpc_binding_handle *b; 39 45 40 46 ZERO_STRUCT(pol); 41 47 42 result= cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,48 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 43 49 &lsa_pipe); 44 if (!NT_STATUS_IS_OK( result)) {50 if (!NT_STATUS_IS_OK(status)) { 45 51 d_fprintf(stderr, _("Could not initialise lsa pipe\n")); 46 return result; 47 } 48 49 result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, 52 return status; 53 } 54 55 b = lsa_pipe->binding_handle; 56 57 status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, 50 58 SEC_FLAG_MAXIMUM_ALLOWED, 51 59 &pol); 52 if (!NT_STATUS_IS_OK( result)) {60 if (!NT_STATUS_IS_OK(status)) { 53 61 d_fprintf(stderr, "open_policy %s: %s\n", _("failed"), 54 nt_errstr( result));55 return result;56 } 57 58 result= rpccli_lsa_lookup_names(lsa_pipe, mem_ctx, &pol, 1,62 nt_errstr(status)); 63 return status; 64 } 65 66 status = rpccli_lsa_lookup_names(lsa_pipe, mem_ctx, &pol, 1, 59 67 &name, &dom_names, 1, &sids, &types); 60 68 61 if (!NT_STATUS_IS_OK( result)) {69 if (!NT_STATUS_IS_OK(status)) { 62 70 /* This can happen easily, don't log an error */ 63 71 goto done; … … 79 87 done: 80 88 if (is_valid_policy_hnd(&pol)) { 81 rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);89 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 82 90 } 83 91 TALLOC_FREE(lsa_pipe); 84 92 85 return result;93 return status; 86 94 } 87 95 … … 106 114 } 107 115 #endif 108 109 116 c->opt_password = net_prompt_pass(c, c->opt_user_name); 110 117 … … 125 132 service_name, service_type, 126 133 c->opt_user_name, c->opt_workgroup, 127 c->opt_password, flags, Undefined , NULL);134 c->opt_password, flags, Undefined); 128 135 if (!NT_STATUS_IS_OK(nt_status)) { 129 136 d_fprintf(stderr, _("Could not connect to server %s\n"), … … 209 216 "IPC$", "IPC", 210 217 "", "", 211 "", 0, Undefined , NULL);218 "", 0, Undefined); 212 219 213 220 if (NT_STATUS_IS_OK(nt_status)) { … … 269 276 c->opt_password, 270 277 CLI_FULL_CONNECTION_USE_KERBEROS, 271 Undefined , NULL);278 Undefined); 272 279 273 280 SAFE_FREE(user_and_realm); … … 423 430 } 424 431 425 if (is_zero_addr( (struct sockaddr *)&pdc_ss)) {432 if (is_zero_addr(&pdc_ss)) { 426 433 return false; 427 434 } … … 480 487 return false; 481 488 } 482 if (is_zero_addr( (struct sockaddr *)server_ss)) {489 if (is_zero_addr(server_ss)) { 483 490 return false; 484 491 } … … 626 633 } 627 634 635 static NTSTATUS net_scan_dc_noad(struct net_context *c, 636 struct cli_state *cli, 637 struct net_dc_info *dc_info) 638 { 639 TALLOC_CTX *mem_ctx = talloc_tos(); 640 struct rpc_pipe_client *pipe_hnd = NULL; 641 struct dcerpc_binding_handle *b; 642 NTSTATUS status, result; 643 struct policy_handle pol; 644 union lsa_PolicyInformation *info; 645 646 ZERO_STRUCTP(dc_info); 647 ZERO_STRUCT(pol); 648 649 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 650 &pipe_hnd); 651 if (!NT_STATUS_IS_OK(status)) { 652 return status; 653 } 654 655 b = pipe_hnd->binding_handle; 656 657 status = dcerpc_lsa_open_policy(b, mem_ctx, 658 false, 659 SEC_FLAG_MAXIMUM_ALLOWED, 660 &pol, 661 &result); 662 if (!NT_STATUS_IS_OK(status)) { 663 goto done; 664 } 665 if (!NT_STATUS_IS_OK(result)) { 666 status = result; 667 goto done; 668 } 669 670 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 671 &pol, 672 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 673 &info, 674 &result); 675 if (!NT_STATUS_IS_OK(status)) { 676 goto done; 677 } 678 if (!NT_STATUS_IS_OK(result)) { 679 status = result; 680 goto done; 681 } 682 683 dc_info->netbios_domain_name = talloc_strdup(mem_ctx, info->account_domain.name.string); 684 if (dc_info->netbios_domain_name == NULL) { 685 status = NT_STATUS_NO_MEMORY; 686 goto done; 687 } 688 689 done: 690 if (is_valid_policy_hnd(&pol)) { 691 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 692 } 693 694 TALLOC_FREE(pipe_hnd); 695 696 return status; 697 } 698 628 699 NTSTATUS net_scan_dc(struct net_context *c, 629 700 struct cli_state *cli, … … 632 703 TALLOC_CTX *mem_ctx = talloc_tos(); 633 704 struct rpc_pipe_client *dssetup_pipe = NULL; 705 struct dcerpc_binding_handle *dssetup_handle = NULL; 634 706 union dssetup_DsRoleInfo info; 635 707 NTSTATUS status; 708 WERROR werr; 636 709 637 710 ZERO_STRUCTP(dc_info); … … 640 713 &dssetup_pipe); 641 714 if (!NT_STATUS_IS_OK(status)) { 642 return status; 643 } 644 645 status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(dssetup_pipe, mem_ctx, 715 DEBUG(10,("net_scan_dc: failed to open dssetup pipe with %s, " 716 "retrying with lsa pipe\n", nt_errstr(status))); 717 return net_scan_dc_noad(c, cli, dc_info); 718 } 719 dssetup_handle = dssetup_pipe->binding_handle; 720 721 status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(dssetup_handle, mem_ctx, 646 722 DS_ROLE_BASIC_INFORMATION, 647 723 &info, 648 NULL);724 &werr); 649 725 TALLOC_FREE(dssetup_pipe); 650 726 727 if (NT_STATUS_IS_OK(status)) { 728 status = werror_to_ntstatus(werr); 729 } 651 730 if (!NT_STATUS_IS_OK(status)) { 652 731 return status;
Note:
See TracChangeset
for help on using the changeset viewer.