Changeset 745 for trunk/server/source3/utils/net_rpc.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_rpc.c
r480 r745 23 23 #include "includes.h" 24 24 #include "utils/net.h" 25 #include "rpc_client/cli_pipe.h" 25 26 #include "../libcli/auth/libcli_auth.h" 26 #include "../librpc/gen_ndr/cli_samr.h" 27 #include "../librpc/gen_ndr/cli_lsa.h" 28 #include "../librpc/gen_ndr/cli_netlogon.h" 29 #include "../librpc/gen_ndr/cli_srvsvc.h" 30 #include "../librpc/gen_ndr/cli_spoolss.h" 31 #include "../librpc/gen_ndr/cli_initshutdown.h" 32 #include "../librpc/gen_ndr/cli_winreg.h" 27 #include "../librpc/gen_ndr/ndr_samr_c.h" 28 #include "rpc_client/cli_samr.h" 29 #include "rpc_client/init_samr.h" 30 #include "../librpc/gen_ndr/ndr_lsa_c.h" 31 #include "rpc_client/cli_lsarpc.h" 32 #include "../librpc/gen_ndr/ndr_netlogon_c.h" 33 #include "../librpc/gen_ndr/ndr_srvsvc_c.h" 34 #include "../librpc/gen_ndr/ndr_spoolss.h" 35 #include "../librpc/gen_ndr/ndr_initshutdown_c.h" 36 #include "../librpc/gen_ndr/ndr_winreg_c.h" 37 #include "secrets.h" 38 #include "lib/netapi/netapi.h" 39 #include "lib/netapi/netapi_net.h" 40 #include "rpc_client/init_lsa.h" 41 #include "../libcli/security/security.h" 42 #include "libsmb/libsmb.h" 43 #include "libsmb/clirap.h" 44 #include "nsswitch/libwbclient/wbclient.h" 45 #include "passdb.h" 33 46 34 47 static int net_mode_share; 35 static boolsync_files(struct copy_clistate *cp_clistate, const char *mask);48 static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask); 36 49 37 50 /** … … 60 73 61 74 NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, 62 DOM_SID**domain_sid,75 struct dom_sid **domain_sid, 63 76 const char **domain_name) 64 77 { 65 78 struct rpc_pipe_client *lsa_pipe = NULL; 66 79 struct policy_handle pol; 67 NTSTATUS result = NT_STATUS_OK;80 NTSTATUS status, result; 68 81 union lsa_PolicyInformation *info = NULL; 69 70 result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 82 struct dcerpc_binding_handle *b; 83 84 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 71 85 &lsa_pipe); 72 if (!NT_STATUS_IS_OK( result)) {86 if (!NT_STATUS_IS_OK(status)) { 73 87 d_fprintf(stderr, _("Could not initialise lsa pipe\n")); 74 return result; 75 } 76 77 result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, 88 return status; 89 } 90 91 b = lsa_pipe->binding_handle; 92 93 status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, false, 78 94 SEC_FLAG_MAXIMUM_ALLOWED, 79 95 &pol); 80 if (!NT_STATUS_IS_OK( result)) {96 if (!NT_STATUS_IS_OK(status)) { 81 97 d_fprintf(stderr, "open_policy %s: %s\n", 82 98 _("failed"), 83 nt_errstr( result));84 return result;85 } 86 87 result = rpccli_lsa_QueryInfoPolicy(lsa_pipe, mem_ctx,99 nt_errstr(status)); 100 return status; 101 } 102 103 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 88 104 &pol, 89 105 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 90 &info); 106 &info, 107 &result); 108 if (!NT_STATUS_IS_OK(status)) { 109 d_fprintf(stderr, "lsaquery %s: %s\n", 110 _("failed"), 111 nt_errstr(status)); 112 return status; 113 } 91 114 if (!NT_STATUS_IS_OK(result)) { 92 115 d_fprintf(stderr, "lsaquery %s: %s\n", … … 99 122 *domain_sid = info->account_domain.sid; 100 123 101 rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);124 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 102 125 TALLOC_FREE(lsa_pipe); 103 126 … … 129 152 TALLOC_CTX *mem_ctx; 130 153 NTSTATUS nt_status; 131 DOM_SID*domain_sid;154 struct dom_sid *domain_sid; 132 155 const char *domain_name; 133 156 int ret = -1; … … 242 265 243 266 static NTSTATUS rpc_changetrustpw_internals(struct net_context *c, 244 const DOM_SID*domain_sid,267 const struct dom_sid *domain_sid, 245 268 const char *domain_name, 246 269 struct cli_state *cli, … … 310 333 311 334 static NTSTATUS rpc_oldjoin_internals(struct net_context *c, 312 const DOM_SID*domain_sid,335 const struct dom_sid *domain_sid, 313 336 const char *domain_name, 314 337 struct cli_state *cli, … … 489 512 490 513 NTSTATUS rpc_info_internals(struct net_context *c, 491 const DOM_SID*domain_sid,514 const struct dom_sid *domain_sid, 492 515 const char *domain_name, 493 516 struct cli_state *cli, … … 498 521 { 499 522 struct policy_handle connect_pol, domain_pol; 500 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;523 NTSTATUS status, result; 501 524 union samr_DomainInfo *info = NULL; 502 525 fstring sid_str; 526 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 503 527 504 528 sid_to_fstring(sid_str, domain_sid); 505 529 506 530 /* Get sam policy handle */ 507 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,531 status = dcerpc_samr_Connect2(b, mem_ctx, 508 532 pipe_hnd->desthost, 509 533 MAXIMUM_ALLOWED_ACCESS, 510 &connect_pol); 534 &connect_pol, 535 &result); 536 if (!NT_STATUS_IS_OK(status)) { 537 d_fprintf(stderr, _("Could not connect to SAM: %s\n"), 538 nt_errstr(status)); 539 goto done; 540 } 541 511 542 if (!NT_STATUS_IS_OK(result)) { 543 status = result; 512 544 d_fprintf(stderr, _("Could not connect to SAM: %s\n"), 513 545 nt_errstr(result)); … … 516 548 517 549 /* Get domain policy handle */ 518 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,550 status = dcerpc_samr_OpenDomain(b, mem_ctx, 519 551 &connect_pol, 520 552 MAXIMUM_ALLOWED_ACCESS, 521 553 CONST_DISCARD(struct dom_sid2 *, domain_sid), 522 &domain_pol); 554 &domain_pol, 555 &result); 556 if (!NT_STATUS_IS_OK(status)) { 557 d_fprintf(stderr, _("Could not open domain: %s\n"), 558 nt_errstr(status)); 559 goto done; 560 } 523 561 if (!NT_STATUS_IS_OK(result)) { 562 status = result; 524 563 d_fprintf(stderr, _("Could not open domain: %s\n"), 525 564 nt_errstr(result)); … … 527 566 } 528 567 529 result = rpccli_samr_QueryDomainInfo(pipe_hnd, mem_ctx,568 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 530 569 &domain_pol, 531 570 2, 532 &info); 571 &info, 572 &result); 573 if (!NT_STATUS_IS_OK(status)) { 574 goto done; 575 } 576 status = result; 533 577 if (NT_STATUS_IS_OK(result)) { 534 578 d_printf(_("Domain Name: %s\n"), … … 543 587 544 588 done: 545 return result;589 return status; 546 590 } 547 591 … … 586 630 587 631 static NTSTATUS rpc_getsid_internals(struct net_context *c, 588 const DOM_SID*domain_sid,632 const struct dom_sid *domain_sid, 589 633 const char *domain_name, 590 634 struct cli_state *cli, … … 728 772 } 729 773 774 return status; 775 } 776 777 /** 778 * Set a user's primary group 779 * 780 * @param argc Standard main() style argc. 781 * @param argv Standard main() style argv. Initial components are already 782 * stripped. 783 * 784 * @return A shell status integer (0 for success). 785 **/ 786 787 static int rpc_user_setprimarygroup(struct net_context *c, int argc, 788 const char **argv) 789 { 790 NET_API_STATUS status; 791 uint8_t *buffer; 792 struct GROUP_INFO_2 *g2; 793 struct USER_INFO_1051 u1051; 794 uint32_t parm_err = 0; 795 796 if (argc != 2 || c->display_usage) { 797 rpc_user_usage(c, argc, argv); 798 return 0; 799 } 800 801 status = NetGroupGetInfo(c->opt_host, argv[1], 2, &buffer); 802 if (status) { 803 d_fprintf(stderr, _("Failed to find group name %s -- %s\n"), 804 argv[1], 805 libnetapi_get_error_string(c->netapi_ctx, status)); 806 return status; 807 } 808 g2 = (struct GROUP_INFO_2 *)buffer; 809 810 u1051.usri1051_primary_group_id = g2->grpi2_group_id; 811 812 NetApiBufferFree(buffer); 813 814 status = NetUserSetInfo(c->opt_host, argv[0], 1051, 815 (uint8_t *)&u1051, &parm_err); 816 if (status) { 817 d_fprintf(stderr, 818 _("Failed to set user's primary group %s to %s - " 819 "%s\n"), argv[0], argv[1], 820 libnetapi_get_error_string(c->netapi_ctx, status)); 821 } else { 822 d_printf(_("Set primary group of user %s to %s\n"), argv[0], 823 argv[1]); 824 } 730 825 return status; 731 826 } … … 894 989 uint32_t max_entries, max_size; 895 990 896 get_query_dispinfo_params(991 dcerpc_get_query_dispinfo_params( 897 992 loop_count, &max_entries, &max_size); 898 993 … … 956 1051 N_("List domain groups of user"), 957 1052 N_("net rpc user info\n" 958 " Lis domain groups of user")1053 " List domain groups of user") 959 1054 }, 960 1055 { … … 982 1077 " Rename specified user") 983 1078 }, 1079 { 1080 "setprimarygroup", 1081 rpc_user_setprimarygroup, 1082 NET_TRANSPORT_RPC, 1083 "Set a user's primary group", 1084 "net rpc user setprimarygroup\n" 1085 " Set a user's primary group" 1086 }, 984 1087 {NULL, NULL, 0, NULL, NULL} 985 1088 }; 986 1089 987 status = libnetapi_ init(&c->netapi_ctx);1090 status = libnetapi_net_init(&c->netapi_ctx); 988 1091 if (status != 0) { 989 1092 return -1; … … 1044 1147 { 1045 1148 struct policy_handle connect_pol, domain_pol, user_pol; 1046 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1047 DOM_SIDsid;1149 NTSTATUS status, result; 1150 struct dom_sid sid; 1048 1151 uint32 rid; 1049 1152 enum lsa_SidType type; 1153 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1050 1154 1051 1155 if (argc == 0) { … … 1059 1163 ZERO_STRUCT(user_pol); 1060 1164 1061 result= net_rpc_lookup_name(c, mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd),1165 status = net_rpc_lookup_name(c, mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd), 1062 1166 argv[0], NULL, NULL, &sid, &type); 1063 if (!NT_STATUS_IS_OK( result)) {1167 if (!NT_STATUS_IS_OK(status)) { 1064 1168 d_fprintf(stderr, _("Could not lookup %s: %s\n"), argv[0], 1065 nt_errstr( result));1169 nt_errstr(status)); 1066 1170 goto done; 1067 1171 } … … 1070 1174 d_fprintf(stderr, _("%s is a %s, not a user\n"), argv[0], 1071 1175 sid_type_lookup(type)); 1072 result= NT_STATUS_NO_SUCH_USER;1176 status = NT_STATUS_NO_SUCH_USER; 1073 1177 goto done; 1074 1178 } … … 1076 1180 if (!sid_peek_check_rid(ctx->domain_sid, &sid, &rid)) { 1077 1181 d_fprintf(stderr, _("%s is not in our domain\n"), argv[0]); 1078 result= NT_STATUS_NO_SUCH_USER;1079 goto done; 1080 } 1081 1082 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,1182 status = NT_STATUS_NO_SUCH_USER; 1183 goto done; 1184 } 1185 1186 status = dcerpc_samr_Connect2(b, mem_ctx, 1083 1187 pipe_hnd->desthost, 1084 1188 MAXIMUM_ALLOWED_ACCESS, 1085 &connect_pol); 1189 &connect_pol, 1190 &result); 1191 if (!NT_STATUS_IS_OK(status)) { 1192 goto done; 1193 } 1086 1194 if (!NT_STATUS_IS_OK(result)) { 1087 goto done; 1088 } 1089 1090 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, 1195 status = result; 1196 goto done; 1197 } 1198 1199 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1091 1200 &connect_pol, 1092 1201 MAXIMUM_ALLOWED_ACCESS, 1093 1202 ctx->domain_sid, 1094 &domain_pol); 1203 &domain_pol, 1204 &result); 1205 if (!NT_STATUS_IS_OK(status)) { 1206 goto done; 1207 } 1095 1208 if (!NT_STATUS_IS_OK(result)) { 1096 goto done; 1097 } 1098 1099 result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, 1209 status = result; 1210 goto done; 1211 } 1212 1213 status = dcerpc_samr_OpenUser(b, mem_ctx, 1100 1214 &domain_pol, 1101 1215 MAXIMUM_ALLOWED_ACCESS, 1102 1216 rid, 1103 &user_pol); 1217 &user_pol, 1218 &result); 1219 if (!NT_STATUS_IS_OK(status)) { 1220 goto done; 1221 } 1104 1222 if (!NT_STATUS_IS_OK(result)) { 1105 goto done; 1106 } 1107 1108 result = fn(c, mem_ctx, ctx, pipe_hnd, &user_pol, argc-1, argv+1); 1223 status = result; 1224 goto done; 1225 } 1226 1227 status = fn(c, mem_ctx, ctx, pipe_hnd, &user_pol, argc-1, argv+1); 1109 1228 1110 1229 done: 1111 1230 if (is_valid_policy_hnd(&user_pol)) { 1112 rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);1231 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 1113 1232 } 1114 1233 if (is_valid_policy_hnd(&domain_pol)) { 1115 rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);1234 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1116 1235 } 1117 1236 if (is_valid_policy_hnd(&connect_pol)) { 1118 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);1119 } 1120 return result;1237 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1238 } 1239 return status; 1121 1240 } 1122 1241 … … 1128 1247 int argc, const char **argv) 1129 1248 { 1130 NTSTATUS result;1249 NTSTATUS status, result; 1131 1250 union samr_UserInfo *info = NULL; 1251 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1132 1252 1133 1253 if (argc != 0) { … … 1137 1257 } 1138 1258 1139 result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx,1259 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 1140 1260 user_hnd, 1141 1261 21, 1142 &info); 1262 &info, 1263 &result); 1264 if (!NT_STATUS_IS_OK(status)) { 1265 return status; 1266 } 1143 1267 if (!NT_STATUS_IS_OK(result)) { 1144 1268 return result; … … 1180 1304 int argc, const char **argv) 1181 1305 { 1182 NTSTATUS result;1306 NTSTATUS status, result; 1183 1307 const char *username; 1184 1308 const char *oldval = ""; 1185 1309 union samr_UserInfo *info = NULL; 1310 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1186 1311 1187 1312 if (argc > 1) { … … 1191 1316 } 1192 1317 1193 result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx,1318 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 1194 1319 user_hnd, 1195 1320 21, 1196 &info); 1321 &info, 1322 &result); 1323 if (!NT_STATUS_IS_OK(status)) { 1324 return status; 1325 } 1197 1326 if (!NT_STATUS_IS_OK(result)) { 1198 1327 return result; … … 1226 1355 SETSTR("description", description, DESCRIPTION); 1227 1356 1228 result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx,1357 status = dcerpc_samr_SetUserInfo(b, mem_ctx, 1229 1358 user_hnd, 1230 1359 21, 1231 info); 1360 info, 1361 &result); 1362 if (!NT_STATUS_IS_OK(status)) { 1363 return status; 1364 } 1365 1366 status = result; 1232 1367 1233 1368 d_printf(_("Set %s's %s from [%s] to [%s]\n"), username, … … 1236 1371 done: 1237 1372 1238 return result;1373 return status; 1239 1374 } 1240 1375 … … 1265 1400 int argc, const char **argv) 1266 1401 { 1267 NTSTATUS result;1402 NTSTATUS status, result; 1268 1403 const char *username; 1269 1404 const char *oldval = "unknown"; … … 1271 1406 bool newval; 1272 1407 union samr_UserInfo *info = NULL; 1408 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1273 1409 1274 1410 if ((argc > 1) || … … 1284 1420 newval = strequal(argv[0], "yes"); 1285 1421 1286 result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx,1422 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 1287 1423 user_hnd, 1288 1424 21, 1289 &info); 1425 &info, 1426 &result); 1427 if (!NT_STATUS_IS_OK(status)) { 1428 return status; 1429 } 1290 1430 if (!NT_STATUS_IS_OK(result)) { 1291 1431 return result; … … 1312 1452 info->info21.fields_present = SAMR_FIELD_ACCT_FLAGS; 1313 1453 1314 result = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx,1454 status = dcerpc_samr_SetUserInfo(b, mem_ctx, 1315 1455 user_hnd, 1316 1456 21, 1317 info); 1318 1457 info, 1458 &result); 1459 if (!NT_STATUS_IS_OK(status)) { 1460 goto done; 1461 } 1462 status = result; 1319 1463 if (NT_STATUS_IS_OK(result)) { 1320 1464 d_printf(_("Set %s's %s flag from [%s] to [%s]\n"), username, … … 1324 1468 done: 1325 1469 1326 return result;1470 return status; 1327 1471 } 1328 1472 … … 1434 1578 1435 1579 static NTSTATUS rpc_group_delete_internals(struct net_context *c, 1436 const DOM_SID*domain_sid,1580 const struct dom_sid *domain_sid, 1437 1581 const char *domain_name, 1438 1582 struct cli_state *cli, … … 1444 1588 struct policy_handle connect_pol, domain_pol, group_pol, user_pol; 1445 1589 bool group_is_primary = false; 1446 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1590 NTSTATUS status, result; 1447 1591 uint32_t group_rid; 1448 struct samr_Rid TypeArray *rids = NULL;1592 struct samr_RidAttrArray *rids = NULL; 1449 1593 /* char **names; */ 1450 1594 int i; 1451 1595 /* struct samr_RidWithAttribute *user_gids; */ 1596 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1452 1597 1453 1598 struct samr_Ids group_rids, name_types; … … 1460 1605 } 1461 1606 1462 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,1607 status = dcerpc_samr_Connect2(b, mem_ctx, 1463 1608 pipe_hnd->desthost, 1464 1609 MAXIMUM_ALLOWED_ACCESS, 1465 &connect_pol); 1610 &connect_pol, 1611 &result); 1612 if (!NT_STATUS_IS_OK(status)) { 1613 d_fprintf(stderr, _("Request samr_Connect2 failed\n")); 1614 goto done; 1615 } 1466 1616 1467 1617 if (!NT_STATUS_IS_OK(result)) { 1618 status = result; 1468 1619 d_fprintf(stderr, _("Request samr_Connect2 failed\n")); 1469 1620 goto done; 1470 1621 } 1471 1622 1472 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,1623 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1473 1624 &connect_pol, 1474 1625 MAXIMUM_ALLOWED_ACCESS, 1475 1626 CONST_DISCARD(struct dom_sid2 *, domain_sid), 1476 &domain_pol); 1627 &domain_pol, 1628 &result); 1629 if (!NT_STATUS_IS_OK(status)) { 1630 d_fprintf(stderr, _("Request open_domain failed\n")); 1631 goto done; 1632 } 1477 1633 1478 1634 if (!NT_STATUS_IS_OK(result)) { 1635 status = result; 1479 1636 d_fprintf(stderr, _("Request open_domain failed\n")); 1480 1637 goto done; 1481 1638 } 1482 1639 1483 1640 init_lsa_String(&lsa_acct_name, argv[0]); 1484 1641 1485 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,1642 status = dcerpc_samr_LookupNames(b, mem_ctx, 1486 1643 &domain_pol, 1487 1644 1, 1488 1645 &lsa_acct_name, 1489 1646 &group_rids, 1490 &name_types); 1647 &name_types, 1648 &result); 1649 if (!NT_STATUS_IS_OK(status)) { 1650 d_fprintf(stderr, _("Lookup of '%s' failed\n"),argv[0]); 1651 goto done; 1652 } 1653 1491 1654 if (!NT_STATUS_IS_OK(result)) { 1655 status = result; 1492 1656 d_fprintf(stderr, _("Lookup of '%s' failed\n"),argv[0]); 1493 1657 goto done; 1494 1658 } 1495 1659 … … 1497 1661 { 1498 1662 case SID_NAME_DOM_GRP: 1499 result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,1663 status = dcerpc_samr_OpenGroup(b, mem_ctx, 1500 1664 &domain_pol, 1501 1665 MAXIMUM_ALLOWED_ACCESS, 1502 1666 group_rids.ids[0], 1503 &group_pol); 1667 &group_pol, 1668 &result); 1669 if (!NT_STATUS_IS_OK(status)) { 1670 d_fprintf(stderr, _("Request open_group failed")); 1671 goto done; 1672 } 1673 1504 1674 if (!NT_STATUS_IS_OK(result)) { 1675 status = result; 1505 1676 d_fprintf(stderr, _("Request open_group failed")); 1506 1677 goto done; 1507 1678 } 1508 1679 1509 1680 group_rid = group_rids.ids[0]; 1510 1681 1511 result = rpccli_samr_QueryGroupMember(pipe_hnd, mem_ctx,1682 status = dcerpc_samr_QueryGroupMember(b, mem_ctx, 1512 1683 &group_pol, 1513 &rids );1514 1515 if (!NT_STATUS_IS_OK( result)) {1684 &rids, 1685 &result); 1686 if (!NT_STATUS_IS_OK(status)) { 1516 1687 d_fprintf(stderr, 1517 1688 _("Unable to query group members of %s"), 1518 1689 argv[0]); 1519 goto done; 1690 goto done; 1691 } 1692 1693 if (!NT_STATUS_IS_OK(result)) { 1694 status = result; 1695 d_fprintf(stderr, 1696 _("Unable to query group members of %s"), 1697 argv[0]); 1698 goto done; 1520 1699 } 1521 1700 … … 1529 1708 for (i = 0; i < rids->count; i++) 1530 1709 { 1531 result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,1710 status = dcerpc_samr_OpenUser(b, mem_ctx, 1532 1711 &domain_pol, 1533 1712 MAXIMUM_ALLOWED_ACCESS, 1534 1713 rids->rids[i], 1535 &user_pol );1536 1537 if (!NT_STATUS_IS_OK(result)) {1714 &user_pol, 1715 &result); 1716 if (!NT_STATUS_IS_OK(status)) { 1538 1717 d_fprintf(stderr, 1539 1718 _("Unable to open group member %d\n"), 1540 1719 rids->rids[i]); 1541 goto done; 1542 } 1543 1544 result = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx, 1720 goto done; 1721 } 1722 1723 if (!NT_STATUS_IS_OK(result)) { 1724 status = result; 1725 d_fprintf(stderr, 1726 _("Unable to open group member %d\n"), 1727 rids->rids[i]); 1728 goto done; 1729 } 1730 1731 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 1545 1732 &user_pol, 1546 1733 21, 1547 &info );1548 1549 if (!NT_STATUS_IS_OK(result)) {1734 &info, 1735 &result); 1736 if (!NT_STATUS_IS_OK(status)) { 1550 1737 d_fprintf(stderr, 1551 1738 _("Unable to lookup userinfo for group " 1552 1739 "member %d\n"), 1553 1740 rids->rids[i]); 1554 goto done; 1555 } 1741 goto done; 1742 } 1743 1744 if (!NT_STATUS_IS_OK(result)) { 1745 status = result; 1746 d_fprintf(stderr, 1747 _("Unable to lookup userinfo for group " 1748 "member %d\n"), 1749 rids->rids[i]); 1750 goto done; 1751 } 1556 1752 1557 1753 if (info->info21.primary_gid == group_rid) { … … 1564 1760 } 1565 1761 1566 rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);1762 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 1567 1763 } 1568 1764 … … 1571 1767 "some of it's members have it as primary " 1572 1768 "group\n")); 1573 result= NT_STATUS_MEMBERS_PRIMARY_GROUP;1769 status = NT_STATUS_MEMBERS_PRIMARY_GROUP; 1574 1770 goto done; 1575 1771 } … … 1581 1777 d_printf(_("Remove group member %d..."), 1582 1778 rids->rids[i]); 1583 result = rpccli_samr_DeleteGroupMember(pipe_hnd, mem_ctx,1779 status = dcerpc_samr_DeleteGroupMember(b, mem_ctx, 1584 1780 &group_pol, 1585 rids->rids[i]); 1586 1781 rids->rids[i], 1782 &result); 1783 if (!NT_STATUS_IS_OK(status)) { 1784 goto done; 1785 } 1786 status = result; 1587 1787 if (NT_STATUS_IS_OK(result)) { 1588 1788 if (c->opt_verbose) … … 1595 1795 } 1596 1796 1597 result = rpccli_samr_DeleteDomainGroup(pipe_hnd, mem_ctx, 1598 &group_pol); 1797 status = dcerpc_samr_DeleteDomainGroup(b, mem_ctx, 1798 &group_pol, 1799 &result); 1800 if (!NT_STATUS_IS_OK(status)) { 1801 break; 1802 } 1803 1804 status = result; 1599 1805 1600 1806 break; 1601 1807 /* removing a local group is easier... */ 1602 1808 case SID_NAME_ALIAS: 1603 result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx,1809 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1604 1810 &domain_pol, 1605 1811 MAXIMUM_ALLOWED_ACCESS, 1606 1812 group_rids.ids[0], 1607 &group_pol); 1608 1813 &group_pol, 1814 &result); 1815 if (!NT_STATUS_IS_OK(status)) { 1816 d_fprintf(stderr, _("Request open_alias failed\n")); 1817 goto done; 1818 } 1609 1819 if (!NT_STATUS_IS_OK(result)) { 1820 status = result; 1610 1821 d_fprintf(stderr, _("Request open_alias failed\n")); 1611 1822 goto done; 1612 1823 } 1613 1824 1614 result = rpccli_samr_DeleteDomAlias(pipe_hnd, mem_ctx, 1615 &group_pol); 1825 status = dcerpc_samr_DeleteDomAlias(b, mem_ctx, 1826 &group_pol, 1827 &result); 1828 if (!NT_STATUS_IS_OK(status)) { 1829 break; 1830 } 1831 1832 status = result; 1833 1616 1834 break; 1617 1835 default: … … 1619 1837 "for deleting local or global groups\n"), 1620 1838 argv[0],sid_type_lookup(name_types.ids[0])); 1621 result= NT_STATUS_UNSUCCESSFUL;1622 goto done; 1623 } 1624 1625 if (NT_STATUS_IS_OK( result)) {1839 status = NT_STATUS_UNSUCCESSFUL; 1840 goto done; 1841 } 1842 1843 if (NT_STATUS_IS_OK(status)) { 1626 1844 if (c->opt_verbose) 1627 1845 d_printf(_("Deleted %s '%s'\n"), … … 1629 1847 } else { 1630 1848 d_fprintf(stderr, _("Deleting of %s failed: %s\n"), argv[0], 1631 get_friendly_nt_error_msg( result));1849 get_friendly_nt_error_msg(status)); 1632 1850 } 1633 1851 1634 1852 done: 1635 return result;1853 return status; 1636 1854 1637 1855 } … … 1720 1938 TALLOC_CTX *mem_ctx, 1721 1939 const char *name, 1722 DOM_SID*sid,1940 struct dom_sid *sid, 1723 1941 enum lsa_SidType *type) 1724 1942 { 1725 DOM_SID*sids = NULL;1943 struct dom_sid *sids = NULL; 1726 1944 enum lsa_SidType *types = NULL; 1727 1945 struct rpc_pipe_client *pipe_hnd = NULL; 1728 1946 struct policy_handle lsa_pol; 1729 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 1730 1731 result = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 1947 NTSTATUS status, result; 1948 struct dcerpc_binding_handle *b; 1949 1950 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, 1732 1951 &pipe_hnd); 1733 if (!NT_STATUS_IS_OK(result)) { 1734 goto done; 1735 } 1736 1737 result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false, 1952 if (!NT_STATUS_IS_OK(status)) { 1953 goto done; 1954 } 1955 1956 b = pipe_hnd->binding_handle; 1957 1958 status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, false, 1738 1959 SEC_FLAG_MAXIMUM_ALLOWED, &lsa_pol); 1739 1960 1740 if (!NT_STATUS_IS_OK( result)) {1741 goto done; 1742 } 1743 1744 result= rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &lsa_pol, 1,1961 if (!NT_STATUS_IS_OK(status)) { 1962 goto done; 1963 } 1964 1965 status = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &lsa_pol, 1, 1745 1966 &name, NULL, 1, &sids, &types); 1746 1967 1747 if (NT_STATUS_IS_OK( result)) {1968 if (NT_STATUS_IS_OK(status)) { 1748 1969 sid_copy(sid, &sids[0]); 1749 1970 *type = types[0]; 1750 1971 } 1751 1972 1752 rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);1973 dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result); 1753 1974 1754 1975 done: … … 1757 1978 } 1758 1979 1759 if (!NT_STATUS_IS_OK( result) && (StrnCaseCmp(name, "S-", 2) == 0)) {1980 if (!NT_STATUS_IS_OK(status) && (StrnCaseCmp(name, "S-", 2) == 0)) { 1760 1981 1761 1982 /* Try as S-1-5-whatever */ 1762 1983 1763 DOM_SIDtmp_sid;1984 struct dom_sid tmp_sid; 1764 1985 1765 1986 if (string_to_sid(&tmp_sid, name)) { 1766 1987 sid_copy(sid, &tmp_sid); 1767 1988 *type = SID_NAME_UNKNOWN; 1768 result= NT_STATUS_OK;1989 status = NT_STATUS_OK; 1769 1990 } 1770 1991 } 1771 1992 1772 return result;1993 return status; 1773 1994 } 1774 1995 1775 1996 static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd, 1776 1997 TALLOC_CTX *mem_ctx, 1777 const DOM_SID*group_sid,1998 const struct dom_sid *group_sid, 1778 1999 const char *member) 1779 2000 { 1780 2001 struct policy_handle connect_pol, domain_pol; 1781 NTSTATUS result;2002 NTSTATUS status, result; 1782 2003 uint32 group_rid; 1783 2004 struct policy_handle group_pol; 2005 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1784 2006 1785 2007 struct samr_Ids rids, rid_types; 1786 2008 struct lsa_String lsa_acct_name; 1787 2009 1788 DOM_SIDsid;2010 struct dom_sid sid; 1789 2011 1790 2012 sid_copy(&sid, group_sid); … … 1795 2017 1796 2018 /* Get sam policy handle */ 1797 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,2019 status = dcerpc_samr_Connect2(b, mem_ctx, 1798 2020 pipe_hnd->desthost, 1799 2021 MAXIMUM_ALLOWED_ACCESS, 1800 &connect_pol); 2022 &connect_pol, 2023 &result); 2024 if (!NT_STATUS_IS_OK(status)) { 2025 return status; 2026 } 1801 2027 if (!NT_STATUS_IS_OK(result)) { 1802 2028 return result; … … 1804 2030 1805 2031 /* Get domain policy handle */ 1806 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2032 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1807 2033 &connect_pol, 1808 2034 MAXIMUM_ALLOWED_ACCESS, 1809 2035 &sid, 1810 &domain_pol); 2036 &domain_pol, 2037 &result); 2038 if (!NT_STATUS_IS_OK(status)) { 2039 return status; 2040 } 1811 2041 if (!NT_STATUS_IS_OK(result)) { 1812 2042 return result; … … 1815 2045 init_lsa_String(&lsa_acct_name, member); 1816 2046 1817 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,2047 status = dcerpc_samr_LookupNames(b, mem_ctx, 1818 2048 &domain_pol, 1819 2049 1, 1820 2050 &lsa_acct_name, 1821 2051 &rids, 1822 &rid_types );1823 1824 if (!NT_STATUS_IS_OK( result)) {2052 &rid_types, 2053 &result); 2054 if (!NT_STATUS_IS_OK(status)) { 1825 2055 d_fprintf(stderr, _("Could not lookup up group member %s\n"), 1826 2056 member); … … 1828 2058 } 1829 2059 1830 result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx, 2060 if (!NT_STATUS_IS_OK(result)) { 2061 status = result; 2062 d_fprintf(stderr, _("Could not lookup up group member %s\n"), 2063 member); 2064 goto done; 2065 } 2066 2067 status = dcerpc_samr_OpenGroup(b, mem_ctx, 1831 2068 &domain_pol, 1832 2069 MAXIMUM_ALLOWED_ACCESS, 1833 2070 group_rid, 1834 &group_pol); 2071 &group_pol, 2072 &result); 2073 if (!NT_STATUS_IS_OK(status)) { 2074 goto done; 2075 } 1835 2076 1836 2077 if (!NT_STATUS_IS_OK(result)) { 1837 goto done; 1838 } 1839 1840 result = rpccli_samr_AddGroupMember(pipe_hnd, mem_ctx, 2078 status = result; 2079 goto done; 2080 } 2081 2082 status = dcerpc_samr_AddGroupMember(b, mem_ctx, 1841 2083 &group_pol, 1842 2084 rids.ids[0], 1843 0x0005); /* unknown flags */ 2085 0x0005, /* unknown flags */ 2086 &result); 2087 if (!NT_STATUS_IS_OK(status)) { 2088 goto done; 2089 } 2090 2091 status = result; 1844 2092 1845 2093 done: 1846 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);1847 return result;2094 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2095 return status; 1848 2096 } 1849 2097 1850 2098 static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd, 1851 2099 TALLOC_CTX *mem_ctx, 1852 const DOM_SID*alias_sid,2100 const struct dom_sid *alias_sid, 1853 2101 const char *member) 1854 2102 { 1855 2103 struct policy_handle connect_pol, domain_pol; 1856 NTSTATUS result;2104 NTSTATUS status, result; 1857 2105 uint32 alias_rid; 1858 2106 struct policy_handle alias_pol; 1859 1860 DOM_SID member_sid; 2107 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2108 2109 struct dom_sid member_sid; 1861 2110 enum lsa_SidType member_type; 1862 2111 1863 DOM_SIDsid;2112 struct dom_sid sid; 1864 2113 1865 2114 sid_copy(&sid, alias_sid); … … 1879 2128 1880 2129 /* Get sam policy handle */ 1881 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,2130 status = dcerpc_samr_Connect2(b, mem_ctx, 1882 2131 pipe_hnd->desthost, 1883 2132 MAXIMUM_ALLOWED_ACCESS, 1884 &connect_pol); 2133 &connect_pol, 2134 &result); 2135 if (!NT_STATUS_IS_OK(status)) { 2136 goto done; 2137 } 1885 2138 if (!NT_STATUS_IS_OK(result)) { 2139 status = result; 1886 2140 goto done; 1887 2141 } 1888 2142 1889 2143 /* Get domain policy handle */ 1890 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2144 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1891 2145 &connect_pol, 1892 2146 MAXIMUM_ALLOWED_ACCESS, 1893 2147 &sid, 1894 &domain_pol); 2148 &domain_pol, 2149 &result); 2150 if (!NT_STATUS_IS_OK(status)) { 2151 goto done; 2152 } 1895 2153 if (!NT_STATUS_IS_OK(result)) { 1896 goto done; 1897 } 1898 1899 result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 2154 status = result; 2155 goto done; 2156 } 2157 2158 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1900 2159 &domain_pol, 1901 2160 MAXIMUM_ALLOWED_ACCESS, 1902 2161 alias_rid, 1903 &alias_pol); 1904 2162 &alias_pol, 2163 &result); 2164 if (!NT_STATUS_IS_OK(status)) { 2165 return status; 2166 } 1905 2167 if (!NT_STATUS_IS_OK(result)) { 1906 2168 return result; 1907 2169 } 1908 2170 1909 result = rpccli_samr_AddAliasMember(pipe_hnd, mem_ctx,2171 status = dcerpc_samr_AddAliasMember(b, mem_ctx, 1910 2172 &alias_pol, 1911 &member_sid); 1912 1913 if (!NT_STATUS_IS_OK(result)) { 1914 return result; 1915 } 2173 &member_sid, 2174 &result); 2175 if (!NT_STATUS_IS_OK(status)) { 2176 return status; 2177 } 2178 2179 status = result; 1916 2180 1917 2181 done: 1918 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);1919 return result;2182 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2183 return status; 1920 2184 } 1921 2185 1922 2186 static NTSTATUS rpc_group_addmem_internals(struct net_context *c, 1923 const DOM_SID*domain_sid,2187 const struct dom_sid *domain_sid, 1924 2188 const char *domain_name, 1925 2189 struct cli_state *cli, … … 1929 2193 const char **argv) 1930 2194 { 1931 DOM_SIDgroup_sid;2195 struct dom_sid group_sid; 1932 2196 enum lsa_SidType group_type; 1933 2197 … … 1987 2251 struct rpc_pipe_client *pipe_hnd, 1988 2252 TALLOC_CTX *mem_ctx, 1989 const DOM_SID*group_sid,2253 const struct dom_sid *group_sid, 1990 2254 const char *member) 1991 2255 { 1992 2256 struct policy_handle connect_pol, domain_pol; 1993 NTSTATUS result;2257 NTSTATUS status, result; 1994 2258 uint32 group_rid; 1995 2259 struct policy_handle group_pol; 2260 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 1996 2261 1997 2262 struct samr_Ids rids, rid_types; 1998 2263 struct lsa_String lsa_acct_name; 1999 2264 2000 DOM_SIDsid;2265 struct dom_sid sid; 2001 2266 2002 2267 sid_copy(&sid, group_sid); … … 2006 2271 2007 2272 /* Get sam policy handle */ 2008 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,2273 status = dcerpc_samr_Connect2(b, mem_ctx, 2009 2274 pipe_hnd->desthost, 2010 2275 MAXIMUM_ALLOWED_ACCESS, 2011 &connect_pol); 2012 if (!NT_STATUS_IS_OK(result)) 2276 &connect_pol, 2277 &result); 2278 if (!NT_STATUS_IS_OK(status)) { 2279 return status; 2280 } 2281 if (!NT_STATUS_IS_OK(result)) { 2013 2282 return result; 2283 } 2284 2014 2285 2015 2286 /* Get domain policy handle */ 2016 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2287 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2017 2288 &connect_pol, 2018 2289 MAXIMUM_ALLOWED_ACCESS, 2019 2290 &sid, 2020 &domain_pol); 2021 if (!NT_STATUS_IS_OK(result)) 2291 &domain_pol, 2292 &result); 2293 if (!NT_STATUS_IS_OK(status)) { 2294 return status; 2295 } 2296 if (!NT_STATUS_IS_OK(result)) { 2022 2297 return result; 2298 } 2023 2299 2024 2300 init_lsa_String(&lsa_acct_name, member); 2025 2301 2026 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,2302 status = dcerpc_samr_LookupNames(b, mem_ctx, 2027 2303 &domain_pol, 2028 2304 1, 2029 2305 &lsa_acct_name, 2030 2306 &rids, 2031 &rid_types); 2032 if (!NT_STATUS_IS_OK(result)) { 2307 &rid_types, 2308 &result); 2309 if (!NT_STATUS_IS_OK(status)) { 2033 2310 d_fprintf(stderr, _("Could not lookup up group member %s\n"), 2034 2311 member); … … 2036 2313 } 2037 2314 2038 result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx, 2315 if (!NT_STATUS_IS_OK(result)) { 2316 status = result; 2317 d_fprintf(stderr, _("Could not lookup up group member %s\n"), 2318 member); 2319 goto done; 2320 } 2321 2322 status = dcerpc_samr_OpenGroup(b, mem_ctx, 2039 2323 &domain_pol, 2040 2324 MAXIMUM_ALLOWED_ACCESS, 2041 2325 group_rid, 2042 &group_pol); 2043 2044 if (!NT_STATUS_IS_OK(result)) 2045 goto done; 2046 2047 result = rpccli_samr_DeleteGroupMember(pipe_hnd, mem_ctx, 2326 &group_pol, 2327 &result); 2328 if (!NT_STATUS_IS_OK(status)) { 2329 goto done; 2330 } 2331 if (!NT_STATUS_IS_OK(result)) { 2332 status = result; 2333 goto done; 2334 } 2335 2336 status = dcerpc_samr_DeleteGroupMember(b, mem_ctx, 2048 2337 &group_pol, 2049 rids.ids[0]); 2050 2338 rids.ids[0], 2339 &result); 2340 if (!NT_STATUS_IS_OK(status)) { 2341 goto done; 2342 } 2343 2344 status = result; 2051 2345 done: 2052 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);2053 return result;2346 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2347 return status; 2054 2348 } 2055 2349 2056 2350 static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd, 2057 2351 TALLOC_CTX *mem_ctx, 2058 const DOM_SID*alias_sid,2352 const struct dom_sid *alias_sid, 2059 2353 const char *member) 2060 2354 { 2061 2355 struct policy_handle connect_pol, domain_pol; 2062 NTSTATUS result;2356 NTSTATUS status, result; 2063 2357 uint32 alias_rid; 2064 2358 struct policy_handle alias_pol; 2065 2066 DOM_SID member_sid; 2359 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2360 2361 struct dom_sid member_sid; 2067 2362 enum lsa_SidType member_type; 2068 2363 2069 DOM_SIDsid;2364 struct dom_sid sid; 2070 2365 2071 2366 sid_copy(&sid, alias_sid); … … 2084 2379 2085 2380 /* Get sam policy handle */ 2086 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,2381 status = dcerpc_samr_Connect2(b, mem_ctx, 2087 2382 pipe_hnd->desthost, 2088 2383 MAXIMUM_ALLOWED_ACCESS, 2089 &connect_pol); 2384 &connect_pol, 2385 &result); 2386 if (!NT_STATUS_IS_OK(status)) { 2387 goto done; 2388 } 2090 2389 if (!NT_STATUS_IS_OK(result)) { 2390 status = result; 2091 2391 goto done; 2092 2392 } 2093 2393 2094 2394 /* Get domain policy handle */ 2095 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2395 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2096 2396 &connect_pol, 2097 2397 MAXIMUM_ALLOWED_ACCESS, 2098 2398 &sid, 2099 &domain_pol); 2399 &domain_pol, 2400 &result); 2401 if (!NT_STATUS_IS_OK(status)) { 2402 goto done; 2403 } 2100 2404 if (!NT_STATUS_IS_OK(result)) { 2101 goto done; 2102 } 2103 2104 result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 2405 status = result; 2406 goto done; 2407 } 2408 2409 status = dcerpc_samr_OpenAlias(b, mem_ctx, 2105 2410 &domain_pol, 2106 2411 MAXIMUM_ALLOWED_ACCESS, 2107 2412 alias_rid, 2108 &alias_pol); 2109 2110 if (!NT_STATUS_IS_OK(result)) 2413 &alias_pol, 2414 &result); 2415 if (!NT_STATUS_IS_OK(status)) { 2416 return status; 2417 } 2418 2419 if (!NT_STATUS_IS_OK(result)) { 2111 2420 return result; 2112 2113 result = rpccli_samr_DeleteAliasMember(pipe_hnd, mem_ctx, 2421 } 2422 2423 status = dcerpc_samr_DeleteAliasMember(b, mem_ctx, 2114 2424 &alias_pol, 2115 &member_sid); 2116 2117 if (!NT_STATUS_IS_OK(result)) 2118 return result; 2425 &member_sid, 2426 &result); 2427 2428 if (!NT_STATUS_IS_OK(status)) { 2429 return status; 2430 } 2431 2432 status = result; 2119 2433 2120 2434 done: 2121 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);2122 return result;2435 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2436 return status; 2123 2437 } 2124 2438 2125 2439 static NTSTATUS rpc_group_delmem_internals(struct net_context *c, 2126 const DOM_SID*domain_sid,2440 const struct dom_sid *domain_sid, 2127 2441 const char *domain_name, 2128 2442 struct cli_state *cli, … … 2132 2446 const char **argv) 2133 2447 { 2134 DOM_SIDgroup_sid;2448 struct dom_sid group_sid; 2135 2449 enum lsa_SidType group_type; 2136 2450 … … 2204 2518 2205 2519 static NTSTATUS rpc_group_list_internals(struct net_context *c, 2206 const DOM_SID*domain_sid,2520 const struct dom_sid *domain_sid, 2207 2521 const char *domain_name, 2208 2522 struct cli_state *cli, … … 2213 2527 { 2214 2528 struct policy_handle connect_pol, domain_pol; 2215 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2529 NTSTATUS status, result; 2216 2530 uint32 start_idx=0, max_entries=250, num_entries, i, loop_count = 0; 2217 2531 struct samr_SamArray *groups = NULL; … … 2219 2533 bool local = false; 2220 2534 bool builtin = false; 2535 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2221 2536 2222 2537 if (c->display_usage) { … … 2253 2568 /* Get sam policy handle */ 2254 2569 2255 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,2570 status = dcerpc_samr_Connect2(b, mem_ctx, 2256 2571 pipe_hnd->desthost, 2257 2572 MAXIMUM_ALLOWED_ACCESS, 2258 &connect_pol); 2573 &connect_pol, 2574 &result); 2575 if (!NT_STATUS_IS_OK(status)) { 2576 goto done; 2577 } 2259 2578 if (!NT_STATUS_IS_OK(result)) { 2579 status = result; 2260 2580 goto done; 2261 2581 } … … 2263 2583 /* Get domain policy handle */ 2264 2584 2265 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2585 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2266 2586 &connect_pol, 2267 2587 MAXIMUM_ALLOWED_ACCESS, 2268 2588 CONST_DISCARD(struct dom_sid2 *, domain_sid), 2269 &domain_pol); 2589 &domain_pol, 2590 &result); 2591 if (!NT_STATUS_IS_OK(status)) { 2592 goto done; 2593 } 2270 2594 if (!NT_STATUS_IS_OK(result)) { 2595 status = result; 2271 2596 goto done; 2272 2597 } … … 2282 2607 if (!global) break; 2283 2608 2284 get_query_dispinfo_params(2609 dcerpc_get_query_dispinfo_params( 2285 2610 loop_count, &max_entries, &max_size); 2286 2611 2287 result = rpccli_samr_QueryDisplayInfo(pipe_hnd, mem_ctx,2612 status = dcerpc_samr_QueryDisplayInfo(b, mem_ctx, 2288 2613 &domain_pol, 2289 2614 3, … … 2293 2618 &total_size, 2294 2619 &returned_size, 2295 &info); 2620 &info, 2621 &result); 2622 if (!NT_STATUS_IS_OK(status)) { 2623 goto done; 2624 } 2296 2625 num_entries = info.info3.count; 2297 2626 start_idx += info.info3.count; … … 2321 2650 if (!local) break; 2322 2651 2323 result = rpccli_samr_EnumDomainAliases(pipe_hnd, mem_ctx,2652 status = dcerpc_samr_EnumDomainAliases(b, mem_ctx, 2324 2653 &domain_pol, 2325 2654 &start_idx, 2326 2655 &groups, 2327 2656 0xffff, 2328 &num_entries); 2657 &num_entries, 2658 &result); 2659 if (!NT_STATUS_IS_OK(status)) { 2660 goto done; 2661 } 2329 2662 if (!NT_STATUS_IS_OK(result) && 2330 2663 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) … … 2339 2672 struct policy_handle alias_pol; 2340 2673 union samr_AliasInfo *info = NULL; 2341 2342 if ((NT_STATUS_IS_OK(rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 2343 &domain_pol, 2344 0x8, 2345 groups->entries[i].idx, 2346 &alias_pol))) && 2347 (NT_STATUS_IS_OK(rpccli_samr_QueryAliasInfo(pipe_hnd, mem_ctx, 2348 &alias_pol, 2349 3, 2350 &info))) && 2351 (NT_STATUS_IS_OK(rpccli_samr_Close(pipe_hnd, mem_ctx, 2352 &alias_pol)))) { 2353 description = info->description.string; 2674 NTSTATUS _result; 2675 2676 status = dcerpc_samr_OpenAlias(b, mem_ctx, 2677 &domain_pol, 2678 0x8, 2679 groups->entries[i].idx, 2680 &alias_pol, 2681 &_result); 2682 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2683 status = dcerpc_samr_QueryAliasInfo(b, mem_ctx, 2684 &alias_pol, 2685 3, 2686 &info, 2687 &_result); 2688 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2689 status = dcerpc_samr_Close(b, mem_ctx, 2690 &alias_pol, 2691 &_result); 2692 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2693 description = info->description.string; 2694 } 2695 } 2354 2696 } 2355 2697 } … … 2364 2706 } 2365 2707 } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); 2366 rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);2708 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2367 2709 /* Get builtin policy handle */ 2368 2710 2369 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,2711 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2370 2712 &connect_pol, 2371 2713 MAXIMUM_ALLOWED_ACCESS, 2372 2714 CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin), 2373 &domain_pol); 2715 &domain_pol, 2716 &result); 2717 if (!NT_STATUS_IS_OK(status)) { 2718 goto done; 2719 } 2374 2720 if (!NT_STATUS_IS_OK(result)) { 2375 goto done; 2376 } 2721 status = result; 2722 goto done; 2723 } 2724 2377 2725 /* query builtin aliases */ 2378 2726 start_idx = 0; … … 2380 2728 if (!builtin) break; 2381 2729 2382 result = rpccli_samr_EnumDomainAliases(pipe_hnd, mem_ctx,2730 status = dcerpc_samr_EnumDomainAliases(b, mem_ctx, 2383 2731 &domain_pol, 2384 2732 &start_idx, 2385 2733 &groups, 2386 2734 max_entries, 2387 &num_entries); 2735 &num_entries, 2736 &result); 2737 if (!NT_STATUS_IS_OK(status)) { 2738 break; 2739 } 2388 2740 if (!NT_STATUS_IS_OK(result) && 2389 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) 2741 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { 2742 status = result; 2390 2743 break; 2744 } 2391 2745 2392 2746 for (i = 0; i < num_entries; i++) { … … 2398 2752 struct policy_handle alias_pol; 2399 2753 union samr_AliasInfo *info = NULL; 2400 2401 if ((NT_STATUS_IS_OK(rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 2402 &domain_pol, 2403 0x8, 2404 groups->entries[i].idx, 2405 &alias_pol))) && 2406 (NT_STATUS_IS_OK(rpccli_samr_QueryAliasInfo(pipe_hnd, mem_ctx, 2407 &alias_pol, 2408 3, 2409 &info))) && 2410 (NT_STATUS_IS_OK(rpccli_samr_Close(pipe_hnd, mem_ctx, 2411 &alias_pol)))) { 2412 description = info->description.string; 2754 NTSTATUS _result; 2755 2756 status = dcerpc_samr_OpenAlias(b, mem_ctx, 2757 &domain_pol, 2758 0x8, 2759 groups->entries[i].idx, 2760 &alias_pol, 2761 &_result); 2762 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2763 status = dcerpc_samr_QueryAliasInfo(b, mem_ctx, 2764 &alias_pol, 2765 3, 2766 &info, 2767 &_result); 2768 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2769 status = dcerpc_samr_Close(b, mem_ctx, 2770 &alias_pol, 2771 &_result); 2772 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(_result)) { 2773 description = info->description.string; 2774 } 2775 } 2413 2776 } 2414 2777 } … … 2424 2787 } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); 2425 2788 2789 status = result; 2790 2426 2791 done: 2427 return result;2792 return status; 2428 2793 } 2429 2794 … … 2439 2804 TALLOC_CTX *mem_ctx, 2440 2805 const char *domain_name, 2441 const DOM_SID*domain_sid,2806 const struct dom_sid *domain_sid, 2442 2807 struct policy_handle *domain_pol, 2443 2808 uint32 rid) 2444 2809 { 2445 NTSTATUS result ;2810 NTSTATUS result, status; 2446 2811 struct policy_handle group_pol; 2447 2812 uint32 num_members, *group_rids; 2448 2813 int i; 2449 struct samr_Rid TypeArray *rids = NULL;2814 struct samr_RidAttrArray *rids = NULL; 2450 2815 struct lsa_Strings names; 2451 2816 struct samr_Ids types; 2817 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2452 2818 2453 2819 fstring sid_str; 2454 2820 sid_to_fstring(sid_str, domain_sid); 2455 2821 2456 result = rpccli_samr_OpenGroup(pipe_hnd, mem_ctx,2822 status = dcerpc_samr_OpenGroup(b, mem_ctx, 2457 2823 domain_pol, 2458 2824 MAXIMUM_ALLOWED_ACCESS, 2459 2825 rid, 2460 &group_pol); 2461 2462 if (!NT_STATUS_IS_OK(result)) 2826 &group_pol, 2827 &result); 2828 if (!NT_STATUS_IS_OK(status)) { 2829 return status; 2830 } 2831 if (!NT_STATUS_IS_OK(result)) { 2463 2832 return result; 2464 2465 result = rpccli_samr_QueryGroupMember(pipe_hnd, mem_ctx, 2833 } 2834 2835 status = dcerpc_samr_QueryGroupMember(b, mem_ctx, 2466 2836 &group_pol, 2467 &rids); 2468 2469 if (!NT_STATUS_IS_OK(result)) 2837 &rids, 2838 &result); 2839 if (!NT_STATUS_IS_OK(status)) { 2840 return status; 2841 } 2842 if (!NT_STATUS_IS_OK(result)) { 2470 2843 return result; 2844 } 2471 2845 2472 2846 num_members = rids->count; … … 2479 2853 this_time = num_members; 2480 2854 2481 result = rpccli_samr_LookupRids(pipe_hnd, mem_ctx,2855 status = dcerpc_samr_LookupRids(b, mem_ctx, 2482 2856 domain_pol, 2483 2857 this_time, 2484 2858 group_rids, 2485 2859 &names, 2486 &types); 2487 2488 if (!NT_STATUS_IS_OK(result)) 2860 &types, 2861 &result); 2862 if (!NT_STATUS_IS_OK(status)) { 2863 return status; 2864 } 2865 if (!NT_STATUS_IS_OK(result)) { 2489 2866 return result; 2867 } 2490 2868 2491 2869 /* We only have users as members, but make the output … … 2518 2896 uint32 rid) 2519 2897 { 2520 NTSTATUS result ;2898 NTSTATUS result, status; 2521 2899 struct rpc_pipe_client *lsa_pipe; 2522 2900 struct policy_handle alias_pol, lsa_pol; 2523 2901 uint32 num_members; 2524 DOM_SID*alias_sids;2902 struct dom_sid *alias_sids; 2525 2903 char **domains; 2526 2904 char **names; … … 2528 2906 int i; 2529 2907 struct lsa_SidArray sid_array; 2530 2531 result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 2908 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2909 2910 status = dcerpc_samr_OpenAlias(b, mem_ctx, 2532 2911 domain_pol, 2533 2912 MAXIMUM_ALLOWED_ACCESS, 2534 2913 rid, 2535 &alias_pol); 2536 2537 if (!NT_STATUS_IS_OK(result)) 2914 &alias_pol, 2915 &result); 2916 if (!NT_STATUS_IS_OK(status)) { 2917 return status; 2918 } 2919 if (!NT_STATUS_IS_OK(result)) { 2538 2920 return result; 2539 2540 result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx, 2921 } 2922 2923 status = dcerpc_samr_GetMembersInAlias(b, mem_ctx, 2541 2924 &alias_pol, 2542 &sid_array); 2543 2925 &sid_array, 2926 &result); 2927 if (!NT_STATUS_IS_OK(status)) { 2928 d_fprintf(stderr, _("Couldn't list alias members\n")); 2929 return status; 2930 } 2544 2931 if (!NT_STATUS_IS_OK(result)) { 2545 2932 d_fprintf(stderr, _("Couldn't list alias members\n")); … … 2571 2958 } 2572 2959 2573 alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members);2960 alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_members); 2574 2961 if (!alias_sids) { 2575 2962 d_fprintf(stderr, _("Out of memory\n")); … … 2614 3001 2615 3002 static NTSTATUS rpc_group_members_internals(struct net_context *c, 2616 const DOM_SID*domain_sid,3003 const struct dom_sid *domain_sid, 2617 3004 const char *domain_name, 2618 3005 struct cli_state *cli, … … 2622 3009 const char **argv) 2623 3010 { 2624 NTSTATUS result ;3011 NTSTATUS result, status; 2625 3012 struct policy_handle connect_pol, domain_pol; 2626 3013 struct samr_Ids rids, rid_types; 2627 3014 struct lsa_String lsa_acct_name; 3015 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2628 3016 2629 3017 /* Get sam policy handle */ 2630 3018 2631 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,3019 status = dcerpc_samr_Connect2(b, mem_ctx, 2632 3020 pipe_hnd->desthost, 2633 3021 MAXIMUM_ALLOWED_ACCESS, 2634 &connect_pol); 2635 2636 if (!NT_STATUS_IS_OK(result)) 3022 &connect_pol, 3023 &result); 3024 if (!NT_STATUS_IS_OK(status)) { 3025 return status; 3026 } 3027 if (!NT_STATUS_IS_OK(result)) { 2637 3028 return result; 3029 } 2638 3030 2639 3031 /* Get domain policy handle */ 2640 3032 2641 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,3033 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2642 3034 &connect_pol, 2643 3035 MAXIMUM_ALLOWED_ACCESS, 2644 3036 CONST_DISCARD(struct dom_sid2 *, domain_sid), 2645 &domain_pol); 2646 2647 if (!NT_STATUS_IS_OK(result)) 3037 &domain_pol, 3038 &result); 3039 if (!NT_STATUS_IS_OK(status)) { 3040 return status; 3041 } 3042 if (!NT_STATUS_IS_OK(result)) { 2648 3043 return result; 3044 } 2649 3045 2650 3046 init_lsa_String(&lsa_acct_name, argv[0]); /* sure? */ 2651 3047 2652 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,3048 status = dcerpc_samr_LookupNames(b, mem_ctx, 2653 3049 &domain_pol, 2654 3050 1, 2655 3051 &lsa_acct_name, 2656 3052 &rids, 2657 &rid_types); 3053 &rid_types, 3054 &result); 3055 if (!NT_STATUS_IS_OK(status)) { 3056 return status; 3057 } 2658 3058 2659 3059 if (!NT_STATUS_IS_OK(result)) { … … 2661 3061 /* Ok, did not find it in the global sam, try with builtin */ 2662 3062 2663 DOM_SIDsid_Builtin;2664 2665 rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);3063 struct dom_sid sid_Builtin; 3064 3065 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2666 3066 2667 3067 sid_copy(&sid_Builtin, &global_sid_Builtin); 2668 3068 2669 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,3069 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2670 3070 &connect_pol, 2671 3071 MAXIMUM_ALLOWED_ACCESS, 2672 3072 &sid_Builtin, 2673 &domain_pol); 2674 3073 &domain_pol, 3074 &result); 3075 if (!NT_STATUS_IS_OK(status)) { 3076 return status; 3077 } 2675 3078 if (!NT_STATUS_IS_OK(result)) { 2676 3079 d_fprintf(stderr, _("Couldn't find group %s\n"), … … 2679 3082 } 2680 3083 2681 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,3084 status = dcerpc_samr_LookupNames(b, mem_ctx, 2682 3085 &domain_pol, 2683 3086 1, 2684 3087 &lsa_acct_name, 2685 3088 &rids, 2686 &rid_types); 2687 3089 &rid_types, 3090 &result); 3091 if (!NT_STATUS_IS_OK(status)) { 3092 return status; 3093 } 2688 3094 if (!NT_STATUS_IS_OK(result)) { 2689 3095 d_fprintf(stderr, _("Couldn't find group %s\n"), … … 2834 3240 }; 2835 3241 2836 status = libnetapi_ init(&c->netapi_ctx);3242 status = libnetapi_net_init(&c->netapi_ctx); 2837 3243 if (status != 0) { 2838 3244 return -1; … … 2975 3381 NTSTATUS status; 2976 3382 union srvsvc_NetShareInfo info; 3383 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 2977 3384 2978 3385 /* no specific share requested, enumerate all */ … … 2985 3392 info_ctr->level = level; 2986 3393 2987 status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx,3394 status = dcerpc_srvsvc_NetShareEnumAll(b, mem_ctx, 2988 3395 pipe_hnd->desthost, 2989 3396 info_ctr, … … 2992 3399 &resume_handle, 2993 3400 &result); 3401 if (!NT_STATUS_IS_OK(status)) { 3402 return ntstatus_to_werror(status); 3403 } 2994 3404 return result; 2995 3405 } 2996 3406 2997 3407 /* request just one share */ 2998 status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx,3408 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 2999 3409 pipe_hnd->desthost, 3000 3410 argv[0], … … 3003 3413 &result); 3004 3414 3005 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 3415 if (!NT_STATUS_IS_OK(status)) { 3416 result = ntstatus_to_werror(status); 3417 goto done; 3418 } 3419 3420 if (!W_ERROR_IS_OK(result)) { 3006 3421 goto done; 3007 3422 } … … 3024 3439 3025 3440 info_ctr->ctr.ctr1 = ctr1; 3441 3442 break; 3026 3443 } 3027 3444 case 2: … … 3036 3453 3037 3454 info_ctr->ctr.ctr2 = ctr2; 3455 3456 break; 3038 3457 } 3039 3458 case 502: … … 3048 3467 3049 3468 info_ctr->ctr.ctr502 = ctr502; 3469 3470 break; 3050 3471 } 3051 3472 } /* switch */ … … 3105 3526 static bool check_share_availability(struct cli_state *cli, const char *netname) 3106 3527 { 3107 if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, netname, "A:", "", 0))) { 3528 NTSTATUS status; 3529 3530 status = cli_tcon_andx(cli, netname, "A:", "", 0); 3531 if (!NT_STATUS_IS_OK(status)) { 3108 3532 d_printf(_("skipping [%s]: not a file share.\n"), netname); 3109 3533 return false; 3110 3534 } 3111 3535 3112 if (!cli_tdis(cli)) 3536 status = cli_tdis(cli); 3537 if (!NT_STATUS_IS_OK(status)) { 3538 d_printf(_("cli_tdis returned %s\n"), nt_errstr(status)); 3113 3539 return false; 3540 } 3114 3541 3115 3542 return true; … … 3157 3584 3158 3585 static NTSTATUS rpc_share_migrate_shares_internals(struct net_context *c, 3159 const DOM_SID*domain_sid,3586 const struct dom_sid *domain_sid, 3160 3587 const char *domain_name, 3161 3588 struct cli_state *cli, … … 3173 3600 uint32 level = 502; /* includes secdesc */ 3174 3601 uint32_t parm_error = 0; 3602 struct dcerpc_binding_handle *b; 3175 3603 3176 3604 result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv, … … 3185 3613 return nt_status; 3186 3614 3615 b = srvsvc_pipe->binding_handle; 3187 3616 3188 3617 for (i = 0; i < ctr_src.ctr.ctr502->count; i++) { … … 3206 3635 info.info502 = &info502; 3207 3636 3208 nt_status = rpccli_srvsvc_NetShareAdd(srvsvc_pipe, mem_ctx,3637 nt_status = dcerpc_srvsvc_NetShareAdd(b, mem_ctx, 3209 3638 srvsvc_pipe->desthost, 3210 3639 502, … … 3212 3641 &parm_error, 3213 3642 &result); 3214 3643 if (!NT_STATUS_IS_OK(nt_status)) { 3644 printf(_("cannot add share: %s\n"), 3645 nt_errstr(nt_status)); 3646 goto done; 3647 } 3215 3648 if (W_ERROR_V(result) == W_ERROR_V(WERR_FILE_EXISTS)) { 3216 3649 printf(_(" [%s] does already exist\n"), … … 3219 3652 } 3220 3653 3221 if (!NT_STATUS_IS_OK(nt_status) || !W_ERROR_IS_OK(result)) { 3222 printf(_("cannot add share: %s\n"), win_errstr(result)); 3654 if (!W_ERROR_IS_OK(result)) { 3655 nt_status = werror_to_ntstatus(result); 3656 printf(_("cannot add share: %s\n"), 3657 win_errstr(result)); 3223 3658 goto done; 3224 3659 } … … 3276 3711 * 3277 3712 **/ 3278 static void copy_fn(const char *mnt,file_info *f,3713 static NTSTATUS copy_fn(const char *mnt, struct file_info *f, 3279 3714 const char *mask, void *state) 3280 3715 { … … 3292 3727 3293 3728 if (strequal(f->name, ".") || strequal(f->name, "..")) 3294 return ;3729 return NT_STATUS_OK; 3295 3730 3296 3731 DEBUG(3,("got mask: %s, name: %s\n", mask, f->name)); 3297 3732 3298 3733 /* DIRECTORY */ 3299 if (f->mode & aDIR) {3734 if (f->mode & FILE_ATTRIBUTE_DIRECTORY) { 3300 3735 3301 3736 DEBUG(3,("got dir: %s\n", f->name)); … … 3320 3755 default: 3321 3756 d_fprintf(stderr, _("Unsupported mode %d\n"), net_mode_share); 3322 return ;3757 return NT_STATUS_INTERNAL_ERROR; 3323 3758 } 3324 3759 3325 if (!NT_STATUS_IS_OK(nt_status)) 3760 if (!NT_STATUS_IS_OK(nt_status)) { 3326 3761 printf(_("could not handle dir %s: %s\n"), 3327 3762 dir, nt_errstr(nt_status)); 3763 return nt_status; 3764 } 3328 3765 3329 3766 /* search below that directory */ … … 3333 3770 old_dir = local_state->cwd; 3334 3771 local_state->cwd = dir; 3335 if (!sync_files(local_state, new_mask)) 3772 nt_status = sync_files(local_state, new_mask); 3773 if (!NT_STATUS_IS_OK(nt_status)) { 3336 3774 printf(_("could not handle files\n")); 3775 } 3337 3776 local_state->cwd = old_dir; 3338 3777 3339 return ;3778 return nt_status; 3340 3779 } 3341 3780 … … 3363 3802 d_fprintf(stderr, _("Unsupported file mode %d\n"), 3364 3803 net_mode_share); 3365 return ;3804 return NT_STATUS_INTERNAL_ERROR; 3366 3805 } 3367 3806 … … 3369 3808 printf(_("could not handle file %s: %s\n"), 3370 3809 filename, nt_errstr(nt_status)); 3371 3810 return nt_status; 3372 3811 } 3373 3812 … … 3381 3820 * @return Boolean result 3382 3821 **/ 3383 static boolsync_files(struct copy_clistate *cp_clistate, const char *mask)3822 static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask) 3384 3823 { 3385 3824 struct cli_state *targetcli; 3386 3825 char *targetpath = NULL; 3826 NTSTATUS status; 3387 3827 3388 3828 DEBUG(3,("calling cli_list with mask: %s\n", mask)); … … 3393 3833 "%s\n"), 3394 3834 mask, cli_errstr(cp_clistate->cli_share_src)); 3395 return false; 3396 } 3397 3398 if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) { 3835 return cli_nt_error(cp_clistate->cli_share_src); 3836 } 3837 3838 status = cli_list(targetcli, targetpath, cp_clistate->attribute, 3839 copy_fn, cp_clistate); 3840 if (!NT_STATUS_IS_OK(status)) { 3399 3841 d_fprintf(stderr, _("listing %s failed with error: %s\n"), 3400 mask, cli_errstr(targetcli)); 3401 return false; 3402 } 3403 3404 return true; 3842 mask, nt_errstr(status)); 3843 } 3844 3845 return status; 3405 3846 } 3406 3847 … … 3462 3903 3463 3904 static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, 3464 const DOM_SID*domain_sid,3905 const struct dom_sid *domain_sid, 3465 3906 const char *domain_name, 3466 3907 struct cli_state *cli, … … 3529 3970 cp_clistate.cli_share_dst = NULL; 3530 3971 cp_clistate.cwd = NULL; 3531 cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;3972 cp_clistate.attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; 3532 3973 cp_clistate.c = c; 3533 3974 … … 3559 4000 } 3560 4001 3561 if (!sync_files(&cp_clistate, mask)) { 4002 nt_status = sync_files(&cp_clistate, mask); 4003 if (!NT_STATUS_IS_OK(nt_status)) { 3562 4004 d_fprintf(stderr, _("could not handle files for share: " 3563 4005 "%s\n"), info502.name); 3564 nt_status = NT_STATUS_UNSUCCESSFUL;3565 4006 goto done; 3566 4007 } … … 3620 4061 3621 4062 static NTSTATUS rpc_share_migrate_security_internals(struct net_context *c, 3622 const DOM_SID*domain_sid,4063 const struct dom_sid *domain_sid, 3623 4064 const char *domain_name, 3624 4065 struct cli_state *cli, … … 3637 4078 uint32 level = 502; /* includes secdesc */ 3638 4079 uint32_t parm_error = 0; 4080 struct dcerpc_binding_handle *b; 3639 4081 3640 4082 result = get_share_info(c, pipe_hnd, mem_ctx, level, argc, argv, … … 3650 4092 return nt_status; 3651 4093 4094 b = srvsvc_pipe->binding_handle; 3652 4095 3653 4096 for (i = 0; i < ctr_src.ctr.ctr502->count; i++) { … … 3673 4116 3674 4117 /* finally modify the share on the dst server */ 3675 nt_status = rpccli_srvsvc_NetShareSetInfo(srvsvc_pipe, mem_ctx,4118 nt_status = dcerpc_srvsvc_NetShareSetInfo(b, mem_ctx, 3676 4119 srvsvc_pipe->desthost, 3677 4120 info502.name, … … 3680 4123 &parm_error, 3681 4124 &result); 3682 if (!NT_STATUS_IS_OK(nt_status) || !W_ERROR_IS_OK(result)) { 4125 if (!NT_STATUS_IS_OK(nt_status)) { 4126 printf(_("cannot set share-acl: %s\n"), 4127 nt_errstr(nt_status)); 4128 goto done; 4129 } 4130 if (!W_ERROR_IS_OK(result)) { 4131 nt_status = werror_to_ntstatus(result); 3683 4132 printf(_("cannot set share-acl: %s\n"), 3684 4133 win_errstr(result)); … … 3830 4279 3831 4280 struct full_alias { 3832 DOM_SIDsid;4281 struct dom_sid sid; 3833 4282 uint32 num_members; 3834 DOM_SID*members;4283 struct dom_sid *members; 3835 4284 }; 3836 4285 … … 3858 4307 TALLOC_CTX *mem_ctx, 3859 4308 struct policy_handle *connect_pol, 3860 const DOM_SID*domain_sid)4309 const struct dom_sid *domain_sid) 3861 4310 { 3862 4311 uint32 start_idx, max_entries, num_entries, i; 3863 4312 struct samr_SamArray *groups = NULL; 3864 NTSTATUS result ;4313 NTSTATUS result, status; 3865 4314 struct policy_handle domain_pol; 4315 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 3866 4316 3867 4317 /* Get domain policy handle */ 3868 4318 3869 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,4319 status = dcerpc_samr_OpenDomain(b, mem_ctx, 3870 4320 connect_pol, 3871 4321 MAXIMUM_ALLOWED_ACCESS, 3872 4322 CONST_DISCARD(struct dom_sid2 *, domain_sid), 3873 &domain_pol); 3874 if (!NT_STATUS_IS_OK(result)) 4323 &domain_pol, 4324 &result); 4325 if (!NT_STATUS_IS_OK(status)) { 4326 return status; 4327 } 4328 if (!NT_STATUS_IS_OK(result)) { 3875 4329 return result; 4330 } 3876 4331 3877 4332 start_idx = 0; … … 3879 4334 3880 4335 do { 3881 result = rpccli_samr_EnumDomainAliases(pipe_hnd, mem_ctx,4336 status = dcerpc_samr_EnumDomainAliases(b, mem_ctx, 3882 4337 &domain_pol, 3883 4338 &start_idx, 3884 4339 &groups, 3885 4340 max_entries, 3886 &num_entries); 4341 &num_entries, 4342 &result); 4343 if (!NT_STATUS_IS_OK(status)) { 4344 goto done; 4345 } 3887 4346 for (i = 0; i < num_entries; i++) { 3888 4347 … … 3891 4350 struct lsa_SidArray sid_array; 3892 4351 int j; 3893 3894 result = rpccli_samr_OpenAlias(pipe_hnd, mem_ctx, 4352 NTSTATUS _result; 4353 4354 status = dcerpc_samr_OpenAlias(b, mem_ctx, 3895 4355 &domain_pol, 3896 4356 MAXIMUM_ALLOWED_ACCESS, 3897 4357 groups->entries[i].idx, 3898 &alias_pol); 3899 if (!NT_STATUS_IS_OK(result)) 4358 &alias_pol, 4359 &_result); 4360 if (!NT_STATUS_IS_OK(status)) { 3900 4361 goto done; 3901 3902 result = rpccli_samr_GetMembersInAlias(pipe_hnd, mem_ctx, 4362 } 4363 if (!NT_STATUS_IS_OK(_result)) { 4364 status = _result; 4365 goto done; 4366 } 4367 4368 status = dcerpc_samr_GetMembersInAlias(b, mem_ctx, 3903 4369 &alias_pol, 3904 &sid_array); 3905 if (!NT_STATUS_IS_OK(result)) 4370 &sid_array, 4371 &_result); 4372 if (!NT_STATUS_IS_OK(status)) { 3906 4373 goto done; 4374 } 4375 if (!NT_STATUS_IS_OK(_result)) { 4376 status = _result; 4377 goto done; 4378 } 3907 4379 3908 4380 alias.num_members = sid_array.num_sids; 3909 4381 3910 result = rpccli_samr_Close(pipe_hnd, mem_ctx, &alias_pol);3911 if (!NT_STATUS_IS_OK( result))4382 status = dcerpc_samr_Close(b, mem_ctx, &alias_pol, &_result); 4383 if (!NT_STATUS_IS_OK(status)) { 3912 4384 goto done; 4385 } 4386 if (!NT_STATUS_IS_OK(_result)) { 4387 status = _result; 4388 goto done; 4389 } 3913 4390 3914 4391 alias.members = NULL; 3915 4392 3916 4393 if (alias.num_members > 0) { 3917 alias.members = SMB_MALLOC_ARRAY( DOM_SID, alias.num_members);4394 alias.members = SMB_MALLOC_ARRAY(struct dom_sid, alias.num_members); 3918 4395 3919 4396 for (j = 0; j < alias.num_members; j++) … … 3922 4399 } 3923 4400 3924 sid_co py(&alias.sid, domain_sid);3925 sid_append_rid(&alias.sid,groups->entries[i].idx);4401 sid_compose(&alias.sid, domain_sid, 4402 groups->entries[i].idx); 3926 4403 3927 4404 push_alias(mem_ctx, &alias); … … 3929 4406 } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); 3930 4407 3931 result= NT_STATUS_OK;4408 status = NT_STATUS_OK; 3932 4409 3933 4410 done: 3934 rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);3935 3936 return result;4411 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 4412 4413 return status; 3937 4414 } 3938 4415 … … 3942 4419 3943 4420 static NTSTATUS rpc_aliaslist_dump(struct net_context *c, 3944 const DOM_SID*domain_sid,4421 const struct dom_sid *domain_sid, 3945 4422 const char *domain_name, 3946 4423 struct cli_state *cli, … … 3953 4430 NTSTATUS result; 3954 4431 struct policy_handle lsa_pol; 4432 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 3955 4433 3956 4434 result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, … … 3997 4475 } 3998 4476 3999 rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);4477 dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result); 4000 4478 4001 4479 return NT_STATUS_OK; … … 4008 4486 4009 4487 static NTSTATUS rpc_aliaslist_internals(struct net_context *c, 4010 const DOM_SID*domain_sid,4488 const struct dom_sid *domain_sid, 4011 4489 const char *domain_name, 4012 4490 struct cli_state *cli, … … 4016 4494 const char **argv) 4017 4495 { 4018 NTSTATUS result ;4496 NTSTATUS result, status; 4019 4497 struct policy_handle connect_pol; 4020 4021 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, 4498 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 4499 4500 status = dcerpc_samr_Connect2(b, mem_ctx, 4022 4501 pipe_hnd->desthost, 4023 4502 MAXIMUM_ALLOWED_ACCESS, 4024 &connect_pol); 4025 4026 if (!NT_STATUS_IS_OK(result)) 4027 goto done; 4028 4029 result = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol, 4503 &connect_pol, 4504 &result); 4505 if (!NT_STATUS_IS_OK(status)) { 4506 goto done; 4507 } 4508 if (!NT_STATUS_IS_OK(result)) { 4509 status = result; 4510 goto done; 4511 } 4512 4513 status = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol, 4030 4514 &global_sid_Builtin); 4031 4032 if (!NT_STATUS_IS_OK(result))4033 goto done;4034 4035 result= rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,4515 if (!NT_STATUS_IS_OK(status)) { 4516 goto done; 4517 } 4518 4519 status = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol, 4036 4520 domain_sid); 4037 4521 4038 rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_pol);4522 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 4039 4523 done: 4040 return result;4041 } 4042 4043 static void init_user_token( NT_USER_TOKEN *token, DOM_SID*user_sid)4524 return status; 4525 } 4526 4527 static void init_user_token(struct security_token *token, struct dom_sid *user_sid) 4044 4528 { 4045 4529 token->num_sids = 4; 4046 4530 4047 if (!(token-> user_sids = SMB_MALLOC_ARRAY(DOM_SID, 4))) {4531 if (!(token->sids = SMB_MALLOC_ARRAY(struct dom_sid, 4))) { 4048 4532 d_fprintf(stderr, "malloc %s\n",_("failed")); 4049 4533 token->num_sids = 0; … … 4051 4535 } 4052 4536 4053 token-> user_sids[0] = *user_sid;4054 sid_copy(&token-> user_sids[1], &global_sid_World);4055 sid_copy(&token-> user_sids[2], &global_sid_Network);4056 sid_copy(&token-> user_sids[3], &global_sid_Authenticated_Users);4057 } 4058 4059 static void free_user_token( NT_USER_TOKEN*token)4060 { 4061 SAFE_FREE(token-> user_sids);4062 } 4063 4064 static void add_sid_to_token( NT_USER_TOKEN *token, DOM_SID*sid)4065 { 4066 if ( is_sid_in_token(token, sid))4537 token->sids[0] = *user_sid; 4538 sid_copy(&token->sids[1], &global_sid_World); 4539 sid_copy(&token->sids[2], &global_sid_Network); 4540 sid_copy(&token->sids[3], &global_sid_Authenticated_Users); 4541 } 4542 4543 static void free_user_token(struct security_token *token) 4544 { 4545 SAFE_FREE(token->sids); 4546 } 4547 4548 static void add_sid_to_token(struct security_token *token, struct dom_sid *sid) 4549 { 4550 if (security_token_has_sid(token, sid)) 4067 4551 return; 4068 4552 4069 token-> user_sids = SMB_REALLOC_ARRAY(token->user_sids, DOM_SID, token->num_sids+1);4070 if (!token-> user_sids) {4553 token->sids = SMB_REALLOC_ARRAY(token->sids, struct dom_sid, token->num_sids+1); 4554 if (!token->sids) { 4071 4555 return; 4072 4556 } 4073 4557 4074 sid_copy(&token-> user_sids[token->num_sids], sid);4558 sid_copy(&token->sids[token->num_sids], sid); 4075 4559 4076 4560 token->num_sids += 1; … … 4079 4563 struct user_token { 4080 4564 fstring name; 4081 NT_USER_TOKENtoken;4565 struct security_token token; 4082 4566 }; 4083 4567 … … 4089 4573 4090 4574 for (i=0; i<token->token.num_sids; i++) { 4091 d_printf(" %s\n", sid_string_tos(&token->token. user_sids[i]));4092 } 4093 } 4094 4095 static bool is_alias_member( DOM_SID*sid, struct full_alias *alias)4575 d_printf(" %s\n", sid_string_tos(&token->token.sids[i])); 4576 } 4577 } 4578 4579 static bool is_alias_member(struct dom_sid *sid, struct full_alias *alias) 4096 4580 { 4097 4581 int i; 4098 4582 4099 4583 for (i=0; i<alias->num_members; i++) { 4100 if ( sid_compare(sid, &alias->members[i]) == 0)4584 if (dom_sid_compare(sid, &alias->members[i]) == 0) 4101 4585 return true; 4102 4586 } … … 4105 4589 } 4106 4590 4107 static void collect_sid_memberships( NT_USER_TOKEN *token, DOM_SIDsid)4591 static void collect_sid_memberships(struct security_token *token, struct dom_sid sid) 4108 4592 { 4109 4593 int i; … … 4122 4606 */ 4123 4607 4124 static void collect_alias_memberships( NT_USER_TOKEN*token)4608 static void collect_alias_memberships(struct security_token *token) 4125 4609 { 4126 4610 int num_global_sids = token->num_sids; … … 4128 4612 4129 4613 for (i=0; i<num_global_sids; i++) { 4130 collect_sid_memberships(token, token-> user_sids[i]);4131 } 4132 } 4133 4134 static bool get_user_sids(const char *domain, const char *user, NT_USER_TOKEN*token)4614 collect_sid_memberships(token, token->sids[i]); 4615 } 4616 } 4617 4618 static bool get_user_sids(const char *domain, const char *user, struct security_token *token) 4135 4619 { 4136 4620 wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; … … 4138 4622 fstring full_name; 4139 4623 struct wbcDomainSid wsid; 4140 char *sid_str = NULL;4141 DOM_SIDuser_sid;4624 char sid_str[WBC_SID_STRING_BUFLEN]; 4625 struct dom_sid user_sid; 4142 4626 uint32_t num_groups; 4143 4627 gid_t *groups = NULL; … … 4157 4641 } 4158 4642 4159 wbc_status = wbcSidToString(&wsid, &sid_str); 4160 if (!WBC_ERROR_IS_OK(wbc_status)) { 4161 return false; 4162 } 4163 4164 if (type != SID_NAME_USER) { 4165 wbcFreeMemory(sid_str); 4643 wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str)); 4644 4645 if (type != WBC_SID_NAME_USER) { 4166 4646 DEBUG(1, ("%s is not a user\n", full_name)); 4167 4647 return false; … … 4172 4652 return false; 4173 4653 } 4174 4175 wbcFreeMemory(sid_str);4176 sid_str = NULL;4177 4654 4178 4655 init_user_token(token, &user_sid); … … 4189 4666 for (i = 0; i < num_groups; i++) { 4190 4667 gid_t gid = groups[i]; 4191 DOM_SIDsid;4668 struct dom_sid sid; 4192 4669 4193 4670 wbc_status = wbcGidToSid(gid, &wsid); … … 4199 4676 } 4200 4677 4201 wbc_status = wbcSidToString(&wsid, &sid_str); 4202 if (!WBC_ERROR_IS_OK(wbc_status)) { 4203 wbcFreeMemory(groups); 4204 return false; 4205 } 4678 wbcSidToStringBuf(&wsid, sid_str, sizeof(sid_str)); 4206 4679 4207 4680 DEBUG(3, (" %s\n", sid_str)); 4208 4681 4209 4682 string_to_sid(&sid, sid_str); 4210 wbcFreeMemory(sid_str);4211 sid_str = NULL;4212 4213 4683 add_sid_to_token(token, &sid); 4214 4684 } … … 4277 4747 4278 4748 get_user_sids(domain, user, &(result[i].token)); 4279 i+=1;4280 4749 } 4281 4750 TALLOC_FREE(frame); … … 4308 4777 /* We have a SID */ 4309 4778 4310 DOM_SIDsid;4779 struct dom_sid sid; 4311 4780 if(!string_to_sid(&sid, &line[1])) { 4312 4781 DEBUG(1,("get_user_tokens_from_file: Could " … … 4337 4806 fstrcpy(token->name, line); 4338 4807 token->token.num_sids = 0; 4339 token->token. user_sids = NULL;4808 token->token.sids = NULL; 4340 4809 continue; 4341 4810 } … … 4356 4825 { 4357 4826 uint16_t fnum; 4358 SEC_DESC*share_sd = NULL;4359 SEC_DESC*root_sd = NULL;4827 struct security_descriptor *share_sd = NULL; 4828 struct security_descriptor *root_sd = NULL; 4360 4829 struct cli_state *cli = rpc_pipe_np_smb_conn(pipe_hnd); 4361 4830 int i; … … 4364 4833 NTSTATUS status; 4365 4834 uint16 cnum; 4366 4367 status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, 4835 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 4836 4837 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 4368 4838 pipe_hnd->desthost, 4369 4839 netname, … … 4472 4942 4473 4943 static NTSTATUS rpc_share_allowedusers_internals(struct net_context *c, 4474 const DOM_SID*domain_sid,4944 const struct dom_sid *domain_sid, 4475 4945 const char *domain_name, 4476 4946 struct cli_state *cli, … … 4668 5138 }; 4669 5139 4670 status = libnetapi_ init(&c->netapi_ctx);5140 status = libnetapi_net_init(&c->netapi_ctx); 4671 5141 if (status != 0) { 4672 5142 return -1; … … 4761 5231 WERROR result; 4762 5232 NTSTATUS status; 5233 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 4763 5234 4764 5235 if (argc != 1) { … … 4767 5238 } 4768 5239 4769 status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx,5240 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 4770 5241 pipe_hnd->desthost, 4771 5242 argv[0], … … 4773 5244 &info, 4774 5245 &result); 4775 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 5246 if (!NT_STATUS_IS_OK(status)) { 5247 result = ntstatus_to_werror(status); 5248 goto done; 5249 } 5250 if (!W_ERROR_IS_OK(result)) { 4776 5251 goto done; 4777 5252 } … … 4944 5419 }; 4945 5420 4946 status = libnetapi_ init(&c->netapi_ctx);5421 status = libnetapi_net_init(&c->netapi_ctx); 4947 5422 if (status != 0) { 4948 5423 return -1; … … 4987 5462 4988 5463 static NTSTATUS rpc_shutdown_abort_internals(struct net_context *c, 4989 const DOM_SID*domain_sid,5464 const struct dom_sid *domain_sid, 4990 5465 const char *domain_name, 4991 5466 struct cli_state *cli, … … 4995 5470 const char **argv) 4996 5471 { 4997 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 4998 4999 result = rpccli_initshutdown_Abort(pipe_hnd, mem_ctx, NULL, NULL); 5000 5001 if (NT_STATUS_IS_OK(result)) { 5472 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 5473 WERROR result; 5474 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5475 5476 status = dcerpc_initshutdown_Abort(b, mem_ctx, NULL, &result); 5477 if (!NT_STATUS_IS_OK(status)) { 5478 return status; 5479 } 5480 if (W_ERROR_IS_OK(result)) { 5002 5481 d_printf(_("\nShutdown successfully aborted\n")); 5003 5482 DEBUG(5,("cmd_shutdown_abort: query succeeded\n")); … … 5005 5484 DEBUG(5,("cmd_shutdown_abort: query failed\n")); 5006 5485 5007 return result;5486 return werror_to_ntstatus(result); 5008 5487 } 5009 5488 … … 5026 5505 5027 5506 static NTSTATUS rpc_reg_shutdown_abort_internals(struct net_context *c, 5028 const DOM_SID*domain_sid,5507 const struct dom_sid *domain_sid, 5029 5508 const char *domain_name, 5030 5509 struct cli_state *cli, … … 5035 5514 { 5036 5515 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 5037 5038 result = rpccli_winreg_AbortSystemShutdown(pipe_hnd, mem_ctx, NULL, NULL); 5039 5040 if (NT_STATUS_IS_OK(result)) { 5516 WERROR werr; 5517 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5518 5519 result = dcerpc_winreg_AbortSystemShutdown(b, mem_ctx, NULL, &werr); 5520 5521 if (!NT_STATUS_IS_OK(result)) { 5522 DEBUG(5,("cmd_reg_abort_shutdown: query failed\n")); 5523 return result; 5524 } 5525 if (W_ERROR_IS_OK(werr)) { 5041 5526 d_printf(_("\nShutdown successfully aborted\n")); 5042 5527 DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n")); … … 5044 5529 DEBUG(5,("cmd_reg_abort_shutdown: query failed\n")); 5045 5530 5046 return result;5531 return werror_to_ntstatus(werr); 5047 5532 } 5048 5533 … … 5102 5587 5103 5588 NTSTATUS rpc_init_shutdown_internals(struct net_context *c, 5104 const DOM_SID*domain_sid,5589 const struct dom_sid *domain_sid, 5105 5590 const char *domain_name, 5106 5591 struct cli_state *cli, … … 5110 5595 const char **argv) 5111 5596 { 5112 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 5597 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 5598 WERROR result; 5113 5599 const char *msg = N_("This machine will be shutdown shortly"); 5114 5600 uint32 timeout = 20; 5115 5601 struct lsa_StringLarge msg_string; 5602 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5116 5603 5117 5604 if (c->opt_comment) { … … 5125 5612 5126 5613 /* create an entry */ 5127 result = rpccli_initshutdown_Init(pipe_hnd, mem_ctx, NULL,5614 status = dcerpc_initshutdown_Init(b, mem_ctx, NULL, 5128 5615 &msg_string, timeout, c->opt_force, c->opt_reboot, 5129 NULL); 5130 5131 if (NT_STATUS_IS_OK(result)) { 5616 &result); 5617 if (!NT_STATUS_IS_OK(status)) { 5618 return status; 5619 } 5620 if (W_ERROR_IS_OK(result)) { 5132 5621 d_printf(_("\nShutdown of remote machine succeeded\n")); 5133 5622 DEBUG(5,("Shutdown of remote machine succeeded\n")); … … 5135 5624 DEBUG(1,("Shutdown of remote machine failed!\n")); 5136 5625 } 5137 return result;5626 return werror_to_ntstatus(result); 5138 5627 } 5139 5628 … … 5156 5645 5157 5646 NTSTATUS rpc_reg_shutdown_internals(struct net_context *c, 5158 const DOM_SID*domain_sid,5647 const struct dom_sid *domain_sid, 5159 5648 const char *domain_name, 5160 5649 struct cli_state *cli, … … 5169 5658 NTSTATUS result; 5170 5659 WERROR werr; 5660 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5171 5661 5172 5662 if (c->opt_comment) { … … 5180 5670 5181 5671 /* create an entry */ 5182 result = rpccli_winreg_InitiateSystemShutdown(pipe_hnd, mem_ctx, NULL,5672 result = dcerpc_winreg_InitiateSystemShutdown(b, mem_ctx, NULL, 5183 5673 &msg_string, timeout, c->opt_force, c->opt_reboot, 5184 5674 &werr); 5185 5186 if (NT_STATUS_IS_OK(result)) { 5675 if (!NT_STATUS_IS_OK(result)) { 5676 d_fprintf(stderr, "\nShutdown of remote machine failed\n"); 5677 return result; 5678 } 5679 5680 if (W_ERROR_IS_OK(werr)) { 5187 5681 d_printf(_("\nShutdown of remote machine succeeded\n")); 5188 5682 } else { … … 5194 5688 } 5195 5689 5196 return result;5690 return werror_to_ntstatus(werr); 5197 5691 } 5198 5692 … … 5253 5747 5254 5748 static NTSTATUS rpc_trustdom_add_internals(struct net_context *c, 5255 const DOM_SID*domain_sid,5749 const struct dom_sid *domain_sid, 5256 5750 const char *domain_name, 5257 5751 struct cli_state *cli, … … 5262 5756 { 5263 5757 struct policy_handle connect_pol, domain_pol, user_pol; 5264 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;5758 NTSTATUS status, result; 5265 5759 char *acct_name; 5266 5760 struct lsa_String lsa_acct_name; … … 5271 5765 union samr_UserInfo info; 5272 5766 unsigned int orig_timeout; 5767 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5273 5768 5274 5769 if (argc != 2) { … … 5293 5788 5294 5789 /* Get samr policy handle */ 5295 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,5790 status = dcerpc_samr_Connect2(b, mem_ctx, 5296 5791 pipe_hnd->desthost, 5297 5792 MAXIMUM_ALLOWED_ACCESS, 5298 &connect_pol); 5793 &connect_pol, 5794 &result); 5795 if (!NT_STATUS_IS_OK(status)) { 5796 goto done; 5797 } 5299 5798 if (!NT_STATUS_IS_OK(result)) { 5799 status = result; 5300 5800 goto done; 5301 5801 } 5302 5802 5303 5803 /* Get domain policy handle */ 5304 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,5804 status = dcerpc_samr_OpenDomain(b, mem_ctx, 5305 5805 &connect_pol, 5306 5806 MAXIMUM_ALLOWED_ACCESS, 5307 5807 CONST_DISCARD(struct dom_sid2 *, domain_sid), 5308 &domain_pol); 5808 &domain_pol, 5809 &result); 5810 if (!NT_STATUS_IS_OK(status)) { 5811 goto done; 5812 } 5309 5813 if (!NT_STATUS_IS_OK(result)) { 5814 status = result; 5310 5815 goto done; 5311 5816 } … … 5324 5829 SAMR_USER_ACCESS_SET_ATTRIBUTES; 5325 5830 5326 result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,5831 status = dcerpc_samr_CreateUser2(b, mem_ctx, 5327 5832 &domain_pol, 5328 5833 &lsa_acct_name, … … 5331 5836 &user_pol, 5332 5837 &access_granted, 5333 &user_rid); 5334 5838 &user_rid, 5839 &result); 5840 if (!NT_STATUS_IS_OK(status)) { 5841 goto done; 5842 } 5335 5843 /* And restore our original timeout. */ 5336 5844 rpccli_set_timeout(pipe_hnd, orig_timeout); 5337 5845 5338 5846 if (!NT_STATUS_IS_OK(result)) { 5847 status = result; 5339 5848 d_printf(_("net rpc trustdom add: create user %s failed %s\n"), 5340 5849 acct_name, nt_errstr(result)); … … 5356 5865 info.info23.password = crypt_pwd; 5357 5866 5358 result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx,5867 status = dcerpc_samr_SetUserInfo2(b, mem_ctx, 5359 5868 &user_pol, 5360 5869 23, 5361 &info); 5870 &info, 5871 &result); 5872 if (!NT_STATUS_IS_OK(status)) { 5873 goto done; 5874 } 5362 5875 5363 5876 if (!NT_STATUS_IS_OK(result)) { 5877 status = result; 5364 5878 DEBUG(0,("Could not set trust account password: %s\n", 5365 5879 nt_errstr(result))); … … 5370 5884 done: 5371 5885 SAFE_FREE(acct_name); 5372 return result;5886 return status; 5373 5887 } 5374 5888 … … 5414 5928 5415 5929 static NTSTATUS rpc_trustdom_del_internals(struct net_context *c, 5416 const DOM_SID*domain_sid,5930 const struct dom_sid *domain_sid, 5417 5931 const char *domain_name, 5418 5932 struct cli_state *cli, … … 5423 5937 { 5424 5938 struct policy_handle connect_pol, domain_pol, user_pol; 5425 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;5939 NTSTATUS status, result; 5426 5940 char *acct_name; 5427 DOM_SIDtrust_acct_sid;5941 struct dom_sid trust_acct_sid; 5428 5942 struct samr_Ids user_rids, name_types; 5429 5943 struct lsa_String lsa_acct_name; 5944 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 5430 5945 5431 5946 if (argc != 1) { … … 5447 5962 5448 5963 /* Get samr policy handle */ 5449 result = rpccli_samr_Connect2(pipe_hnd, mem_ctx,5964 status = dcerpc_samr_Connect2(b, mem_ctx, 5450 5965 pipe_hnd->desthost, 5451 5966 MAXIMUM_ALLOWED_ACCESS, 5452 &connect_pol); 5967 &connect_pol, 5968 &result); 5969 if (!NT_STATUS_IS_OK(status)) { 5970 goto done; 5971 } 5453 5972 if (!NT_STATUS_IS_OK(result)) { 5973 status = result; 5454 5974 goto done; 5455 5975 } 5456 5976 5457 5977 /* Get domain policy handle */ 5458 result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,5978 status = dcerpc_samr_OpenDomain(b, mem_ctx, 5459 5979 &connect_pol, 5460 5980 MAXIMUM_ALLOWED_ACCESS, 5461 5981 CONST_DISCARD(struct dom_sid2 *, domain_sid), 5462 &domain_pol); 5982 &domain_pol, 5983 &result); 5984 if (!NT_STATUS_IS_OK(status)) { 5985 goto done; 5986 } 5463 5987 if (!NT_STATUS_IS_OK(result)) { 5988 status = result; 5464 5989 goto done; 5465 5990 } … … 5467 5992 init_lsa_String(&lsa_acct_name, acct_name); 5468 5993 5469 result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,5994 status = dcerpc_samr_LookupNames(b, mem_ctx, 5470 5995 &domain_pol, 5471 5996 1, 5472 5997 &lsa_acct_name, 5473 5998 &user_rids, 5474 &name_types); 5475 5999 &name_types, 6000 &result); 6001 if (!NT_STATUS_IS_OK(status)) { 6002 d_printf(_("net rpc trustdom del: LookupNames on user %s " 6003 "failed %s\n"), 6004 acct_name, nt_errstr(status)); 6005 goto done; 6006 } 5476 6007 if (!NT_STATUS_IS_OK(result)) { 6008 status = result; 5477 6009 d_printf(_("net rpc trustdom del: LookupNames on user %s " 5478 6010 "failed %s\n"), … … 5481 6013 } 5482 6014 5483 result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,6015 status = dcerpc_samr_OpenUser(b, mem_ctx, 5484 6016 &domain_pol, 5485 6017 MAXIMUM_ALLOWED_ACCESS, 5486 6018 user_rids.ids[0], 5487 &user_pol); 6019 &user_pol, 6020 &result); 6021 if (!NT_STATUS_IS_OK(status)) { 6022 d_printf(_("net rpc trustdom del: OpenUser on user %s failed " 6023 "%s\n"), 6024 acct_name, nt_errstr(status) ); 6025 goto done; 6026 } 5488 6027 5489 6028 if (!NT_STATUS_IS_OK(result)) { 6029 status = result; 5490 6030 d_printf(_("net rpc trustdom del: OpenUser on user %s failed " 5491 6031 "%s\n"), … … 5495 6035 5496 6036 /* append the rid to the domain sid */ 5497 sid_copy(&trust_acct_sid, domain_sid); 5498 if (!sid_append_rid(&trust_acct_sid, user_rids.ids[0])) { 6037 if (!sid_compose(&trust_acct_sid, domain_sid, user_rids.ids[0])) { 5499 6038 goto done; 5500 6039 } … … 5502 6041 /* remove the sid */ 5503 6042 5504 result = rpccli_samr_RemoveMemberFromForeignDomain(pipe_hnd, mem_ctx,6043 status = dcerpc_samr_RemoveMemberFromForeignDomain(b, mem_ctx, 5505 6044 &user_pol, 5506 &trust_acct_sid); 6045 &trust_acct_sid, 6046 &result); 6047 if (!NT_STATUS_IS_OK(status)) { 6048 d_printf(_("net rpc trustdom del: RemoveMemberFromForeignDomain" 6049 " on user %s failed %s\n"), 6050 acct_name, nt_errstr(status)); 6051 goto done; 6052 } 5507 6053 if (!NT_STATUS_IS_OK(result)) { 6054 status = result; 5508 6055 d_printf(_("net rpc trustdom del: RemoveMemberFromForeignDomain" 5509 6056 " on user %s failed %s\n"), … … 5512 6059 } 5513 6060 6061 5514 6062 /* Delete user */ 5515 6063 5516 result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx, 5517 &user_pol); 6064 status = dcerpc_samr_DeleteUser(b, mem_ctx, 6065 &user_pol, 6066 &result); 6067 if (!NT_STATUS_IS_OK(status)) { 6068 d_printf(_("net rpc trustdom del: DeleteUser on user %s failed " 6069 "%s\n"), 6070 acct_name, nt_errstr(status)); 6071 goto done; 6072 } 5518 6073 5519 6074 if (!NT_STATUS_IS_OK(result)) { 6075 result = status; 5520 6076 d_printf(_("net rpc trustdom del: DeleteUser on user %s failed " 5521 6077 "%s\n"), … … 5531 6087 5532 6088 done: 5533 return result;6089 return status; 5534 6090 } 5535 6091 … … 5565 6121 struct rpc_pipe_client *netr; 5566 6122 NTSTATUS status; 6123 WERROR result; 6124 struct dcerpc_binding_handle *b; 5567 6125 5568 6126 /* Use NetServerEnum2 */ … … 5584 6142 } 5585 6143 5586 status = rpccli_netr_GetDcName(netr, mem_ctx, 6144 b = netr->binding_handle; 6145 6146 status = dcerpc_netr_GetDcName(b, mem_ctx, 5587 6147 cli->desthost, 5588 6148 domain_name, 5589 6149 &buffer, 5590 NULL);6150 &result); 5591 6151 TALLOC_FREE(netr); 5592 6152 5593 if (NT_STATUS_IS_OK(status) ) {6153 if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) { 5594 6154 return status; 5595 6155 } … … 5598 6158 for domain %s\n", domain_name)); 5599 6159 5600 return status; 6160 if (!NT_STATUS_IS_OK(status)) { 6161 return status; 6162 } 6163 6164 return werror_to_ntstatus(result); 5601 6165 } 5602 6166 … … 5620 6184 struct policy_handle connect_hnd; 5621 6185 TALLOC_CTX *mem_ctx; 5622 NTSTATUS nt_status ;5623 DOM_SID*domain_sid;6186 NTSTATUS nt_status, result; 6187 struct dom_sid *domain_sid; 5624 6188 5625 6189 char* domain_name; … … 5627 6191 fstring pdc_name; 5628 6192 union lsa_PolicyInformation *info = NULL; 6193 struct dcerpc_binding_handle *b; 5629 6194 5630 6195 /* … … 5719 6284 return -1; 5720 6285 } 6286 6287 b = pipe_hnd->binding_handle; 5721 6288 5722 6289 nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, KEY_QUERY_VALUE, … … 5732 6299 /* Querying info level 5 */ 5733 6300 5734 nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,6301 nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 5735 6302 &connect_hnd, 5736 6303 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 5737 &info); 6304 &info, 6305 &result); 5738 6306 if (NT_STATUS_IS_ERR(nt_status)) { 5739 6307 DEBUG(0, ("LSA Query Info failed. Returned error was %s\n", … … 5743 6311 return -1; 5744 6312 } 6313 if (NT_STATUS_IS_ERR(result)) { 6314 DEBUG(0, ("LSA Query Info failed. Returned error was %s\n", 6315 nt_errstr(result))); 6316 cli_shutdown(cli); 6317 talloc_destroy(mem_ctx); 6318 return -1; 6319 } 5745 6320 5746 6321 domain_sid = info->account_domain.sid; … … 5764 6339 */ 5765 6340 5766 nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);6341 nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result); 5767 6342 if (NT_STATUS_IS_ERR(nt_status)) { 5768 6343 DEBUG(0, ("Couldn't close LSA pipe. Error was %s\n", … … 5824 6399 5825 6400 static NTSTATUS rpc_query_domain_sid(struct net_context *c, 5826 const DOM_SID*domain_sid,6401 const struct dom_sid *domain_sid, 5827 6402 const char *domain_name, 5828 6403 struct cli_state *cli, … … 5840 6415 } 5841 6416 5842 static void print_trusted_domain( DOM_SID*dom_sid, const char *trusted_dom_name)6417 static void print_trusted_domain(struct dom_sid *dom_sid, const char *trusted_dom_name) 5843 6418 { 5844 6419 fstring ascii_sid; … … 5853 6428 TALLOC_CTX *mem_ctx, 5854 6429 struct policy_handle *pol, 5855 DOM_SIDdom_sid,6430 struct dom_sid dom_sid, 5856 6431 const char *trusted_dom_name) 5857 6432 { 5858 NTSTATUS nt_status ;6433 NTSTATUS nt_status, result; 5859 6434 union lsa_TrustedDomainInfo *info = NULL; 5860 6435 char *cleartextpwd = NULL; … … 5862 6437 DATA_BLOB session_key_blob; 5863 6438 DATA_BLOB data = data_blob_null; 5864 5865 nt_status = rpccli_lsa_QueryTrustedDomainInfoBySid(pipe_hnd, mem_ctx, 6439 struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; 6440 6441 nt_status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx, 5866 6442 pol, 5867 6443 &dom_sid, 5868 6444 LSA_TRUSTED_DOMAIN_INFO_PASSWORD, 5869 &info); 6445 &info, 6446 &result); 5870 6447 if (NT_STATUS_IS_ERR(nt_status)) { 5871 6448 DEBUG(0,("Could not query trusted domain info. Error was %s\n", 5872 6449 nt_errstr(nt_status))); 6450 goto done; 6451 } 6452 if (NT_STATUS_IS_ERR(result)) { 6453 nt_status = result; 6454 DEBUG(0,("Could not query trusted domain info. Error was %s\n", 6455 nt_errstr(result))); 5873 6456 goto done; 5874 6457 } … … 5917 6500 struct cli_state *cli = NULL; 5918 6501 struct rpc_pipe_client *pipe_hnd = NULL; 5919 NTSTATUS nt_status ;6502 NTSTATUS nt_status, result; 5920 6503 const char *domain_name = NULL; 5921 DOM_SID*queried_dom_sid;6504 struct dom_sid *queried_dom_sid; 5922 6505 struct policy_handle connect_hnd; 5923 6506 union lsa_PolicyInformation *info = NULL; … … 5928 6511 struct lsa_DomainList dom_list; 5929 6512 fstring pdc_name; 6513 struct dcerpc_binding_handle *b; 5930 6514 5931 6515 if (c->display_usage) { … … 5977 6561 }; 5978 6562 6563 b = pipe_hnd->binding_handle; 6564 5979 6565 nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE, 5980 6566 &connect_hnd); … … 5988 6574 5989 6575 /* query info level 5 to obtain sid of a domain being queried */ 5990 nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,6576 nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 5991 6577 &connect_hnd, 5992 6578 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 5993 &info); 6579 &info, 6580 &result); 5994 6581 5995 6582 if (NT_STATUS_IS_ERR(nt_status)) { … … 6000 6587 return -1; 6001 6588 } 6589 if (NT_STATUS_IS_ERR(result)) { 6590 DEBUG(0, ("LSA Query Info failed. Returned error was %s\n", 6591 nt_errstr(result))); 6592 cli_shutdown(cli); 6593 talloc_destroy(mem_ctx); 6594 return -1; 6595 } 6002 6596 6003 6597 queried_dom_sid = info->account_domain.sid; … … 6011 6605 6012 6606 do { 6013 nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx,6607 nt_status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 6014 6608 &connect_hnd, 6015 6609 &enum_ctx, 6016 6610 &dom_list, 6017 (uint32_t)-1); 6611 (uint32_t)-1, 6612 &result); 6018 6613 if (NT_STATUS_IS_ERR(nt_status)) { 6019 6614 DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", … … 6023 6618 return -1; 6024 6619 }; 6620 if (NT_STATUS_IS_ERR(result)) { 6621 nt_status = result; 6622 DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", 6623 nt_errstr(result))); 6624 cli_shutdown(cli); 6625 talloc_destroy(mem_ctx); 6626 return -1; 6627 }; 6628 6025 6629 6026 6630 for (i = 0; i < dom_list.count; i++) { … … 6048 6652 6049 6653 /* close this connection before doing next one */ 6050 nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);6654 nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result); 6051 6655 if (NT_STATUS_IS_ERR(nt_status)) { 6052 6656 DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n", … … 6070 6674 struct cli_state *cli = NULL, *remote_cli = NULL; 6071 6675 struct rpc_pipe_client *pipe_hnd = NULL; 6072 NTSTATUS nt_status ;6676 NTSTATUS nt_status, result; 6073 6677 const char *domain_name = NULL; 6074 DOM_SID*queried_dom_sid;6678 struct dom_sid *queried_dom_sid; 6075 6679 int ascii_dom_name_len; 6076 6680 struct policy_handle connect_hnd; 6077 6681 union lsa_PolicyInformation *info = NULL; 6682 struct dcerpc_binding_handle *b = NULL; 6078 6683 6079 6684 /* trusted domains listing variables */ … … 6135 6740 return -1; 6136 6741 }; 6742 6743 b = pipe_hnd->binding_handle; 6137 6744 6138 6745 nt_status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, false, KEY_QUERY_VALUE, … … 6147 6754 6148 6755 /* query info level 5 to obtain sid of a domain being queried */ 6149 nt_status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,6756 nt_status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 6150 6757 &connect_hnd, 6151 6758 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 6152 &info); 6759 &info, 6760 &result); 6153 6761 6154 6762 if (NT_STATUS_IS_ERR(nt_status)) { … … 6159 6767 return -1; 6160 6768 } 6769 if (NT_STATUS_IS_ERR(result)) { 6770 DEBUG(0, ("LSA Query Info failed. Returned error was %s\n", 6771 nt_errstr(result))); 6772 cli_shutdown(cli); 6773 talloc_destroy(mem_ctx); 6774 return -1; 6775 } 6161 6776 6162 6777 queried_dom_sid = info->account_domain.sid; … … 6172 6787 6173 6788 do { 6174 nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx,6789 nt_status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 6175 6790 &connect_hnd, 6176 6791 &enum_ctx, 6177 6792 &dom_list, 6178 (uint32_t)-1); 6793 (uint32_t)-1, 6794 &result); 6179 6795 if (NT_STATUS_IS_ERR(nt_status)) { 6180 6796 DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", … … 6184 6800 return -1; 6185 6801 }; 6802 if (NT_STATUS_IS_ERR(result)) { 6803 DEBUG(0, ("Couldn't enumerate trusted domains. Error was %s\n", 6804 nt_errstr(result))); 6805 cli_shutdown(cli); 6806 talloc_destroy(mem_ctx); 6807 return -1; 6808 }; 6809 6186 6810 6187 6811 for (i = 0; i < dom_list.count; i++) { … … 6203 6827 6204 6828 /* close this connection before doing next one */ 6205 nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);6829 nt_status = dcerpc_lsa_Close(b, mem_ctx, &connect_hnd, &result); 6206 6830 if (NT_STATUS_IS_ERR(nt_status)) { 6207 6831 DEBUG(0, ("Couldn't properly close lsa policy handle. Error was %s\n", … … 6232 6856 }; 6233 6857 6858 b = pipe_hnd->binding_handle; 6859 6234 6860 /* SamrConnect2 */ 6235 nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,6861 nt_status = dcerpc_samr_Connect2(b, mem_ctx, 6236 6862 pipe_hnd->desthost, 6237 6863 SAMR_ACCESS_LOOKUP_DOMAIN, 6238 &connect_hnd); 6864 &connect_hnd, 6865 &result); 6239 6866 if (!NT_STATUS_IS_OK(nt_status)) { 6240 6867 DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n", … … 6244 6871 return -1; 6245 6872 }; 6873 if (!NT_STATUS_IS_OK(result)) { 6874 nt_status = result; 6875 DEBUG(0, ("Couldn't open SAMR policy handle. Error was %s\n", 6876 nt_errstr(result))); 6877 cli_shutdown(cli); 6878 talloc_destroy(mem_ctx); 6879 return -1; 6880 }; 6246 6881 6247 6882 /* SamrOpenDomain - we have to open domain policy handle in order to be 6248 6883 able to enumerate accounts*/ 6249 nt_status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,6884 nt_status = dcerpc_samr_OpenDomain(b, mem_ctx, 6250 6885 &connect_hnd, 6251 6886 SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS, 6252 6887 queried_dom_sid, 6253 &domain_hnd); 6888 &domain_hnd, 6889 &result); 6254 6890 if (!NT_STATUS_IS_OK(nt_status)) { 6255 6891 DEBUG(0, ("Couldn't open domain object. Error was %s\n", … … 6259 6895 return -1; 6260 6896 }; 6897 if (!NT_STATUS_IS_OK(result)) { 6898 nt_status = result; 6899 DEBUG(0, ("Couldn't open domain object. Error was %s\n", 6900 nt_errstr(result))); 6901 cli_shutdown(cli); 6902 talloc_destroy(mem_ctx); 6903 return -1; 6904 }; 6261 6905 6262 6906 /* … … 6269 6913 do { 6270 6914 6271 nt_status = rpccli_samr_EnumDomainUsers(pipe_hnd, mem_ctx,6915 nt_status = dcerpc_samr_EnumDomainUsers(b, mem_ctx, 6272 6916 &domain_hnd, 6273 6917 &enum_ctx, … … 6275 6919 &trusts, 6276 6920 0xffff, 6277 &num_domains); 6921 &num_domains, 6922 &result); 6278 6923 if (NT_STATUS_IS_ERR(nt_status)) { 6279 6924 DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n", 6280 6925 nt_errstr(nt_status))); 6926 cli_shutdown(cli); 6927 talloc_destroy(mem_ctx); 6928 return -1; 6929 }; 6930 if (NT_STATUS_IS_ERR(result)) { 6931 nt_status = result; 6932 DEBUG(0, ("Couldn't enumerate accounts. Error was: %s\n", 6933 nt_errstr(result))); 6281 6934 cli_shutdown(cli); 6282 6935 talloc_destroy(mem_ctx); … … 6331 6984 } 6332 6985 6333 } while (NT_STATUS_EQUAL( nt_status, STATUS_MORE_ENTRIES));6986 } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); 6334 6987 6335 6988 if (!found_domain) { … … 6338 6991 6339 6992 /* close opened samr and domain policy handles */ 6340 nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_hnd);6993 nt_status = dcerpc_samr_Close(b, mem_ctx, &domain_hnd, &result); 6341 6994 if (!NT_STATUS_IS_OK(nt_status)) { 6342 6995 DEBUG(0, ("Couldn't properly close domain policy handle for domain %s\n", domain_name)); 6343 6996 }; 6344 6997 6345 nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_hnd);6998 nt_status = dcerpc_samr_Close(b, mem_ctx, &connect_hnd, &result); 6346 6999 if (!NT_STATUS_IS_OK(nt_status)) { 6347 7000 DEBUG(0, ("Couldn't properly close samr policy handle for domain %s\n", domain_name)); … … 6521 7174 } 6522 7175 6523 return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id, 6524 NET_FLAGS_ANONYMOUS, 6525 rpc_vampire_internals, 6526 argc, argv); 7176 return rpc_vampire_passdb(c, argc, argv); 6527 7177 } 6528 7178 … … 7349 7999 " Open interactive shell on remote server") 7350 8000 }, 8001 { 8002 "trust", 8003 net_rpc_trust, 8004 NET_TRANSPORT_RPC, 8005 N_("Manage trusts"), 8006 N_("net rpc trust\n" 8007 " Manage trusts") 8008 }, 7351 8009 {NULL, NULL, 0, NULL, NULL} 7352 8010 }; 7353 8011 7354 status = libnetapi_ init(&c->netapi_ctx);8012 status = libnetapi_net_init(&c->netapi_ctx); 7355 8013 if (status != 0) { 7356 8014 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.