Changeset 740 for vendor/current/source3/rpcclient
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/source3/rpcclient
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/rpcclient/cmd_dfs.c
r414 r740 22 22 #include "includes.h" 23 23 #include "rpcclient.h" 24 #include "../librpc/gen_ndr/ cli_dfs.h"24 #include "../librpc/gen_ndr/ndr_dfs_c.h" 25 25 26 26 /* Check DFS is supported by the remote server */ … … 31 31 enum dfs_ManagerVersion version; 32 32 NTSTATUS result; 33 struct dcerpc_binding_handle *b = cli->binding_handle; 33 34 34 35 if (argc != 1) { … … 37 38 } 38 39 39 result = rpccli_dfs_GetManagerVersion(cli, mem_ctx, &version);40 result = dcerpc_dfs_GetManagerVersion(b, mem_ctx, &version); 40 41 41 42 if (!NT_STATUS_IS_OK(result)) { … … 59 60 const char *path, *servername, *sharename, *comment; 60 61 uint32 flags = 0; 62 struct dcerpc_binding_handle *b = cli->binding_handle; 61 63 62 64 if (argc != 5) { … … 71 73 comment = argv[4]; 72 74 73 result = rpccli_dfs_Add(cli, mem_ctx, path, servername,75 result = dcerpc_dfs_Add(b, mem_ctx, path, servername, 74 76 sharename, comment, flags, &werr); 75 77 if (!NT_STATUS_IS_OK(result)) { … … 86 88 WERROR werr; 87 89 const char *path, *servername, *sharename; 90 struct dcerpc_binding_handle *b = cli->binding_handle; 88 91 89 92 if (argc != 4) { … … 96 99 sharename = argv[3]; 97 100 98 result = rpccli_dfs_Remove(cli, mem_ctx, path, servername,101 result = dcerpc_dfs_Remove(b, mem_ctx, path, servername, 99 102 sharename, &werr); 100 103 if (!NT_STATUS_IS_OK(result)) { … … 196 199 struct dfs_EnumArray200 info200; 197 200 struct dfs_EnumArray300 info300; 201 struct dcerpc_binding_handle *b = cli->binding_handle; 198 202 199 203 NTSTATUS result; … … 222 226 } 223 227 224 result = rpccli_dfs_Enum(cli, mem_ctx, str.level, 0xFFFFFFFF, &str,228 result = dcerpc_dfs_Enum(b, mem_ctx, str.level, 0xFFFFFFFF, &str, 225 229 &total, &werr); 226 227 if (NT_STATUS_IS_OK(result)) { 230 if (!NT_STATUS_IS_OK(result)) { 231 return ntstatus_to_werror(result); 232 } 233 if (W_ERROR_IS_OK(werr)) { 228 234 display_dfs_enumstruct(&str); 229 235 } … … 244 250 struct dfs_EnumArray200 info200; 245 251 struct dfs_EnumArray300 info300; 252 struct dcerpc_binding_handle *b = cli->binding_handle; 246 253 247 254 NTSTATUS result; … … 271 278 } 272 279 273 result = rpccli_dfs_EnumEx(cli, mem_ctx, argv[1], str.level,280 result = dcerpc_dfs_EnumEx(b, mem_ctx, argv[1], str.level, 274 281 0xFFFFFFFF, &str, &total, &werr); 275 276 if (NT_STATUS_IS_OK(result)) { 282 if (!NT_STATUS_IS_OK(result)) { 283 return ntstatus_to_werror(result); 284 } 285 if (W_ERROR_IS_OK(werr)) { 277 286 display_dfs_enumstruct(&str); 278 287 } … … 290 299 uint32 info_level = 1; 291 300 union dfs_Info ctr; 301 struct dcerpc_binding_handle *b = cli->binding_handle; 292 302 293 303 if (argc < 4 || argc > 5) { … … 304 314 info_level = atoi(argv[4]); 305 315 306 result = rpccli_dfs_GetInfo(cli, mem_ctx, path, servername,316 result = dcerpc_dfs_GetInfo(b, mem_ctx, path, servername, 307 317 sharename, info_level, &ctr, &werr); 308 309 if (NT_STATUS_IS_OK(result)) { 318 if (!NT_STATUS_IS_OK(result)) { 319 return ntstatus_to_werror(result); 320 } 321 if (W_ERROR_IS_OK(werr)) { 310 322 display_dfs_info(info_level, &ctr); 311 323 } -
vendor/current/source3/rpcclient/cmd_drsuapi.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/ cli_drsuapi.h"23 #include "../librpc/gen_ndr/ndr_drsuapi_c.h" 24 24 25 25 static WERROR cracknames(struct rpc_pipe_client *cli, … … 35 35 WERROR werr; 36 36 int i; 37 int32_t level = 1;37 uint32_t level = 1; 38 38 union drsuapi_DsNameRequest req; 39 int32_t level_out;39 uint32_t level_out; 40 40 struct drsuapi_DsNameString *names; 41 struct dcerpc_binding_handle *b = cli->binding_handle; 41 42 42 43 names = TALLOC_ZERO_ARRAY(mem_ctx, struct drsuapi_DsNameString, argc); … … 55 56 req.req1.format_desired = format_desired; 56 57 57 status = rpccli_drsuapi_DsCrackNames(cli, mem_ctx,58 status = dcerpc_drsuapi_DsCrackNames(b, mem_ctx, 58 59 bind_handle, 59 60 level, … … 83 84 struct GUID bind_guid; 84 85 struct policy_handle bind_handle; 86 struct dcerpc_binding_handle *b = cli->binding_handle; 85 87 86 88 union drsuapi_DsNameCtr ctr; … … 93 95 GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid); 94 96 95 status = rpccli_drsuapi_DsBind(cli, mem_ctx,97 status = dcerpc_drsuapi_DsBind(b, mem_ctx, 96 98 &bind_guid, 97 99 NULL, … … 101 103 if (!NT_STATUS_IS_OK(status)) { 102 104 return ntstatus_to_werror(status); 105 } 106 107 if (!W_ERROR_IS_OK(werr)) { 108 return werr; 103 109 } 104 110 … … 126 132 out: 127 133 if (is_valid_policy_hnd(&bind_handle)) { 128 rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr); 134 WERROR _werr; 135 dcerpc_drsuapi_DsUnbind(b, mem_ctx, &bind_handle, &_werr); 129 136 } 130 137 … … 235 242 struct GUID bind_guid; 236 243 struct policy_handle bind_handle; 244 struct dcerpc_binding_handle *b = cli->binding_handle; 237 245 238 246 const char *domain = NULL; … … 254 262 GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid); 255 263 256 status = rpccli_drsuapi_DsBind(cli, mem_ctx,264 status = dcerpc_drsuapi_DsBind(b, mem_ctx, 257 265 &bind_guid, 258 266 NULL, … … 264 272 } 265 273 274 if (!W_ERROR_IS_OK(werr)) { 275 return werr; 276 } 277 266 278 req.req1.domain_name = domain; 267 279 req.req1.level = level; 268 280 269 status = rpccli_drsuapi_DsGetDomainControllerInfo(cli, mem_ctx,281 status = dcerpc_drsuapi_DsGetDomainControllerInfo(b, mem_ctx, 270 282 &bind_handle, 271 283 1, … … 286 298 out: 287 299 if (is_valid_policy_hnd(&bind_handle)) { 288 rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr); 300 WERROR _werr; 301 dcerpc_drsuapi_DsUnbind(b, mem_ctx, &bind_handle, &_werr); 289 302 } 290 303 … … 300 313 301 314 struct policy_handle bind_handle; 315 struct dcerpc_binding_handle *b = cli->binding_handle; 302 316 303 317 struct GUID bind_guid; … … 309 323 DATA_BLOB session_key; 310 324 311 int32_t level = 8;325 uint32_t level = 8; 312 326 bool single = false; 313 int32_t level_out = 0;327 uint32_t level_out = 0; 314 328 union drsuapi_DsGetNCChangesRequest req; 315 329 union drsuapi_DsGetNCChangesCtr ctr; … … 319 333 struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL; 320 334 struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL; 321 int32_t out_level = 0;335 uint32_t out_level = 0; 322 336 int y; 323 337 324 338 uint32_t supported_extensions = 0; 325 uint32_t replica_flags = DRSUAPI_D S_REPLICA_NEIGHBOUR_WRITEABLE|326 DRSUAPI_D S_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP|327 DRSUAPI_D S_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS|328 DRSUAPI_D S_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS|329 DRSUAPI_D S_REPLICA_NEIGHBOUR_NEVER_SYNCED;339 uint32_t replica_flags = DRSUAPI_DRS_WRIT_REP | 340 DRSUAPI_DRS_INIT_SYNC | 341 DRSUAPI_DRS_PER_SYNC | 342 DRSUAPI_DRS_GET_ANC | 343 DRSUAPI_DRS_NEVER_SYNCED; 330 344 331 345 if (argc > 3) { … … 389 403 bind_info.info.info28 = info28; 390 404 391 status = rpccli_drsuapi_DsBind(cli, mem_ctx,405 status = dcerpc_drsuapi_DsBind(b, mem_ctx, 392 406 &bind_guid, 393 407 &bind_info, … … 476 490 } 477 491 478 status = rpccli_drsuapi_DsGetNCChanges(cli, mem_ctx,492 status = dcerpc_drsuapi_DsGetNCChanges(b, mem_ctx, 479 493 &bind_handle, 480 494 level, … … 484 498 &werr); 485 499 if (!NT_STATUS_IS_OK(status)) { 500 werr = ntstatus_to_werror(status); 501 printf("Failed to get NC Changes: %s", 502 get_friendly_nt_error_msg(status)); 503 goto out; 504 } 505 506 if (!W_ERROR_IS_OK(werr)) { 486 507 printf("Failed to get NC Changes: %s", 487 508 get_friendly_werror_msg(werr)); 488 goto out;489 }490 491 if (!W_ERROR_IS_OK(werr)) {492 status = werror_to_ntstatus(werr);493 509 goto out; 494 510 } -
vendor/current/source3/rpcclient/cmd_dssetup.c
r414 r740 22 22 #include "includes.h" 23 23 #include "rpcclient.h" 24 #include "../librpc/gen_ndr/ cli_dssetup.h"24 #include "../librpc/gen_ndr/ndr_dssetup_c.h" 25 25 26 26 /* Look up domain related information on a remote host */ … … 30 30 const char **argv) 31 31 { 32 struct dcerpc_binding_handle *b = cli->binding_handle; 32 33 NTSTATUS status; 33 34 WERROR werr; 34 35 union dssetup_DsRoleInfo info; 35 36 36 status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(cli, mem_ctx,37 status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(b, mem_ctx, 37 38 DS_ROLE_BASIC_INFORMATION, 38 39 &info, -
vendor/current/source3/rpcclient/cmd_echo.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/ cli_echo.h"23 #include "../librpc/gen_ndr/ndr_echo_c.h" 24 24 25 25 static NTSTATUS cmd_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 26 26 int argc, const char **argv) 27 27 { 28 struct dcerpc_binding_handle *b = cli->binding_handle; 28 29 uint32 request = 1, response; 29 NTSTATUS result;30 NTSTATUS status; 30 31 31 32 if (argc > 2) { … … 34 35 } 35 36 36 if (argc == 2) 37 if (argc == 2) { 37 38 request = atoi(argv[1]); 39 } 38 40 39 result = rpccli_echo_AddOne(cli, mem_ctx, request, &response); 40 41 if (!NT_STATUS_IS_OK(result)) 41 status = dcerpc_echo_AddOne(b, mem_ctx, request, &response); 42 if (!NT_STATUS_IS_OK(status)) { 42 43 goto done; 44 } 43 45 44 46 printf("%d + 1 = %d\n", request, response); 45 47 46 48 done: 47 return result;49 return status; 48 50 } 49 51 … … 51 53 int argc, const char **argv) 52 54 { 55 struct dcerpc_binding_handle *b = cli->binding_handle; 53 56 uint32 size, i; 54 NTSTATUS result;57 NTSTATUS status; 55 58 uint8_t *in_data = NULL, *out_data = NULL; 56 59 … … 64 67 printf("Failure to allocate buff of %d bytes\n", 65 68 size); 66 result= NT_STATUS_NO_MEMORY;69 status = NT_STATUS_NO_MEMORY; 67 70 goto done; 68 71 } … … 70 73 printf("Failure to allocate buff of %d bytes\n", 71 74 size); 72 result= NT_STATUS_NO_MEMORY;75 status = NT_STATUS_NO_MEMORY; 73 76 goto done; 74 77 } 75 78 76 for (i = 0; i < size; i++) 79 for (i = 0; i < size; i++) { 77 80 in_data[i] = i & 0xff; 81 } 78 82 79 result = rpccli_echo_EchoData(cli, mem_ctx, size, in_data, out_data); 80 81 if (!NT_STATUS_IS_OK(result)) 83 status = dcerpc_echo_EchoData(b, mem_ctx, size, in_data, out_data); 84 if (!NT_STATUS_IS_OK(status)) { 82 85 goto done; 86 } 83 87 84 88 for (i = 0; i < size; i++) { … … 86 90 printf("mismatch at offset %d, %d != %d\n", 87 91 i, in_data[i], out_data[i]); 88 result= NT_STATUS_UNSUCCESSFUL;92 status = NT_STATUS_UNSUCCESSFUL; 89 93 } 90 94 } … … 94 98 SAFE_FREE(out_data); 95 99 96 return result;100 return status; 97 101 } 98 102 … … 101 105 const char **argv) 102 106 { 107 struct dcerpc_binding_handle *b = cli->binding_handle; 103 108 uint32 size, i; 104 NTSTATUS result;109 NTSTATUS status; 105 110 uint8_t *out_data = NULL; 106 111 … … 114 119 printf("Failure to allocate buff of %d bytes\n", 115 120 size); 116 result= NT_STATUS_NO_MEMORY;121 status = NT_STATUS_NO_MEMORY; 117 122 goto done; 118 123 } 119 124 120 125 121 result = rpccli_echo_SourceData(cli, mem_ctx, size, out_data); 122 123 if (!NT_STATUS_IS_OK(result)) 126 status = dcerpc_echo_SourceData(b, mem_ctx, size, out_data); 127 if (!NT_STATUS_IS_OK(status)) { 124 128 goto done; 129 } 125 130 126 131 for (i = 0; i < size; i++) { … … 128 133 printf("mismatch at offset %d, %d != %d\n", 129 134 i, out_data[i], i & 0xff); 130 result= NT_STATUS_UNSUCCESSFUL;135 status = NT_STATUS_UNSUCCESSFUL; 131 136 } 132 137 } … … 135 140 136 141 SAFE_FREE(out_data); 137 return result;142 return status; 138 143 } 139 144 … … 141 146 int argc, const char **argv) 142 147 { 148 struct dcerpc_binding_handle *b = cli->binding_handle; 143 149 uint32 size, i; 144 NTSTATUS result;150 NTSTATUS status; 145 151 uint8_t *in_data = NULL; 146 152 … … 154 160 printf("Failure to allocate buff of %d bytes\n", 155 161 size); 156 result= NT_STATUS_NO_MEMORY;162 status = NT_STATUS_NO_MEMORY; 157 163 goto done; 158 164 } 159 165 160 for (i = 0; i < size; i++) 166 for (i = 0; i < size; i++) { 161 167 in_data[i] = i & 0xff; 168 } 162 169 163 result = rpccli_echo_SinkData(cli, mem_ctx, size, in_data); 164 165 if (!NT_STATUS_IS_OK(result)) 170 status = dcerpc_echo_SinkData(b, mem_ctx, size, in_data); 171 if (!NT_STATUS_IS_OK(status)) { 166 172 goto done; 173 } 167 174 168 175 done: 169 176 SAFE_FREE(in_data); 170 177 171 return result;178 return status; 172 179 } 173 180 -
vendor/current/source3/rpcclient/cmd_epmapper.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/cli_epmapper.h" 23 #include "../librpc/gen_ndr/ndr_epmapper_c.h" 24 #include "../librpc/gen_ndr/ndr_lsa.h" 24 25 25 26 static NTSTATUS cmd_epmapper_map(struct rpc_pipe_client *p, … … 27 28 int argc, const char **argv) 28 29 { 30 struct dcerpc_binding_handle *b = p->binding_handle; 29 31 struct dcerpc_binding map_binding; 30 32 struct epm_twr_t map_tower; 31 struct epm_twr_t res_tower; 32 struct epm_twr_p_t towers; 33 struct epm_twr_p_t towers[500]; 33 34 struct policy_handle entry_handle; 34 35 struct ndr_syntax_id abstract_syntax; … … 36 37 TALLOC_CTX *tmp_ctx = talloc_stackframe(); 37 38 NTSTATUS status; 39 uint32_t result; 40 uint32_t i; 38 41 39 42 abstract_syntax = ndr_table_lsarpc.syntax_id; … … 52 55 } 53 56 54 towers.twr = &res_tower; 57 ZERO_STRUCT(towers); 58 ZERO_STRUCT(entry_handle); 55 59 56 ZERO_STRUCT(entry_handle); 57 status = rpccli_epm_Map( 58 p, tmp_ctx, &abstract_syntax.uuid, 59 &map_tower, &entry_handle, 1, 60 &num_towers, &towers); 60 status = dcerpc_epm_Map( 61 b, tmp_ctx, &abstract_syntax.uuid, 62 &map_tower, &entry_handle, ARRAY_SIZE(towers), 63 &num_towers, towers, &result); 64 if (!NT_STATUS_IS_OK(status)) { 65 d_fprintf(stderr, "dcerpc_epm_Map returned %s\n", 66 nt_errstr(status)); 67 return status; 68 } 61 69 62 return status; 70 if (result != EPMAPPER_STATUS_OK) { 71 d_fprintf(stderr, "epm_Map returned %u (0x%08X)\n", 72 result, result); 73 return NT_STATUS_UNSUCCESSFUL; 74 } 75 76 d_printf("num_tower[%u]\n", num_towers); 77 78 for (i=0; i < num_towers; i++) { 79 struct dcerpc_binding *binding; 80 81 if (towers[i].twr == NULL) { 82 d_fprintf(stderr, "tower[%u] NULL\n", i); 83 break; 84 } 85 86 status = dcerpc_binding_from_tower(tmp_ctx, &towers[i].twr->tower, 87 &binding); 88 if (!NT_STATUS_IS_OK(status)) { 89 break; 90 } 91 92 d_printf("tower[%u] %s\n", i, dcerpc_binding_string(tmp_ctx, binding)); 93 } 94 95 return NT_STATUS_OK; 63 96 } 64 97 … … 67 100 int argc, const char **argv) 68 101 { 102 struct dcerpc_binding_handle *b = p->binding_handle; 69 103 struct policy_handle entry_handle; 70 104 … … 78 112 char *guid_string; 79 113 struct dcerpc_binding *binding; 114 uint32_t result; 80 115 81 status = rpccli_epm_Lookup(p, tmp_ctx,116 status = dcerpc_epm_Lookup(b, tmp_ctx, 82 117 0, /* rpc_c_ep_all */ 83 118 NULL, … … 86 121 &entry_handle, 87 122 1, /* max_ents */ 88 &num_entries, &entry); 123 &num_entries, &entry, 124 &result); 89 125 if (!NT_STATUS_IS_OK(status)) { 90 d_fprintf(stderr, " rpccli_epm_Lookup returned %s\n",126 d_fprintf(stderr, "dcerpc_epm_Lookup returned %s\n", 91 127 nt_errstr(status)); 92 128 break; 93 129 } 94 130 131 if (result == EPMAPPER_STATUS_NO_MORE_ENTRIES) { 132 d_fprintf(stderr, "epm_Lookup no more entries\n"); 133 break; 134 } 135 136 if (result != EPMAPPER_STATUS_OK) { 137 d_fprintf(stderr, "epm_Lookup returned %u (0x%08X)\n", 138 result, result); 139 break; 140 } 141 95 142 if (num_entries != 1) { 96 d_fprintf(stderr, " rpccli_epm_Lookup returned %d "143 d_fprintf(stderr, "epm_Lookup returned %d " 97 144 "entries, expected one\n", (int)num_entries); 98 145 break; -
vendor/current/source3/rpcclient/cmd_eventlog.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/cli_eventlog.h" 23 #include "../librpc/gen_ndr/ndr_eventlog.h" 24 #include "../librpc/gen_ndr/ndr_eventlog_c.h" 25 #include "rpc_client/init_lsa.h" 24 26 25 27 static NTSTATUS get_eventlog_handle(struct rpc_pipe_client *cli, … … 28 30 struct policy_handle *handle) 29 31 { 30 NTSTATUS status ;32 NTSTATUS status, result; 31 33 struct eventlog_OpenUnknown0 unknown0; 32 34 struct lsa_String logname, servername; 35 struct dcerpc_binding_handle *b = cli->binding_handle; 33 36 34 37 unknown0.unknown0 = 0x005c; … … 38 41 init_lsa_String(&servername, NULL); 39 42 40 status = rpccli_eventlog_OpenEventLogW(cli, mem_ctx,43 status = dcerpc_eventlog_OpenEventLogW(b, mem_ctx, 41 44 &unknown0, 42 45 &logname, … … 44 47 0x00000001, /* major */ 45 48 0x00000001, /* minor */ 46 handle); 47 if (!NT_STATUS_IS_OK(status)) { 48 return status; 49 } 50 51 return NT_STATUS_OK; 49 handle, 50 &result); 51 if (!NT_STATUS_IS_OK(status)) { 52 return status; 53 } 54 55 return result; 52 56 } 53 57 … … 58 62 { 59 63 NTSTATUS status = NT_STATUS_OK; 60 struct policy_handle handle; 64 NTSTATUS result = NT_STATUS_OK; 65 struct policy_handle handle; 66 struct dcerpc_binding_handle *b = cli->binding_handle; 61 67 62 68 uint32_t flags = EVENTLOG_BACKWARDS_READ | … … 98 104 uint32_t pos = 0; 99 105 100 status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,106 status = dcerpc_eventlog_ReadEventLogW(b, mem_ctx, 101 107 &handle, 102 108 flags, … … 105 111 data, 106 112 &sent_size, 107 &real_size); 108 if (NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL) && 113 &real_size, 114 &result); 115 if (!NT_STATUS_IS_OK(status)) { 116 return status; 117 } 118 if (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) && 109 119 real_size > 0 ) { 110 120 number_of_bytes = real_size; … … 113 123 goto done; 114 124 } 115 status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,125 status = dcerpc_eventlog_ReadEventLogW(b, mem_ctx, 116 126 &handle, 117 127 flags, … … 120 130 data, 121 131 &sent_size, 122 &real_size); 132 &real_size, 133 &result); 134 if (!NT_STATUS_IS_OK(status)) { 135 return status; 136 } 123 137 } 124 138 125 if (!NT_STATUS_EQUAL( status, NT_STATUS_END_OF_FILE) &&126 !NT_STATUS_IS_OK( status)) {139 if (!NT_STATUS_EQUAL(result, NT_STATUS_END_OF_FILE) && 140 !NT_STATUS_IS_OK(result)) { 127 141 goto done; 128 142 } … … 136 150 blob = data_blob_const(data + pos, size); 137 151 /* dump_data(0, blob.data, blob.length); */ 138 ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL,&r,152 ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, &r, 139 153 (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD); 140 154 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 156 170 offset++; 157 171 158 } while (NT_STATUS_IS_OK( status));159 160 done: 161 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);172 } while (NT_STATUS_IS_OK(result)); 173 174 done: 175 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 162 176 163 177 return status; … … 169 183 const char **argv) 170 184 { 171 NTSTATUS status ;185 NTSTATUS status, result; 172 186 struct policy_handle handle; 173 187 uint32_t number = 0; 188 struct dcerpc_binding_handle *b = cli->binding_handle; 174 189 175 190 if (argc != 2) { … … 183 198 } 184 199 185 status = rpccli_eventlog_GetNumRecords(cli, mem_ctx,200 status = dcerpc_eventlog_GetNumRecords(b, mem_ctx, 186 201 &handle, 187 &number); 188 if (!NT_STATUS_IS_OK(status)) { 202 &number, 203 &result); 204 if (!NT_STATUS_IS_OK(status)) { 205 goto done; 206 } 207 if (!NT_STATUS_IS_OK(result)) { 208 status = result; 189 209 goto done; 190 210 } … … 193 213 194 214 done: 195 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);215 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 196 216 197 217 return status; … … 203 223 const char **argv) 204 224 { 205 NTSTATUS status ;225 NTSTATUS status, result; 206 226 struct policy_handle handle; 207 227 uint32_t oldest_entry = 0; 228 struct dcerpc_binding_handle *b = cli->binding_handle; 208 229 209 230 if (argc != 2) { … … 217 238 } 218 239 219 status = rpccli_eventlog_GetOldestRecord(cli, mem_ctx,240 status = dcerpc_eventlog_GetOldestRecord(b, mem_ctx, 220 241 &handle, 221 &oldest_entry); 222 if (!NT_STATUS_IS_OK(status)) { 242 &oldest_entry, 243 &result); 244 if (!NT_STATUS_IS_OK(status)) { 245 goto done; 246 } 247 if (!NT_STATUS_IS_OK(result)) { 248 status = result; 223 249 goto done; 224 250 } … … 227 253 228 254 done: 229 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);255 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 230 256 231 257 return status; … … 237 263 const char **argv) 238 264 { 239 NTSTATUS status; 240 struct policy_handle handle; 265 NTSTATUS status, result; 266 struct policy_handle handle; 267 struct dcerpc_binding_handle *b = cli->binding_handle; 241 268 242 269 uint16_t num_of_strings = 1; … … 266 293 init_lsa_String(&servername, NULL); 267 294 268 status = rpccli_eventlog_ReportEventW(cli, mem_ctx,295 status = dcerpc_eventlog_ReportEventW(b, mem_ctx, 269 296 &handle, 270 297 time(NULL), … … 280 307 0, /* flags */ 281 308 &record_number, 282 &time_written); 283 284 if (!NT_STATUS_IS_OK(status)) { 309 &time_written, 310 &result); 311 312 if (!NT_STATUS_IS_OK(status)) { 313 goto done; 314 } 315 if (!NT_STATUS_IS_OK(result)) { 316 status = result; 285 317 goto done; 286 318 } … … 290 322 291 323 done: 292 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);324 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 293 325 294 326 return status; … … 300 332 const char **argv) 301 333 { 302 NTSTATUS status; 303 struct policy_handle handle; 334 NTSTATUS status, result; 335 struct policy_handle handle; 336 struct dcerpc_binding_handle *b = cli->binding_handle; 304 337 305 338 uint16_t num_of_strings = 1; … … 330 363 init_lsa_String(&sourcename, "rpcclient"); 331 364 332 status = rpccli_eventlog_ReportEventAndSourceW(cli, mem_ctx,365 status = dcerpc_eventlog_ReportEventAndSourceW(b, mem_ctx, 333 366 &handle, 334 367 time(NULL), … … 345 378 0, /* flags */ 346 379 &record_number, 347 &time_written); 348 if (!NT_STATUS_IS_OK(status)) { 380 &time_written, 381 &result); 382 if (!NT_STATUS_IS_OK(status)) { 383 goto done; 384 } 385 if (!NT_STATUS_IS_OK(result)) { 386 status = result; 349 387 goto done; 350 388 } … … 354 392 355 393 done: 356 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);394 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 357 395 358 396 return status; … … 364 402 const char **argv) 365 403 { 366 NTSTATUS status ;404 NTSTATUS status, result; 367 405 struct policy_handle log_handle; 368 406 struct lsa_String module_name, reg_module_name; 369 407 struct eventlog_OpenUnknown0 unknown0; 408 struct dcerpc_binding_handle *b = cli->binding_handle; 370 409 371 410 unknown0.unknown0 = 0x005c; … … 380 419 init_lsa_String(®_module_name, NULL); 381 420 382 status = rpccli_eventlog_RegisterEventSourceW(cli, mem_ctx,421 status = dcerpc_eventlog_RegisterEventSourceW(b, mem_ctx, 383 422 &unknown0, 384 423 &module_name, … … 386 425 1, /* major_version */ 387 426 1, /* minor_version */ 388 &log_handle); 389 if (!NT_STATUS_IS_OK(status)) { 390 goto done; 391 } 392 393 done: 394 rpccli_eventlog_DeregisterEventSource(cli, mem_ctx, &log_handle); 427 &log_handle, 428 &result); 429 if (!NT_STATUS_IS_OK(status)) { 430 goto done; 431 } 432 if (!NT_STATUS_IS_OK(result)) { 433 status = result; 434 goto done; 435 } 436 437 done: 438 dcerpc_eventlog_DeregisterEventSource(b, mem_ctx, &log_handle, &result); 395 439 396 440 return status; … … 402 446 const char **argv) 403 447 { 404 NTSTATUS status ;448 NTSTATUS status, result; 405 449 struct policy_handle handle; 406 450 struct lsa_String backup_filename; 407 451 const char *tmp; 452 struct dcerpc_binding_handle *b = cli->binding_handle; 408 453 409 454 if (argc != 3) { … … 425 470 init_lsa_String(&backup_filename, tmp); 426 471 427 status = rpccli_eventlog_BackupEventLogW(cli, mem_ctx,472 status = dcerpc_eventlog_BackupEventLogW(b, mem_ctx, 428 473 &handle, 429 &backup_filename); 430 431 done: 432 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle); 474 &backup_filename, 475 &result); 476 if (!NT_STATUS_IS_OK(status)) { 477 goto done; 478 } 479 if (!NT_STATUS_IS_OK(result)) { 480 status = result; 481 goto done; 482 } 483 484 done: 485 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 433 486 434 487 return status; … … 440 493 const char **argv) 441 494 { 442 NTSTATUS status ;495 NTSTATUS status, result; 443 496 struct policy_handle handle; 444 497 uint8_t *buffer = NULL; 445 498 uint32_t buf_size = 0; 446 499 uint32_t bytes_needed = 0; 500 struct dcerpc_binding_handle *b = cli->binding_handle; 447 501 448 502 if (argc != 2) { … … 456 510 } 457 511 458 status = rpccli_eventlog_GetLogInformation(cli, mem_ctx,512 status = dcerpc_eventlog_GetLogInformation(b, mem_ctx, 459 513 &handle, 460 514 0, /* level */ 461 515 buffer, 462 516 buf_size, 463 &bytes_needed); 464 if (!NT_STATUS_IS_OK(status) && 465 !NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL)) { 517 &bytes_needed, 518 &result); 519 if (!NT_STATUS_IS_OK(status)) { 520 goto done; 521 } 522 if (!NT_STATUS_IS_OK(result) && 523 !NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) { 466 524 goto done; 467 525 } … … 474 532 } 475 533 476 status = rpccli_eventlog_GetLogInformation(cli, mem_ctx,534 status = dcerpc_eventlog_GetLogInformation(b, mem_ctx, 477 535 &handle, 478 536 0, /* level */ 479 537 buffer, 480 538 buf_size, 481 &bytes_needed); 482 if (!NT_STATUS_IS_OK(status)) { 483 goto done; 484 } 485 486 done: 487 rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle); 539 &bytes_needed, 540 &result); 541 if (!NT_STATUS_IS_OK(status)) { 542 goto done; 543 } 544 if (!NT_STATUS_IS_OK(result)) { 545 status = result; 546 goto done; 547 } 548 549 done: 550 dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result); 488 551 489 552 return status; -
vendor/current/source3/rpcclient/cmd_lsarpc.c
r414 r740 11 11 the Free Software Foundation; either version 3 of the License, or 12 12 (at your option) any later version. 13 13 14 14 This program is distributed in the hope that it will be useful, 15 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 17 GNU General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 24 24 #include "rpcclient.h" 25 25 #include "../libcli/auth/libcli_auth.h" 26 #include "../librpc/gen_ndr/cli_lsa.h" 26 #include "../librpc/gen_ndr/ndr_lsa.h" 27 #include "../librpc/gen_ndr/ndr_lsa_c.h" 28 #include "rpc_client/cli_lsarpc.h" 29 #include "rpc_client/init_lsa.h" 30 #include "../libcli/security/security.h" 27 31 28 32 /* useful function to allow entering a name instead of a SID and … … 30 34 static NTSTATUS name_to_sid(struct rpc_pipe_client *cli, 31 35 TALLOC_CTX *mem_ctx, 32 DOM_SID*sid, const char *name)36 struct dom_sid *sid, const char *name) 33 37 { 34 38 struct policy_handle pol; 35 39 enum lsa_SidType *sid_types; 36 NTSTATUS result; 37 DOM_SID *sids; 40 NTSTATUS status, result; 41 struct dom_sid *sids; 42 struct dcerpc_binding_handle *b = cli->binding_handle; 38 43 39 44 /* maybe its a raw SID */ … … 43 48 } 44 49 45 result = rpccli_lsa_open_policy(cli, mem_ctx, True,50 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 46 51 SEC_FLAG_MAXIMUM_ALLOWED, 47 52 &pol); 48 if (!NT_STATUS_IS_OK( result))49 goto done; 50 51 result= rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);52 if (!NT_STATUS_IS_OK( result))53 goto done; 54 55 rpccli_lsa_Close(cli, mem_ctx, &pol);53 if (!NT_STATUS_IS_OK(status)) 54 goto done; 55 56 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types); 57 if (!NT_STATUS_IS_OK(status)) 58 goto done; 59 60 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 56 61 57 62 *sid = sids[0]; 58 63 59 64 done: 60 return result;65 return status; 61 66 } 62 67 … … 153 158 { 154 159 struct policy_handle pol; 155 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;160 NTSTATUS status, result; 156 161 union lsa_PolicyInformation *info = NULL; 162 struct dcerpc_binding_handle *b = cli->binding_handle; 157 163 158 164 uint32 info_class = 3; … … 168 174 switch (info_class) { 169 175 case 12: 170 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,176 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 171 177 SEC_FLAG_MAXIMUM_ALLOWED, 172 178 &pol); 173 179 174 if (!NT_STATUS_IS_OK( result))180 if (!NT_STATUS_IS_OK(status)) 175 181 goto done; 176 177 result = rpccli_lsa_QueryInfoPolicy2(cli, mem_ctx,182 183 status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx, 178 184 &pol, 179 185 info_class, 180 &info); 186 &info, 187 &result); 181 188 break; 182 189 default: 183 result = rpccli_lsa_open_policy(cli, mem_ctx, True,190 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 184 191 SEC_FLAG_MAXIMUM_ALLOWED, 185 192 &pol); 186 193 187 if (!NT_STATUS_IS_OK( result))194 if (!NT_STATUS_IS_OK(status)) 188 195 goto done; 189 190 result = rpccli_lsa_QueryInfoPolicy(cli, mem_ctx,196 197 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 191 198 &pol, 192 199 info_class, 193 &info); 194 } 195 200 &info, 201 &result); 202 } 203 204 if (!NT_STATUS_IS_OK(status)) { 205 goto done; 206 } 207 status = result; 196 208 if (NT_STATUS_IS_OK(result)) { 197 209 display_lsa_query_info(info, info_class); 198 210 } 199 211 200 rpccli_lsa_Close(cli, mem_ctx, &pol);201 202 done: 203 return result;212 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 213 214 done: 215 return status; 204 216 } 205 217 … … 211 223 { 212 224 struct policy_handle pol; 213 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;214 DOM_SID*sids;225 NTSTATUS status, result; 226 struct dom_sid *sids; 215 227 enum lsa_SidType *types; 216 228 int i; 229 struct dcerpc_binding_handle *b = cli->binding_handle; 217 230 218 231 if (argc == 1) { … … 221 234 } 222 235 223 result = rpccli_lsa_open_policy(cli, mem_ctx, True,236 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 224 237 SEC_FLAG_MAXIMUM_ALLOWED, 225 238 &pol); 226 239 227 if (!NT_STATUS_IS_OK( result))228 goto done; 229 230 result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,240 if (!NT_STATUS_IS_OK(status)) 241 goto done; 242 243 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, 231 244 (const char**)(argv + 1), NULL, 1, &sids, &types); 232 245 233 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=246 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 234 247 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 235 248 goto done; 236 249 237 result= NT_STATUS_OK;250 status = NT_STATUS_OK; 238 251 239 252 /* Print results */ … … 246 259 } 247 260 248 rpccli_lsa_Close(cli, mem_ctx, &pol);249 250 done: 251 return result;261 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 262 263 done: 264 return status; 252 265 } 253 266 … … 259 272 { 260 273 struct policy_handle pol; 261 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;262 DOM_SID*sids;274 NTSTATUS status, result; 275 struct dom_sid *sids; 263 276 enum lsa_SidType *types; 264 277 int i, level; 278 struct dcerpc_binding_handle *b = cli->binding_handle; 265 279 266 280 if (argc < 3) { … … 269 283 } 270 284 271 result = rpccli_lsa_open_policy(cli, mem_ctx, True,285 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 272 286 SEC_FLAG_MAXIMUM_ALLOWED, 273 287 &pol); 274 288 275 if (!NT_STATUS_IS_OK( result))289 if (!NT_STATUS_IS_OK(status)) 276 290 goto done; 277 291 278 292 level = atoi(argv[1]); 279 293 280 result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,294 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2, 281 295 (const char**)(argv + 2), NULL, level, &sids, &types); 282 296 283 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=297 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 284 298 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 285 299 goto done; 286 300 287 result= NT_STATUS_OK;301 status = NT_STATUS_OK; 288 302 289 303 /* Print results */ … … 296 310 } 297 311 298 rpccli_lsa_Close(cli, mem_ctx, &pol);299 300 done: 301 return result;312 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 313 314 done: 315 return status; 302 316 } 303 317 … … 306 320 const char **argv) 307 321 { 308 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;322 NTSTATUS status, result; 309 323 310 324 uint32_t num_names; … … 314 328 uint32_t count = 0; 315 329 int i; 330 struct dcerpc_binding_handle *b = cli->binding_handle; 316 331 317 332 if (argc == 1) { … … 330 345 } 331 346 332 result = rpccli_lsa_LookupNames4(cli, mem_ctx,347 status = dcerpc_lsa_LookupNames4(b, mem_ctx, 333 348 num_names, 334 349 names, … … 338 353 &count, 339 354 0, 340 0); 355 0, 356 &result); 357 if (!NT_STATUS_IS_OK(status)) { 358 return status; 359 } 341 360 if (!NT_STATUS_IS_OK(result)) { 342 361 return result; … … 351 370 } 352 371 353 return result;372 return status; 354 373 } 355 374 … … 360 379 { 361 380 struct policy_handle pol; 362 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;363 DOM_SID*sids;381 NTSTATUS status, result; 382 struct dom_sid *sids; 364 383 char **domains; 365 384 char **names; 366 385 enum lsa_SidType *types; 367 386 int i; 387 struct dcerpc_binding_handle *b = cli->binding_handle; 368 388 369 389 if (argc == 1) { … … 372 392 } 373 393 374 result = rpccli_lsa_open_policy(cli, mem_ctx, True,394 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 375 395 SEC_FLAG_MAXIMUM_ALLOWED, 376 396 &pol); 377 397 378 if (!NT_STATUS_IS_OK( result))398 if (!NT_STATUS_IS_OK(status)) 379 399 goto done; 380 400 381 401 /* Convert arguments to sids */ 382 402 383 sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);403 sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, argc - 1); 384 404 385 405 if (!sids) { … … 390 410 for (i = 0; i < argc - 1; i++) 391 411 if (!string_to_sid(&sids[i], argv[i + 1])) { 392 result= NT_STATUS_INVALID_SID;412 status = NT_STATUS_INVALID_SID; 393 413 goto done; 394 414 } … … 396 416 /* Lookup the SIDs */ 397 417 398 result = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,418 status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, 399 419 &domains, &names, &types); 400 420 401 if (!NT_STATUS_IS_OK( result) && NT_STATUS_V(result) !=421 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) != 402 422 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 403 423 goto done; 404 424 405 result= NT_STATUS_OK;425 status = NT_STATUS_OK; 406 426 407 427 /* Print results */ … … 416 436 } 417 437 418 rpccli_lsa_Close(cli, mem_ctx, &pol);419 420 done: 421 return result;438 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 439 440 done: 441 return status; 422 442 } 423 443 … … 428 448 int argc, const char **argv) 429 449 { 430 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;450 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result; 431 451 int i; 432 452 struct lsa_SidArray sids; … … 434 454 struct lsa_TransNameArray2 names; 435 455 uint32_t count = 0; 456 struct dcerpc_binding_handle *b = cli->binding_handle; 436 457 437 458 if (argc == 1) { … … 452 473 453 474 for (i = 0; i < sids.num_sids; i++) { 454 sids.sids[ 0].sid = string_sid_talloc(sids.sids, argv[i + 1]);455 if ( !sids.sids[0].sid) {456 result = NT_STATUS_INVALID_SID;475 sids.sids[i].sid = talloc(sids.sids, struct dom_sid); 476 if (sids.sids[i].sid == NULL) { 477 status = NT_STATUS_NO_MEMORY; 457 478 goto done; 458 479 } 480 if (!string_to_sid(sids.sids[i].sid, argv[i+1])) { 481 status = NT_STATUS_INVALID_SID; 482 goto done; 483 } 459 484 } 460 485 461 486 /* Lookup the SIDs */ 462 result = rpccli_lsa_LookupSids3(cli, mem_ctx,487 status = dcerpc_lsa_LookupSids3(b, mem_ctx, 463 488 &sids, 464 489 &domains, … … 467 492 &count, 468 493 0, 469 0); 470 494 0, 495 &result); 496 if (!NT_STATUS_IS_OK(status)) { 497 goto done; 498 } 471 499 if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != 472 NT_STATUS_V(STATUS_SOME_UNMAPPED)) 473 goto done; 474 475 result = NT_STATUS_OK; 500 NT_STATUS_V(STATUS_SOME_UNMAPPED)) { 501 status = result; 502 goto done; 503 } 504 505 status = NT_STATUS_OK; 476 506 477 507 /* Print results */ … … 487 517 488 518 done: 489 return result;519 return status; 490 520 } 491 521 … … 498 528 { 499 529 struct policy_handle pol; 500 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;530 NTSTATUS status, result; 501 531 struct lsa_DomainList domain_list; 532 struct dcerpc_binding_handle *b = cli->binding_handle; 502 533 503 534 /* defaults, but may be changed using params */ … … 515 546 } 516 547 517 result = rpccli_lsa_open_policy(cli, mem_ctx, True,548 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 518 549 LSA_POLICY_VIEW_LOCAL_INFORMATION, 519 550 &pol); 520 551 521 if (!NT_STATUS_IS_OK( result))522 goto done; 523 524 result= STATUS_MORE_ENTRIES;525 526 while (NT_STATUS_EQUAL( result, STATUS_MORE_ENTRIES)) {552 if (!NT_STATUS_IS_OK(status)) 553 goto done; 554 555 status = STATUS_MORE_ENTRIES; 556 557 while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { 527 558 528 559 /* Lookup list of trusted domains */ 529 560 530 result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,561 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 531 562 &pol, 532 563 &enum_ctx, 533 564 &domain_list, 534 max_size); 565 max_size, 566 &result); 567 if (!NT_STATUS_IS_OK(status)) { 568 goto done; 569 } 535 570 if (!NT_STATUS_IS_OK(result) && 536 571 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) && 537 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) 572 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) { 573 status = result; 538 574 goto done; 575 } 539 576 540 577 /* Print results: list of names and sids returned in this … … 551 588 } 552 589 553 rpccli_lsa_Close(cli, mem_ctx, &pol);554 done: 555 return result;590 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 591 done: 592 return status; 556 593 } 557 594 … … 563 600 { 564 601 struct policy_handle pol; 565 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;602 NTSTATUS status, result; 566 603 struct lsa_PrivArray priv_array; 604 struct dcerpc_binding_handle *b = cli->binding_handle; 567 605 568 606 uint32 enum_context=0; … … 581 619 pref_max_length=atoi(argv[2]); 582 620 583 result = rpccli_lsa_open_policy(cli, mem_ctx, True,621 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 584 622 SEC_FLAG_MAXIMUM_ALLOWED, 585 623 &pol); 586 624 587 if (!NT_STATUS_IS_OK( result))588 goto done; 589 590 result = rpccli_lsa_EnumPrivs(cli, mem_ctx,625 if (!NT_STATUS_IS_OK(status)) 626 goto done; 627 628 status = dcerpc_lsa_EnumPrivs(b, mem_ctx, 591 629 &pol, 592 630 &enum_context, 593 631 &priv_array, 594 pref_max_length); 595 if (!NT_STATUS_IS_OK(result)) 596 goto done; 632 pref_max_length, 633 &result); 634 if (!NT_STATUS_IS_OK(status)) 635 goto done; 636 if (!NT_STATUS_IS_OK(result)) { 637 status = result; 638 goto done; 639 } 597 640 598 641 /* Print results */ … … 608 651 } 609 652 610 rpccli_lsa_Close(cli, mem_ctx, &pol);611 done: 612 return result;653 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 654 done: 655 return status; 613 656 } 614 657 … … 620 663 { 621 664 struct policy_handle pol; 622 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 665 NTSTATUS status, result; 666 struct dcerpc_binding_handle *b = cli->binding_handle; 623 667 624 668 uint16 lang_id=0; … … 633 677 } 634 678 635 result = rpccli_lsa_open_policy(cli, mem_ctx, True,679 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 636 680 SEC_FLAG_MAXIMUM_ALLOWED, 637 681 &pol); 638 682 639 if (!NT_STATUS_IS_OK( result))683 if (!NT_STATUS_IS_OK(status)) 640 684 goto done; 641 685 642 686 init_lsa_String(&lsa_name, argv[1]); 643 687 644 result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,688 status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx, 645 689 &pol, 646 690 &lsa_name, … … 648 692 lang_id_sys, 649 693 &description, 650 &lang_id_desc); 651 652 if (!NT_STATUS_IS_OK(result)) 653 goto done; 694 &lang_id_desc, 695 &result); 696 if (!NT_STATUS_IS_OK(status)) 697 goto done; 698 if (!NT_STATUS_IS_OK(result)) { 699 status = result; 700 goto done; 701 } 654 702 655 703 /* Print results */ 656 704 printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc); 657 705 658 rpccli_lsa_Close(cli, mem_ctx, &pol);659 done: 660 return result;706 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 707 done: 708 return status; 661 709 } 662 710 … … 668 716 { 669 717 struct policy_handle pol; 670 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 718 NTSTATUS status, result; 719 struct dcerpc_binding_handle *b = cli->binding_handle; 671 720 672 721 uint32 enum_context=0; … … 686 735 pref_max_length=atoi(argv[2]); 687 736 688 result = rpccli_lsa_open_policy(cli, mem_ctx, True,737 status = rpccli_lsa_open_policy(cli, mem_ctx, True, 689 738 SEC_FLAG_MAXIMUM_ALLOWED, 690 739 &pol); 691 740 692 if (!NT_STATUS_IS_OK( result))693 goto done; 694 695 result = rpccli_lsa_EnumAccounts(cli, mem_ctx,741 if (!NT_STATUS_IS_OK(status)) 742 goto done; 743 744 status = dcerpc_lsa_EnumAccounts(b, mem_ctx, 696 745 &pol, 697 746 &enum_context, 698 747 &sid_array, 699 pref_max_length); 700 701 if (!NT_STATUS_IS_OK(result)) 702 goto done; 748 pref_max_length, 749 &result); 750 if (!NT_STATUS_IS_OK(status)) 751 goto done; 752 if (!NT_STATUS_IS_OK(result)) { 753 status = result; 754 goto done; 755 } 703 756 704 757 /* Print results */ … … 712 765 } 713 766 714 rpccli_lsa_Close(cli, mem_ctx, &pol);715 done: 716 return result;767 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 768 done: 769 return status; 717 770 } 718 771 … … 725 778 struct policy_handle dom_pol; 726 779 struct policy_handle user_pol; 727 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;780 NTSTATUS status, result; 728 781 uint32 des_access = 0x000f000f; 729 730 DOM_SID sid; 782 struct dcerpc_binding_handle *b = cli->binding_handle; 783 784 struct dom_sid sid; 731 785 732 786 if (argc != 2 ) { … … 735 789 } 736 790 737 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);738 if (!NT_STATUS_IS_OK( result))791 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 792 if (!NT_STATUS_IS_OK(status)) 739 793 goto done; 740 794 741 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,795 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 742 796 SEC_FLAG_MAXIMUM_ALLOWED, 743 797 &dom_pol); 744 798 745 if (!NT_STATUS_IS_OK( result))746 goto done; 747 748 result = rpccli_lsa_CreateAccount(cli, mem_ctx,799 if (!NT_STATUS_IS_OK(status)) 800 goto done; 801 802 status = dcerpc_lsa_CreateAccount(b, mem_ctx, 749 803 &dom_pol, 750 804 &sid, 751 805 des_access, 752 &user_pol); 753 754 if (!NT_STATUS_IS_OK(result)) 755 goto done; 806 &user_pol, 807 &result); 808 if (!NT_STATUS_IS_OK(status)) 809 goto done; 810 if (!NT_STATUS_IS_OK(result)) { 811 status = result; 812 goto done; 813 } 756 814 757 815 printf("Account for SID %s successfully created\n\n", argv[1]); 758 result= NT_STATUS_OK;759 760 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);761 done: 762 return result;816 status = NT_STATUS_OK; 817 818 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 819 done: 820 return status; 763 821 } 764 822 … … 772 830 struct policy_handle dom_pol; 773 831 struct policy_handle user_pol; 774 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;832 NTSTATUS status, result; 775 833 uint32 access_desired = 0x000f000f; 776 DOM_SIDsid;834 struct dom_sid sid; 777 835 struct lsa_PrivilegeSet *privs = NULL; 778 836 int i; 837 struct dcerpc_binding_handle *b = cli->binding_handle; 779 838 780 839 if (argc != 2 ) { … … 783 842 } 784 843 785 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);786 if (!NT_STATUS_IS_OK( result))844 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 845 if (!NT_STATUS_IS_OK(status)) 787 846 goto done; 788 847 789 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,848 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 790 849 SEC_FLAG_MAXIMUM_ALLOWED, 791 850 &dom_pol); 792 851 793 if (!NT_STATUS_IS_OK( result))794 goto done; 795 796 result = rpccli_lsa_OpenAccount(cli, mem_ctx,852 if (!NT_STATUS_IS_OK(status)) 853 goto done; 854 855 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 797 856 &dom_pol, 798 857 &sid, 799 858 access_desired, 800 &user_pol); 801 802 if (!NT_STATUS_IS_OK(result)) 803 goto done; 804 805 result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx, 859 &user_pol, 860 &result); 861 if (!NT_STATUS_IS_OK(status)) 862 goto done; 863 if (!NT_STATUS_IS_OK(result)) { 864 status = result; 865 goto done; 866 } 867 868 status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx, 806 869 &user_pol, 807 &privs); 808 809 if (!NT_STATUS_IS_OK(result)) 810 goto done; 870 &privs, 871 &result); 872 if (!NT_STATUS_IS_OK(status)) 873 goto done; 874 if (!NT_STATUS_IS_OK(result)) { 875 status = result; 876 goto done; 877 } 811 878 812 879 /* Print results */ … … 821 888 } 822 889 823 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);824 done: 825 return result;890 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 891 done: 892 return status; 826 893 } 827 894 … … 834 901 { 835 902 struct policy_handle dom_pol; 836 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;837 DOM_SIDsid;903 NTSTATUS status, result; 904 struct dom_sid sid; 838 905 struct lsa_RightSet rights; 906 struct dcerpc_binding_handle *b = cli->binding_handle; 839 907 840 908 int i; … … 845 913 } 846 914 847 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);848 if (!NT_STATUS_IS_OK( result))915 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 916 if (!NT_STATUS_IS_OK(status)) 849 917 goto done; 850 918 851 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,919 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 852 920 SEC_FLAG_MAXIMUM_ALLOWED, 853 921 &dom_pol); 854 922 855 if (!NT_STATUS_IS_OK( result))856 goto done; 857 858 result = rpccli_lsa_EnumAccountRights(cli, mem_ctx,923 if (!NT_STATUS_IS_OK(status)) 924 goto done; 925 926 status = dcerpc_lsa_EnumAccountRights(b, mem_ctx, 859 927 &dom_pol, 860 928 &sid, 861 &rights); 862 863 if (!NT_STATUS_IS_OK(result)) 864 goto done; 929 &rights, 930 &result); 931 if (!NT_STATUS_IS_OK(status)) 932 goto done; 933 if (!NT_STATUS_IS_OK(result)) { 934 status = result; 935 goto done; 936 } 865 937 866 938 printf("found %d privileges for SID %s\n", rights.count, … … 871 943 } 872 944 873 rpccli_lsa_Close(cli, mem_ctx, &dom_pol);874 done: 875 return result;945 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 946 done: 947 return status; 876 948 } 877 949 … … 884 956 { 885 957 struct policy_handle dom_pol; 886 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;958 NTSTATUS status, result; 887 959 struct lsa_RightSet rights; 888 DOM_SIDsid;960 struct dom_sid sid; 889 961 int i; 962 struct dcerpc_binding_handle *b = cli->binding_handle; 890 963 891 964 if (argc < 3 ) { … … 894 967 } 895 968 896 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);897 if (!NT_STATUS_IS_OK( result))969 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 970 if (!NT_STATUS_IS_OK(status)) 898 971 goto done; 899 972 900 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,973 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 901 974 SEC_FLAG_MAXIMUM_ALLOWED, 902 975 &dom_pol); 903 976 904 if (!NT_STATUS_IS_OK( result))977 if (!NT_STATUS_IS_OK(status)) 905 978 goto done; 906 979 … … 916 989 } 917 990 918 result = rpccli_lsa_AddAccountRights(cli, mem_ctx,991 status = dcerpc_lsa_AddAccountRights(b, mem_ctx, 919 992 &dom_pol, 920 993 &sid, 921 &rights); 922 923 if (!NT_STATUS_IS_OK(result)) 924 goto done; 925 926 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 927 done: 928 return result; 994 &rights, 995 &result); 996 if (!NT_STATUS_IS_OK(status)) 997 goto done; 998 if (!NT_STATUS_IS_OK(result)) { 999 status = result; 1000 goto done; 1001 } 1002 1003 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1004 done: 1005 return status; 929 1006 } 930 1007 … … 937 1014 { 938 1015 struct policy_handle dom_pol; 939 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1016 NTSTATUS status, result; 940 1017 struct lsa_RightSet rights; 941 DOM_SIDsid;1018 struct dom_sid sid; 942 1019 int i; 1020 struct dcerpc_binding_handle *b = cli->binding_handle; 943 1021 944 1022 if (argc < 3 ) { … … 947 1025 } 948 1026 949 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);950 if (!NT_STATUS_IS_OK( result))1027 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1028 if (!NT_STATUS_IS_OK(status)) 951 1029 goto done; 952 1030 953 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1031 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 954 1032 SEC_FLAG_MAXIMUM_ALLOWED, 955 1033 &dom_pol); 956 1034 957 if (!NT_STATUS_IS_OK( result))1035 if (!NT_STATUS_IS_OK(status)) 958 1036 goto done; 959 1037 … … 969 1047 } 970 1048 971 result = rpccli_lsa_RemoveAccountRights(cli, mem_ctx,1049 status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx, 972 1050 &dom_pol, 973 1051 &sid, 974 1052 false, 975 &rights); 976 977 if (!NT_STATUS_IS_OK(result)) 978 goto done; 979 980 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 981 982 done: 983 return result; 1053 &rights, 1054 &result); 1055 if (!NT_STATUS_IS_OK(status)) 1056 goto done; 1057 if (!NT_STATUS_IS_OK(result)) { 1058 status = result; 1059 goto done; 1060 } 1061 1062 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1063 1064 done: 1065 return status; 984 1066 } 985 1067 … … 992 1074 { 993 1075 struct policy_handle pol; 994 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1076 NTSTATUS status, result; 995 1077 struct lsa_LUID luid; 996 1078 struct lsa_String name; 1079 struct dcerpc_binding_handle *b = cli->binding_handle; 997 1080 998 1081 if (argc != 2 ) { … … 1001 1084 } 1002 1085 1003 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1086 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1004 1087 SEC_FLAG_MAXIMUM_ALLOWED, 1005 1088 &pol); 1006 1089 1007 if (!NT_STATUS_IS_OK( result))1090 if (!NT_STATUS_IS_OK(status)) 1008 1091 goto done; 1009 1092 1010 1093 init_lsa_String(&name, argv[1]); 1011 1094 1012 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1095 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1013 1096 &pol, 1014 1097 &name, 1015 &luid); 1016 1017 if (!NT_STATUS_IS_OK(result)) 1018 goto done; 1098 &luid, 1099 &result); 1100 if (!NT_STATUS_IS_OK(status)) 1101 goto done; 1102 if (!NT_STATUS_IS_OK(result)) { 1103 status = result; 1104 goto done; 1105 } 1019 1106 1020 1107 /* Print results */ … … 1022 1109 printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low); 1023 1110 1024 rpccli_lsa_Close(cli, mem_ctx, &pol);1025 done: 1026 return result;1111 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1112 done: 1113 return status; 1027 1114 } 1028 1115 … … 1034 1121 { 1035 1122 struct policy_handle pol; 1036 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 1037 SEC_DESC_BUF *sdb; 1038 uint32 sec_info = DACL_SECURITY_INFORMATION; 1123 NTSTATUS status, result; 1124 struct sec_desc_buf *sdb; 1125 uint32 sec_info = SECINFO_DACL; 1126 struct dcerpc_binding_handle *b = cli->binding_handle; 1039 1127 1040 1128 if (argc < 1 || argc > 2) { … … 1043 1131 } 1044 1132 1045 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,1133 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1046 1134 SEC_FLAG_MAXIMUM_ALLOWED, 1047 1135 &pol); … … 1050 1138 sscanf(argv[1], "%x", &sec_info); 1051 1139 1052 if (!NT_STATUS_IS_OK( result))1053 goto done; 1054 1055 result = rpccli_lsa_QuerySecurity(cli, mem_ctx,1140 if (!NT_STATUS_IS_OK(status)) 1141 goto done; 1142 1143 status = dcerpc_lsa_QuerySecurity(b, mem_ctx, 1056 1144 &pol, 1057 1145 sec_info, 1058 &sdb); 1059 if (!NT_STATUS_IS_OK(result)) 1060 goto done; 1146 &sdb, 1147 &result); 1148 if (!NT_STATUS_IS_OK(status)) 1149 goto done; 1150 if (!NT_STATUS_IS_OK(result)) { 1151 status = result; 1152 goto done; 1153 } 1061 1154 1062 1155 /* Print results */ … … 1064 1157 display_sec_desc(sdb->sd); 1065 1158 1066 rpccli_lsa_Close(cli, mem_ctx, &pol);1067 done: 1068 return result;1159 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1160 done: 1161 return status; 1069 1162 } 1070 1163 … … 1073 1166 { 1074 1167 char *pwd, *pwd_old; 1075 1168 1076 1169 DATA_BLOB data = data_blob_const(p->password->data, p->password->length); 1077 1170 DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length); … … 1080 1173 pwd = sess_decrypt_string(talloc_tos(), &data, &session_key_blob); 1081 1174 pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key_blob); 1082 1175 1083 1176 d_printf("Password:\t%s\n", pwd); 1084 1177 d_printf("Old Password:\t%s\n", pwd_old); … … 1115 1208 { 1116 1209 struct policy_handle pol; 1117 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1118 DOM_SIDdom_sid;1210 NTSTATUS status, result; 1211 struct dom_sid dom_sid; 1119 1212 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1120 1213 union lsa_TrustedDomainInfo *info = NULL; 1121 1214 enum lsa_TrustDomInfoEnum info_class = 1; 1122 1215 uint8_t nt_hash[16]; 1216 struct dcerpc_binding_handle *b = cli->binding_handle; 1123 1217 1124 1218 if (argc > 3 || argc < 2) { … … 1133 1227 info_class = atoi(argv[2]); 1134 1228 1135 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1136 1137 if (!NT_STATUS_IS_OK( result))1138 goto done; 1139 1140 result = rpccli_lsa_QueryTrustedDomainInfoBySid(cli, mem_ctx,1229 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1230 1231 if (!NT_STATUS_IS_OK(status)) 1232 goto done; 1233 1234 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx, 1141 1235 &pol, 1142 1236 &dom_sid, 1143 1237 info_class, 1144 &info); 1145 if (!NT_STATUS_IS_OK(result)) 1146 goto done; 1238 &info, 1239 &result); 1240 if (!NT_STATUS_IS_OK(status)) 1241 goto done; 1242 if (!NT_STATUS_IS_OK(result)) { 1243 status = result; 1244 goto done; 1245 } 1147 1246 1148 1247 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1154 1253 1155 1254 done: 1156 rpccli_lsa_Close(cli, mem_ctx, &pol);1157 1158 return result;1255 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1256 1257 return status; 1159 1258 } 1160 1259 … … 1164 1263 { 1165 1264 struct policy_handle pol; 1166 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1265 NTSTATUS status, result; 1167 1266 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1168 1267 union lsa_TrustedDomainInfo *info = NULL; … … 1170 1269 struct lsa_String trusted_domain; 1171 1270 uint8_t nt_hash[16]; 1271 struct dcerpc_binding_handle *b = cli->binding_handle; 1172 1272 1173 1273 if (argc > 3 || argc < 2) { … … 1179 1279 info_class = atoi(argv[2]); 1180 1280 1181 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1182 1183 if (!NT_STATUS_IS_OK( result))1281 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1282 1283 if (!NT_STATUS_IS_OK(status)) 1184 1284 goto done; 1185 1285 1186 1286 init_lsa_String(&trusted_domain, argv[1]); 1187 1287 1188 result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,1288 status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx, 1189 1289 &pol, 1190 1290 &trusted_domain, 1191 1291 info_class, 1192 &info); 1193 if (!NT_STATUS_IS_OK(result)) 1194 goto done; 1292 &info, 1293 &result); 1294 if (!NT_STATUS_IS_OK(status)) 1295 goto done; 1296 if (!NT_STATUS_IS_OK(result)) { 1297 status = result; 1298 goto done; 1299 } 1195 1300 1196 1301 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1202 1307 1203 1308 done: 1204 rpccli_lsa_Close(cli, mem_ctx, &pol);1205 1206 return result;1309 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1310 1311 return status; 1207 1312 } 1208 1313 … … 1212 1317 { 1213 1318 struct policy_handle pol, trustdom_pol; 1214 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1319 NTSTATUS status, result; 1215 1320 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1216 1321 union lsa_TrustedDomainInfo *info = NULL; 1217 DOM_SIDdom_sid;1322 struct dom_sid dom_sid; 1218 1323 enum lsa_TrustDomInfoEnum info_class = 1; 1219 1324 uint8_t nt_hash[16]; 1325 struct dcerpc_binding_handle *b = cli->binding_handle; 1220 1326 1221 1327 if (argc > 3 || argc < 2) { … … 1231 1337 info_class = atoi(argv[2]); 1232 1338 1233 result= rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);1234 1235 if (!NT_STATUS_IS_OK( result))1236 goto done; 1237 1238 result = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,1339 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); 1340 1341 if (!NT_STATUS_IS_OK(status)) 1342 goto done; 1343 1344 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx, 1239 1345 &pol, 1240 1346 &dom_sid, 1241 1347 access_mask, 1242 &trustdom_pol); 1243 1244 if (!NT_STATUS_IS_OK(result)) 1245 goto done; 1246 1247 result = rpccli_lsa_QueryTrustedDomainInfo(cli, mem_ctx, 1348 &trustdom_pol, 1349 &result); 1350 if (!NT_STATUS_IS_OK(status)) 1351 goto done; 1352 if (!NT_STATUS_IS_OK(result)) { 1353 status = result; 1354 goto done; 1355 } 1356 1357 status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx, 1248 1358 &trustdom_pol, 1249 1359 info_class, 1250 &info); 1251 1252 if (!NT_STATUS_IS_OK(result)) 1253 goto done; 1360 &info, 1361 &result); 1362 if (!NT_STATUS_IS_OK(status)) 1363 goto done; 1364 if (!NT_STATUS_IS_OK(result)) { 1365 status = result; 1366 goto done; 1367 } 1254 1368 1255 1369 if (!rpccli_get_pwd_hash(cli, nt_hash)) { … … 1261 1375 1262 1376 done: 1263 rpccli_lsa_Close(cli, mem_ctx, &pol);1264 1265 return result;1377 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1378 1379 return status; 1266 1380 } 1267 1381 … … 1271 1385 { 1272 1386 struct policy_handle pol; 1273 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1387 NTSTATUS status, result; 1274 1388 const char *servername = cli->desthost; 1275 1389 struct lsa_String *account_name = NULL; 1276 1390 struct lsa_String *authority_name = NULL; 1391 struct dcerpc_binding_handle *b = cli->binding_handle; 1277 1392 1278 1393 if (argc > 2) { … … 1281 1396 } 1282 1397 1283 result= rpccli_lsa_open_policy(cli, mem_ctx, true,1398 status = rpccli_lsa_open_policy(cli, mem_ctx, true, 1284 1399 SEC_FLAG_MAXIMUM_ALLOWED, 1285 1400 &pol); 1286 1401 1287 if (!NT_STATUS_IS_OK( result)) {1288 goto done; 1289 } 1290 1291 result = rpccli_lsa_GetUserName(cli, mem_ctx,1402 if (!NT_STATUS_IS_OK(status)) { 1403 goto done; 1404 } 1405 1406 status = dcerpc_lsa_GetUserName(b, mem_ctx, 1292 1407 servername, 1293 1408 &account_name, 1294 &authority_name); 1295 if (!NT_STATUS_IS_OK(result)) { 1409 &authority_name, 1410 &result); 1411 if (!NT_STATUS_IS_OK(status)) { 1412 goto done; 1413 } 1414 if (!NT_STATUS_IS_OK(result)) { 1415 status = result; 1296 1416 goto done; 1297 1417 } … … 1303 1423 ""); 1304 1424 1305 rpccli_lsa_Close(cli, mem_ctx, &pol);1306 done: 1307 return result;1425 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 1426 done: 1427 return status; 1308 1428 } 1309 1429 … … 1313 1433 { 1314 1434 struct policy_handle dom_pol, user_pol; 1315 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1435 NTSTATUS status, result; 1316 1436 struct lsa_PrivilegeSet privs; 1317 1437 struct lsa_LUIDAttribute *set = NULL; 1318 DOM_SIDsid;1438 struct dom_sid sid; 1319 1439 int i; 1440 struct dcerpc_binding_handle *b = cli->binding_handle; 1320 1441 1321 1442 ZERO_STRUCT(privs); … … 1326 1447 } 1327 1448 1328 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);1329 if (!NT_STATUS_IS_OK( result)) {1330 goto done; 1331 } 1332 1333 result= rpccli_lsa_open_policy2(cli, mem_ctx, True,1449 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1450 if (!NT_STATUS_IS_OK(status)) { 1451 goto done; 1452 } 1453 1454 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1334 1455 SEC_FLAG_MAXIMUM_ALLOWED, 1335 1456 &dom_pol); 1336 1457 1337 if (!NT_STATUS_IS_OK( result)) {1338 goto done; 1339 } 1340 1341 result = rpccli_lsa_OpenAccount(cli, mem_ctx,1458 if (!NT_STATUS_IS_OK(status)) { 1459 goto done; 1460 } 1461 1462 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 1342 1463 &dom_pol, 1343 1464 &sid, 1344 1465 SEC_FLAG_MAXIMUM_ALLOWED, 1345 &user_pol); 1346 1347 if (!NT_STATUS_IS_OK(result)) { 1466 &user_pol, 1467 &result); 1468 if (!NT_STATUS_IS_OK(status)) { 1469 goto done; 1470 } 1471 if (!NT_STATUS_IS_OK(result)) { 1472 status = result; 1348 1473 goto done; 1349 1474 } … … 1356 1481 init_lsa_String(&priv_name, argv[i]); 1357 1482 1358 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1483 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1359 1484 &dom_pol, 1360 1485 &priv_name, 1361 &luid); 1486 &luid, 1487 &result); 1488 if (!NT_STATUS_IS_OK(status)) { 1489 continue; 1490 } 1362 1491 if (!NT_STATUS_IS_OK(result)) { 1492 status = result; 1363 1493 continue; 1364 1494 } … … 1378 1508 privs.set = set; 1379 1509 1380 result = rpccli_lsa_AddPrivilegesToAccount(cli, mem_ctx,1510 status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx, 1381 1511 &user_pol, 1382 &privs); 1383 1384 if (!NT_STATUS_IS_OK(result)) { 1385 goto done; 1386 } 1387 1388 rpccli_lsa_Close(cli, mem_ctx, &user_pol); 1389 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 1390 done: 1391 return result; 1512 &privs, 1513 &result); 1514 if (!NT_STATUS_IS_OK(status)) { 1515 goto done; 1516 } 1517 if (!NT_STATUS_IS_OK(result)) { 1518 status = result; 1519 goto done; 1520 } 1521 1522 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result); 1523 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1524 done: 1525 return status; 1392 1526 } 1393 1527 … … 1397 1531 { 1398 1532 struct policy_handle dom_pol, user_pol; 1399 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1533 NTSTATUS status, result; 1400 1534 struct lsa_PrivilegeSet privs; 1401 1535 struct lsa_LUIDAttribute *set = NULL; 1402 DOM_SIDsid;1536 struct dom_sid sid; 1403 1537 int i; 1538 struct dcerpc_binding_handle *b = cli->binding_handle; 1404 1539 1405 1540 ZERO_STRUCT(privs); … … 1410 1545 } 1411 1546 1412 result= name_to_sid(cli, mem_ctx, &sid, argv[1]);1413 if (!NT_STATUS_IS_OK( result)) {1414 goto done; 1415 } 1416 1417 result= rpccli_lsa_open_policy2(cli, mem_ctx, True,1547 status = name_to_sid(cli, mem_ctx, &sid, argv[1]); 1548 if (!NT_STATUS_IS_OK(status)) { 1549 goto done; 1550 } 1551 1552 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, 1418 1553 SEC_FLAG_MAXIMUM_ALLOWED, 1419 1554 &dom_pol); 1420 1555 1421 if (!NT_STATUS_IS_OK( result)) {1422 goto done; 1423 } 1424 1425 result = rpccli_lsa_OpenAccount(cli, mem_ctx,1556 if (!NT_STATUS_IS_OK(status)) { 1557 goto done; 1558 } 1559 1560 status = dcerpc_lsa_OpenAccount(b, mem_ctx, 1426 1561 &dom_pol, 1427 1562 &sid, 1428 1563 SEC_FLAG_MAXIMUM_ALLOWED, 1429 &user_pol); 1430 1431 if (!NT_STATUS_IS_OK(result)) { 1564 &user_pol, 1565 &result); 1566 if (!NT_STATUS_IS_OK(status)) { 1567 goto done; 1568 } 1569 if (!NT_STATUS_IS_OK(result)) { 1570 status = result; 1432 1571 goto done; 1433 1572 } … … 1440 1579 init_lsa_String(&priv_name, argv[i]); 1441 1580 1442 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,1581 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx, 1443 1582 &dom_pol, 1444 1583 &priv_name, 1445 &luid); 1584 &luid, 1585 &result); 1586 if (!NT_STATUS_IS_OK(status)) { 1587 continue; 1588 } 1446 1589 if (!NT_STATUS_IS_OK(result)) { 1590 status = result; 1447 1591 continue; 1448 1592 } … … 1463 1607 1464 1608 1465 result = rpccli_lsa_RemovePrivilegesFromAccount(cli, mem_ctx,1609 status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx, 1466 1610 &user_pol, 1467 1611 false, 1468 &privs); 1469 1470 if (!NT_STATUS_IS_OK(result)) { 1471 goto done; 1472 } 1473 1474 rpccli_lsa_Close(cli, mem_ctx, &user_pol); 1475 rpccli_lsa_Close(cli, mem_ctx, &dom_pol); 1476 done: 1477 return result; 1612 &privs, 1613 &result); 1614 if (!NT_STATUS_IS_OK(status)) { 1615 goto done; 1616 } 1617 if (!NT_STATUS_IS_OK(result)) { 1618 status = result; 1619 goto done; 1620 } 1621 1622 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result); 1623 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result); 1624 done: 1625 return status; 1478 1626 } 1479 1627 … … 1482 1630 const char **argv) 1483 1631 { 1484 NTSTATUS status ;1632 NTSTATUS status, result; 1485 1633 struct policy_handle handle, sec_handle; 1486 1634 struct lsa_String name; 1635 struct dcerpc_binding_handle *b = cli->binding_handle; 1487 1636 1488 1637 if (argc < 2) { … … 1501 1650 init_lsa_String(&name, argv[1]); 1502 1651 1503 status = rpccli_lsa_CreateSecret(cli, mem_ctx,1652 status = dcerpc_lsa_CreateSecret(b, mem_ctx, 1504 1653 &handle, 1505 1654 name, 1506 1655 SEC_FLAG_MAXIMUM_ALLOWED, 1507 &sec_handle); 1508 if (!NT_STATUS_IS_OK(status)) { 1656 &sec_handle, 1657 &result); 1658 if (!NT_STATUS_IS_OK(status)) { 1659 goto done; 1660 } 1661 if (!NT_STATUS_IS_OK(result)) { 1662 status = result; 1509 1663 goto done; 1510 1664 } … … 1512 1666 done: 1513 1667 if (is_valid_policy_hnd(&sec_handle)) { 1514 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1668 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1515 1669 } 1516 1670 if (is_valid_policy_hnd(&handle)) { 1517 rpccli_lsa_Close(cli, mem_ctx, &handle);1671 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1518 1672 } 1519 1673 … … 1525 1679 const char **argv) 1526 1680 { 1527 NTSTATUS status ;1681 NTSTATUS status, result; 1528 1682 struct policy_handle handle, sec_handle; 1529 1683 struct lsa_String name; 1684 struct dcerpc_binding_handle *b = cli->binding_handle; 1530 1685 1531 1686 if (argc < 2) { … … 1544 1699 init_lsa_String(&name, argv[1]); 1545 1700 1546 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1701 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1547 1702 &handle, 1548 1703 name, 1549 1704 SEC_FLAG_MAXIMUM_ALLOWED, 1550 &sec_handle); 1551 if (!NT_STATUS_IS_OK(status)) { 1552 goto done; 1553 } 1554 1555 status = rpccli_lsa_DeleteObject(cli, mem_ctx, 1556 &sec_handle); 1557 if (!NT_STATUS_IS_OK(status)) { 1705 &sec_handle, 1706 &result); 1707 if (!NT_STATUS_IS_OK(status)) { 1708 goto done; 1709 } 1710 if (!NT_STATUS_IS_OK(result)) { 1711 status = result; 1712 goto done; 1713 } 1714 1715 status = dcerpc_lsa_DeleteObject(b, mem_ctx, 1716 &sec_handle, 1717 &result); 1718 if (!NT_STATUS_IS_OK(status)) { 1719 goto done; 1720 } 1721 if (!NT_STATUS_IS_OK(result)) { 1722 status = result; 1558 1723 goto done; 1559 1724 } … … 1561 1726 done: 1562 1727 if (is_valid_policy_hnd(&sec_handle)) { 1563 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1728 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1564 1729 } 1565 1730 if (is_valid_policy_hnd(&handle)) { 1566 rpccli_lsa_Close(cli, mem_ctx, &handle);1731 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1567 1732 } 1568 1733 … … 1574 1739 const char **argv) 1575 1740 { 1576 NTSTATUS status ;1741 NTSTATUS status, result; 1577 1742 struct policy_handle handle, sec_handle; 1578 1743 struct lsa_String name; … … 1585 1750 DATA_BLOB old_blob = data_blob_null; 1586 1751 char *new_secret, *old_secret; 1752 struct dcerpc_binding_handle *b = cli->binding_handle; 1587 1753 1588 1754 if (argc < 2) { … … 1601 1767 init_lsa_String(&name, argv[1]); 1602 1768 1603 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1769 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1604 1770 &handle, 1605 1771 name, 1606 1772 SEC_FLAG_MAXIMUM_ALLOWED, 1607 &sec_handle); 1608 if (!NT_STATUS_IS_OK(status)) { 1773 &sec_handle, 1774 &result); 1775 if (!NT_STATUS_IS_OK(status)) { 1776 goto done; 1777 } 1778 if (!NT_STATUS_IS_OK(result)) { 1779 status = result; 1609 1780 goto done; 1610 1781 } … … 1613 1784 ZERO_STRUCT(old_val); 1614 1785 1615 status = rpccli_lsa_QuerySecret(cli, mem_ctx,1786 status = dcerpc_lsa_QuerySecret(b, mem_ctx, 1616 1787 &sec_handle, 1617 1788 &new_val, 1618 1789 &new_mtime, 1619 1790 &old_val, 1620 &old_mtime); 1621 if (!NT_STATUS_IS_OK(status)) { 1791 &old_mtime, 1792 &result); 1793 if (!NT_STATUS_IS_OK(status)) { 1794 goto done; 1795 } 1796 if (!NT_STATUS_IS_OK(result)) { 1797 status = result; 1622 1798 goto done; 1623 1799 } … … 1646 1822 done: 1647 1823 if (is_valid_policy_hnd(&sec_handle)) { 1648 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1824 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1649 1825 } 1650 1826 if (is_valid_policy_hnd(&handle)) { 1651 rpccli_lsa_Close(cli, mem_ctx, &handle);1827 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1652 1828 } 1653 1829 … … 1659 1835 const char **argv) 1660 1836 { 1661 NTSTATUS status ;1837 NTSTATUS status, result; 1662 1838 struct policy_handle handle, sec_handle; 1663 1839 struct lsa_String name; … … 1666 1842 DATA_BLOB enc_key; 1667 1843 DATA_BLOB session_key; 1844 struct dcerpc_binding_handle *b = cli->binding_handle; 1668 1845 1669 1846 if (argc < 3) { … … 1682 1859 init_lsa_String(&name, argv[1]); 1683 1860 1684 status = rpccli_lsa_OpenSecret(cli, mem_ctx,1861 status = dcerpc_lsa_OpenSecret(b, mem_ctx, 1685 1862 &handle, 1686 1863 name, 1687 1864 SEC_FLAG_MAXIMUM_ALLOWED, 1688 &sec_handle); 1689 if (!NT_STATUS_IS_OK(status)) { 1865 &sec_handle, 1866 &result); 1867 if (!NT_STATUS_IS_OK(status)) { 1868 goto done; 1869 } 1870 if (!NT_STATUS_IS_OK(result)) { 1871 status = result; 1690 1872 goto done; 1691 1873 } … … 1705 1887 new_val.data = enc_key.data; 1706 1888 1707 status = rpccli_lsa_SetSecret(cli, mem_ctx,1889 status = dcerpc_lsa_SetSecret(b, mem_ctx, 1708 1890 &sec_handle, 1709 1891 &new_val, 1710 NULL); 1711 if (!NT_STATUS_IS_OK(status)) { 1892 NULL, 1893 &result); 1894 if (!NT_STATUS_IS_OK(status)) { 1895 goto done; 1896 } 1897 if (!NT_STATUS_IS_OK(result)) { 1898 status = result; 1712 1899 goto done; 1713 1900 } … … 1715 1902 done: 1716 1903 if (is_valid_policy_hnd(&sec_handle)) { 1717 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);1904 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result); 1718 1905 } 1719 1906 if (is_valid_policy_hnd(&handle)) { 1720 rpccli_lsa_Close(cli, mem_ctx, &handle);1907 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1721 1908 } 1722 1909 … … 1728 1915 const char **argv) 1729 1916 { 1730 NTSTATUS status ;1917 NTSTATUS status, result; 1731 1918 struct policy_handle handle; 1732 1919 struct lsa_String name; … … 1735 1922 DATA_BLOB blob = data_blob_null; 1736 1923 char *secret; 1924 struct dcerpc_binding_handle *b = cli->binding_handle; 1737 1925 1738 1926 if (argc < 2) { … … 1753 1941 ZERO_STRUCT(val); 1754 1942 1755 status = rpccli_lsa_RetrievePrivateData(cli, mem_ctx,1943 status = dcerpc_lsa_RetrievePrivateData(b, mem_ctx, 1756 1944 &handle, 1757 1945 &name, 1758 &val); 1759 if (!NT_STATUS_IS_OK(status)) { 1946 &val, 1947 &result); 1948 if (!NT_STATUS_IS_OK(status)) { 1949 goto done; 1950 } 1951 if (!NT_STATUS_IS_OK(result)) { 1952 status = result; 1760 1953 goto done; 1761 1954 } … … 1777 1970 done: 1778 1971 if (is_valid_policy_hnd(&handle)) { 1779 rpccli_lsa_Close(cli, mem_ctx, &handle);1972 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1780 1973 } 1781 1974 … … 1787 1980 const char **argv) 1788 1981 { 1789 NTSTATUS status ;1982 NTSTATUS status, result; 1790 1983 struct policy_handle handle; 1791 1984 struct lsa_String name; … … 1793 1986 DATA_BLOB session_key; 1794 1987 DATA_BLOB enc_key; 1988 struct dcerpc_binding_handle *b = cli->binding_handle; 1795 1989 1796 1990 if (argc < 3) { … … 1822 2016 val.data = enc_key.data; 1823 2017 1824 status = rpccli_lsa_StorePrivateData(cli, mem_ctx,2018 status = dcerpc_lsa_StorePrivateData(b, mem_ctx, 1825 2019 &handle, 1826 2020 &name, 1827 &val); 1828 if (!NT_STATUS_IS_OK(status)) { 2021 &val, 2022 &result); 2023 if (!NT_STATUS_IS_OK(status)) { 2024 goto done; 2025 } 2026 if (!NT_STATUS_IS_OK(result)) { 2027 status = result; 1829 2028 goto done; 1830 2029 } … … 1832 2031 done: 1833 2032 if (is_valid_policy_hnd(&handle)) { 1834 rpccli_lsa_Close(cli, mem_ctx, &handle);2033 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1835 2034 } 1836 2035 … … 1842 2041 const char **argv) 1843 2042 { 1844 NTSTATUS status ;2043 NTSTATUS status, result; 1845 2044 struct policy_handle handle, trustdom_handle; 2045 struct dom_sid sid; 1846 2046 struct lsa_DomainInfo info; 2047 struct dcerpc_binding_handle *b = cli->binding_handle; 1847 2048 1848 2049 if (argc < 3) { … … 1860 2061 1861 2062 init_lsa_StringLarge(&info.name, argv[1]); 1862 info.sid = string_sid_talloc(mem_ctx, argv[2]); 1863 1864 status = rpccli_lsa_CreateTrustedDomain(cli, mem_ctx, 2063 info.sid = &sid; 2064 string_to_sid(&sid, argv[2]); 2065 2066 status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx, 1865 2067 &handle, 1866 2068 &info, 1867 2069 SEC_FLAG_MAXIMUM_ALLOWED, 1868 &trustdom_handle); 1869 if (!NT_STATUS_IS_OK(status)) { 2070 &trustdom_handle, 2071 &result); 2072 if (!NT_STATUS_IS_OK(status)) { 2073 goto done; 2074 } 2075 if (!NT_STATUS_IS_OK(result)) { 2076 status = result; 1870 2077 goto done; 1871 2078 } … … 1873 2080 done: 1874 2081 if (is_valid_policy_hnd(&trustdom_handle)) { 1875 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);2082 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result); 1876 2083 } 1877 2084 1878 2085 if (is_valid_policy_hnd(&handle)) { 1879 rpccli_lsa_Close(cli, mem_ctx, &handle);2086 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1880 2087 } 1881 2088 … … 1887 2094 const char **argv) 1888 2095 { 1889 NTSTATUS status ;2096 NTSTATUS status, result; 1890 2097 struct policy_handle handle, trustdom_handle; 1891 2098 struct lsa_String name; 1892 2099 struct dom_sid *sid = NULL; 2100 struct dcerpc_binding_handle *b = cli->binding_handle; 1893 2101 1894 2102 if (argc < 2) { … … 1907 2115 init_lsa_String(&name, argv[1]); 1908 2116 1909 status = rpccli_lsa_OpenTrustedDomainByName(cli, mem_ctx,2117 status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx, 1910 2118 &handle, 1911 2119 name, 1912 2120 SEC_FLAG_MAXIMUM_ALLOWED, 1913 &trustdom_handle); 1914 if (NT_STATUS_IS_OK(status)) { 2121 &trustdom_handle, 2122 &result); 2123 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) { 1915 2124 goto delete_object; 1916 2125 } … … 1921 2130 int i; 1922 2131 1923 status = rpccli_lsa_EnumTrustDom(cli, mem_ctx,2132 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx, 1924 2133 &handle, 1925 2134 &resume_handle, 1926 2135 &domains, 1927 0xffff); 2136 0xffff, 2137 &result); 1928 2138 if (!NT_STATUS_IS_OK(status)) { 2139 goto done; 2140 } 2141 if (!NT_STATUS_IS_OK(result)) { 2142 status = result; 1929 2143 goto done; 1930 2144 } … … 1942 2156 } 1943 2157 1944 status = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,2158 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx, 1945 2159 &handle, 1946 2160 sid, 1947 2161 SEC_FLAG_MAXIMUM_ALLOWED, 1948 &trustdom_handle); 1949 if (!NT_STATUS_IS_OK(status)) { 2162 &trustdom_handle, 2163 &result); 2164 if (!NT_STATUS_IS_OK(status)) { 2165 goto done; 2166 } 2167 if (!NT_STATUS_IS_OK(result)) { 2168 status = result; 1950 2169 goto done; 1951 2170 } 1952 2171 1953 2172 delete_object: 1954 status = rpccli_lsa_DeleteObject(cli, mem_ctx, 1955 &trustdom_handle); 1956 if (!NT_STATUS_IS_OK(status)) { 2173 status = dcerpc_lsa_DeleteObject(b, mem_ctx, 2174 &trustdom_handle, 2175 &result); 2176 if (!NT_STATUS_IS_OK(status)) { 2177 goto done; 2178 } 2179 if (!NT_STATUS_IS_OK(result)) { 2180 status = result; 1957 2181 goto done; 1958 2182 } … … 1960 2184 done: 1961 2185 if (is_valid_policy_hnd(&trustdom_handle)) { 1962 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);2186 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result); 1963 2187 } 1964 2188 1965 2189 if (is_valid_policy_hnd(&handle)) { 1966 rpccli_lsa_Close(cli, mem_ctx, &handle);2190 dcerpc_lsa_Close(b, mem_ctx, &handle, &result); 1967 2191 } 1968 2192 -
vendor/current/source3/rpcclient/cmd_netlogon.c
r414 r740 23 23 #include "rpcclient.h" 24 24 #include "../libcli/auth/libcli_auth.h" 25 #include "../librpc/gen_ndr/cli_netlogon.h" 25 #include "../librpc/gen_ndr/ndr_netlogon.h" 26 #include "../librpc/gen_ndr/ndr_netlogon_c.h" 27 #include "rpc_client/cli_netlogon.h" 28 #include "secrets.h" 26 29 27 30 static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, … … 37 40 union netr_CONTROL_QUERY_INFORMATION query; 38 41 const char *domain = lp_workgroup(); 42 struct dcerpc_binding_handle *b = cli->binding_handle; 39 43 40 44 if (argc > 5) { … … 69 73 } 70 74 71 status = rpccli_netr_LogonControl2(cli, mem_ctx,75 status = dcerpc_netr_LogonControl2(b, mem_ctx, 72 76 logon_server, 73 77 function_code, … … 97 101 NTSTATUS status; 98 102 int old_timeout; 103 struct dcerpc_binding_handle *b = cli->binding_handle; 99 104 100 105 if (argc != 2) { … … 107 112 rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */ 108 113 109 status = rpccli_netr_GetAnyDCName(cli, mem_ctx,114 status = dcerpc_netr_GetAnyDCName(b, mem_ctx, 110 115 cli->desthost, 111 116 argv[1], … … 137 142 WERROR werr; 138 143 int old_timeout; 144 struct dcerpc_binding_handle *b = cli->binding_handle; 139 145 140 146 if (argc != 2) { … … 147 153 rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */ 148 154 149 status = rpccli_netr_GetDcName(cli, mem_ctx,155 status = dcerpc_netr_GetDcName(b, mem_ctx, 150 156 cli->desthost, 151 157 argv[1], … … 181 187 struct GUID site_guid = GUID_zero(); 182 188 struct netr_DsRGetDCNameInfo *info = NULL; 189 struct dcerpc_binding_handle *b = cli->binding_handle; 183 190 184 191 if (argc < 2) { … … 208 215 debug_dsdcinfo_flags(1,flags); 209 216 210 result = rpccli_netr_DsRGetDCName(cli, mem_ctx,217 result = dcerpc_netr_DsRGetDCName(b, mem_ctx, 211 218 server_name, 212 219 domain_name, … … 216 223 &info, 217 224 &werr); 225 if (!NT_STATUS_IS_OK(result)) { 226 return ntstatus_to_werror(result); 227 } 218 228 219 229 if (W_ERROR_IS_OK(werr)) { … … 241 251 struct GUID domain_guid = GUID_zero(); 242 252 struct netr_DsRGetDCNameInfo *info = NULL; 253 struct dcerpc_binding_handle *b = cli->binding_handle; 243 254 244 255 if (argc < 2) { … … 266 277 debug_dsdcinfo_flags(1,flags); 267 278 268 status = rpccli_netr_DsRGetDCNameEx(cli, mem_ctx,279 status = dcerpc_netr_DsRGetDCNameEx(b, mem_ctx, 269 280 server_name, 270 281 domain_name, … … 302 313 struct GUID domain_guid = GUID_zero(); 303 314 struct netr_DsRGetDCNameInfo *info = NULL; 315 struct dcerpc_binding_handle *b = cli->binding_handle; 304 316 305 317 if (argc < 2) { … … 338 350 debug_dsdcinfo_flags(1,flags); 339 351 340 status = rpccli_netr_DsRGetDCNameEx2(cli, mem_ctx,352 status = dcerpc_netr_DsRGetDCNameEx2(b, mem_ctx, 341 353 server_name, 342 354 client_account, … … 370 382 NTSTATUS status; 371 383 const char *sitename = NULL; 384 struct dcerpc_binding_handle *b = cli->binding_handle; 372 385 373 386 if (argc != 2) { … … 376 389 } 377 390 378 status = rpccli_netr_DsRGetSiteName(cli, mem_ctx,391 status = dcerpc_netr_DsRGetSiteName(b, mem_ctx, 379 392 argv[1], 380 393 &sitename, … … 405 418 uint32_t level = 1; 406 419 union netr_CONTROL_QUERY_INFORMATION info; 420 struct dcerpc_binding_handle *b = cli->binding_handle; 407 421 408 422 if (argc > 4) { … … 424 438 } 425 439 426 status = rpccli_netr_LogonControl(cli, mem_ctx,440 status = dcerpc_netr_LogonControl(b, mem_ctx, 427 441 logon_server, 428 442 function_code, … … 465 479 case NETR_DELTA_DELETE_GROUP: 466 480 printf("Delete Group: %d\n", 467 u.delete_account.unknown);481 id.rid); 468 482 break; 469 483 case NETR_DELTA_RENAME_GROUP: … … 498 512 case NETR_DELTA_DELETE_ALIAS: 499 513 printf("Delete Alias: %d\n", 500 r->delta_enum[i].delta_id_union.rid);514 id.rid); 501 515 break; 502 516 case NETR_DELTA_RENAME_ALIAS: … … 514 528 break; 515 529 case NETR_DELTA_POLICY: 516 printf("Policy\n"); 530 printf("Policy: %s\n", 531 sid_string_dbg(id.sid)); 517 532 break; 518 533 case NETR_DELTA_TRUSTED_DOMAIN: … … 521 536 break; 522 537 case NETR_DELTA_DELETE_TRUST: 523 printf("Delete Trust: % d\n",524 u.delete_trust.unknown);538 printf("Delete Trust: %s\n", 539 sid_string_dbg(id.sid)); 525 540 break; 526 541 case NETR_DELTA_ACCOUNT: 527 printf("Account\n"); 542 printf("Account: %s\n", 543 sid_string_dbg(id.sid)); 528 544 break; 529 545 case NETR_DELTA_DELETE_ACCOUNT: 530 printf("Delete Account: % d\n",531 u.delete_account.unknown);546 printf("Delete Account: %s\n", 547 sid_string_dbg(id.sid)); 532 548 break; 533 549 case NETR_DELTA_SECRET: 534 printf("Secret\n"); 550 printf("Secret: %s\n", 551 id.name); 535 552 break; 536 553 case NETR_DELTA_DELETE_SECRET: 537 printf("Delete Secret: % d\n",538 u.delete_secret.unknown);554 printf("Delete Secret: %s\n", 555 id.name); 539 556 break; 540 557 case NETR_DELTA_DELETE_GROUP2: … … 565 582 { 566 583 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 584 NTSTATUS status; 567 585 const char *logon_server = cli->desthost; 568 586 const char *computername = global_myname(); … … 572 590 uint16_t restart_state = 0; 573 591 uint32_t sync_context = 0; 592 struct dcerpc_binding_handle *b = cli->binding_handle; 574 593 575 594 if (argc > 2) { … … 589 608 netlogon_creds_client_authenticator(cli->dc, &credential); 590 609 591 result = rpccli_netr_DatabaseSync2(cli, mem_ctx,610 status = dcerpc_netr_DatabaseSync2(b, mem_ctx, 592 611 logon_server, 593 612 computername, … … 598 617 &sync_context, 599 618 &delta_enum_array, 600 0xffff); 619 0xffff, 620 &result); 621 if (!NT_STATUS_IS_OK(status)) { 622 return status; 623 } 601 624 602 625 /* Check returned credentials. */ … … 629 652 { 630 653 NTSTATUS result = NT_STATUS_UNSUCCESSFUL; 654 NTSTATUS status; 631 655 uint32_t tmp; 632 656 const char *logon_server = cli->desthost; … … 636 660 enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; 637 661 uint64_t sequence_num; 662 struct dcerpc_binding_handle *b = cli->binding_handle; 638 663 639 664 if (argc != 3) { … … 652 677 netlogon_creds_client_authenticator(cli->dc, &credential); 653 678 654 result = rpccli_netr_DatabaseDeltas(cli, mem_ctx,679 status = dcerpc_netr_DatabaseDeltas(b, mem_ctx, 655 680 logon_server, 656 681 computername, … … 660 685 &sequence_num, 661 686 &delta_enum_array, 662 0xffff); 687 0xffff, 688 &result); 689 if (!NT_STATUS_IS_OK(status)) { 690 return status; 691 } 663 692 664 693 /* Check returned credentials. */ … … 693 722 int logon_type = NetlogonNetworkInformation; 694 723 const char *username, *password; 695 int auth_level = 2;724 uint16_t validation_level = 3; 696 725 uint32 logon_param = 0; 697 726 const char *workstation = NULL; … … 715 744 716 745 if (argc >= 6) 717 sscanf(argv[5], "%i", &auth_level);746 validation_level = atoi(argv[5]); 718 747 719 748 if (argc == 7) … … 722 751 /* Perform the sam logon */ 723 752 724 result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, workstation, logon_type);753 result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, workstation, validation_level, logon_type); 725 754 726 755 if (!NT_STATUS_IS_OK(result)) … … 767 796 const char *domain_name = lp_workgroup(); 768 797 uint32_t rid = 0; 798 struct dcerpc_binding_handle *b = cli->binding_handle; 769 799 770 800 if (argc < 1 || argc > 3) { … … 782 812 } 783 813 784 status = rpccli_netr_LogonGetTrustRid(cli, mem_ctx,814 status = dcerpc_netr_LogonGetTrustRid(b, mem_ctx, 785 815 server_name, 786 816 domain_name, … … 788 818 &werr); 789 819 if (!NT_STATUS_IS_OK(status)) { 820 werr = ntstatus_to_werror(status); 790 821 goto done; 791 822 } … … 807 838 uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST; 808 839 struct netr_DomainTrustList trusts; 840 struct dcerpc_binding_handle *b = cli->binding_handle; 809 841 810 842 if (argc < 1 || argc > 3) { … … 822 854 } 823 855 824 status = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,856 status = dcerpc_netr_DsrEnumerateDomainTrusts(b, mem_ctx, 825 857 server_name, 826 858 trust_flags, … … 828 860 &werr); 829 861 if (!NT_STATUS_IS_OK(status)) { 862 werr = ntstatus_to_werror(status); 830 863 goto done; 831 864 } … … 855 888 const char *domain = lp_workgroup(); 856 889 const char *dns_host = NULL; 890 struct dcerpc_binding_handle *b = cli->binding_handle; 857 891 858 892 if (argc < 1 || argc > 4) { … … 874 908 } 875 909 876 status = rpccli_netr_DsrDeregisterDNSHostRecords(cli, mem_ctx,910 status = dcerpc_netr_DsrDeregisterDNSHostRecords(b, mem_ctx, 877 911 server_name, 878 912 domain, … … 882 916 &werr); 883 917 if (!NT_STATUS_IS_OK(status)) { 918 werr = ntstatus_to_werror(status); 884 919 goto done; 885 920 } … … 902 937 struct lsa_ForestTrustInformation *info = NULL; 903 938 uint32_t flags = 0; 939 struct dcerpc_binding_handle *b = cli->binding_handle; 904 940 905 941 if (argc < 1 || argc > 4) { … … 921 957 } 922 958 923 status = rpccli_netr_DsRGetForestTrustInformation(cli, mem_ctx,959 status = dcerpc_netr_DsRGetForestTrustInformation(b, mem_ctx, 924 960 server_name, 925 961 trusted_domain_name, … … 928 964 &werr); 929 965 if (!NT_STATUS_IS_OK(status)) { 966 werr = ntstatus_to_werror(status); 930 967 goto done; 931 968 } … … 938 975 } 939 976 940 static WERRORcmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,941 942 977 static NTSTATUS cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli, 978 TALLOC_CTX *mem_ctx, int argc, 979 const char **argv) 943 980 { 944 981 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 945 WERROR werr = WERR_GENERAL_FAILURE;982 NTSTATUS result; 946 983 const char *server_name = cli->desthost; 947 984 struct netr_Blob blob; 985 struct dcerpc_binding_handle *b = cli->binding_handle; 948 986 949 987 950 988 if (argc < 1 || argc > 3) { 951 989 fprintf(stderr, "Usage: %s <server_name>\n", argv[0]); 952 return WERR_OK;990 return NT_STATUS_OK; 953 991 } 954 992 … … 957 995 } 958 996 959 status = rpccli_netr_NetrEnumerateTrustedDomains(cli, mem_ctx,997 status = dcerpc_netr_NetrEnumerateTrustedDomains(b, mem_ctx, 960 998 server_name, 961 999 &blob, 962 & werr);1000 &result); 963 1001 if (!NT_STATUS_IS_OK(status)) { 964 1002 goto done; 965 1003 } 966 1004 967 if (W_ERROR_IS_OK(werr)) { 968 printf("success\n"); 969 dump_data(1, blob.data, blob.length); 970 } 1005 if (!NT_STATUS_IS_OK(result)) { 1006 status = result; 1007 goto done; 1008 } 1009 1010 printf("success\n"); 1011 dump_data(1, blob.data, blob.length); 971 1012 done: 972 return werr;1013 return status; 973 1014 } 974 1015 … … 981 1022 const char *server_name = cli->desthost; 982 1023 struct netr_DomainTrustList list; 1024 struct dcerpc_binding_handle *b = cli->binding_handle; 983 1025 984 1026 if (argc < 1 || argc > 3) { … … 991 1033 } 992 1034 993 status = rpccli_netr_NetrEnumerateTrustedDomainsEx(cli, mem_ctx,1035 status = dcerpc_netr_NetrEnumerateTrustedDomainsEx(b, mem_ctx, 994 1036 server_name, 995 1037 &list, 996 1038 &werr); 997 1039 if (!NT_STATUS_IS_OK(status)) { 1040 werr = ntstatus_to_werror(status); 998 1041 goto done; 999 1042 } … … 1014 1057 const char *server_name = cli->desthost; 1015 1058 struct DcSitesCtr *ctr = NULL; 1059 struct dcerpc_binding_handle *b = cli->binding_handle; 1016 1060 1017 1061 if (argc < 1 || argc > 3) { … … 1024 1068 } 1025 1069 1026 status = rpccli_netr_DsrGetDcSiteCoverageW(cli, mem_ctx,1070 status = dcerpc_netr_DsrGetDcSiteCoverageW(b, mem_ctx, 1027 1071 server_name, 1028 1072 &ctr, 1029 1073 &werr); 1030 1074 if (!NT_STATUS_IS_OK(status)) { 1075 werr = ntstatus_to_werror(status); 1031 1076 goto done; 1032 1077 } … … 1048 1093 { 1049 1094 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 1095 NTSTATUS result; 1050 1096 const char *server_name = cli->desthost; 1051 1097 uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS; … … 1056 1102 struct netr_ChangeLogEntry e; 1057 1103 uint32_t rid = 500; 1104 struct dcerpc_binding_handle *b = cli->binding_handle; 1058 1105 1059 1106 if (argc > 2) { … … 1093 1140 e.delta_type = NETR_DELTA_USER; 1094 1141 1095 status = rpccli_netr_DatabaseRedo(cli, mem_ctx,1142 status = dcerpc_netr_DatabaseRedo(b, mem_ctx, 1096 1143 server_name, 1097 1144 global_myname(), … … 1100 1147 e, 1101 1148 0, /* is calculated automatically */ 1102 &delta_enum_array); 1149 &delta_enum_array, 1150 &result); 1151 if (!NT_STATUS_IS_OK(status)) { 1152 return status; 1153 } 1103 1154 1104 1155 if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) { … … 1107 1158 } 1108 1159 1109 return status;1160 return result; 1110 1161 } 1111 1162 … … 1115 1166 { 1116 1167 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 1168 NTSTATUS result; 1117 1169 struct netr_Authenticator credential; 1118 1170 struct netr_Authenticator return_authenticator; 1119 1171 union netr_Capabilities capabilities; 1120 1172 uint32_t level = 1; 1173 struct dcerpc_binding_handle *b = cli->binding_handle; 1121 1174 1122 1175 if (argc > 2) { … … 1133 1186 netlogon_creds_client_authenticator(cli->dc, &credential); 1134 1187 1135 status = rpccli_netr_LogonGetCapabilities(cli, mem_ctx,1188 status = dcerpc_netr_LogonGetCapabilities(b, mem_ctx, 1136 1189 cli->desthost, 1137 1190 global_myname(), … … 1139 1192 &return_authenticator, 1140 1193 level, 1141 &capabilities); 1194 &capabilities, 1195 &result); 1196 if (!NT_STATUS_IS_OK(status)) { 1197 return status; 1198 } 1142 1199 1143 1200 if (!netlogon_creds_client_check(cli->dc, … … 1149 1206 printf("capabilities: 0x%08x\n", capabilities.server_capabilities); 1150 1207 1151 return status;1208 return result; 1152 1209 } 1153 1210 … … 1175 1232 { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, &ndr_table_netlogon.syntax_id, NULL, "Enumerate all trusted domains in an AD forest", "" }, 1176 1233 { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, &ndr_table_netlogon.syntax_id, NULL, "Deregister DNS records", "" }, 1177 { "netrenumtrusteddomains", RPC_RTYPE_ WERROR, NULL, cmd_netlogon_enumtrusteddomains, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" },1234 { "netrenumtrusteddomains", RPC_RTYPE_NTSTATUS, cmd_netlogon_enumtrusteddomains, NULL, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" }, 1178 1235 { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" }, 1179 1236 { "getdcsitecoverage", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcsitecoverage, &ndr_table_netlogon.syntax_id, NULL, "Get the Site-Coverage from a DC", "" }, -
vendor/current/source3/rpcclient/cmd_ntsvcs.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/ cli_ntsvcs.h"23 #include "../librpc/gen_ndr/ndr_ntsvcs_c.h" 24 24 25 25 static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, … … 28 28 const char **argv) 29 29 { 30 struct dcerpc_binding_handle *b = cli->binding_handle; 30 31 NTSTATUS status; 31 32 WERROR werr; 32 33 uint16_t version; 33 34 34 status = rpccli_PNP_GetVersion(cli, mem_ctx,35 status = dcerpc_PNP_GetVersion(b, mem_ctx, 35 36 &version, &werr); 36 37 if (!NT_STATUS_IS_OK(status)) { … … 50 51 const char **argv) 51 52 { 53 struct dcerpc_binding_handle *b = cli->binding_handle; 52 54 NTSTATUS status; 53 55 WERROR werr; … … 66 68 } 67 69 68 status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx,70 status = dcerpc_PNP_ValidateDeviceInstance(b, mem_ctx, 69 71 devicepath, 70 72 flags, … … 82 84 const char **argv) 83 85 { 86 struct dcerpc_binding_handle *b = cli->binding_handle; 84 87 NTSTATUS status; 85 88 WERROR werr; … … 97 100 devicepath = argv[1]; 98 101 99 status = rpccli_PNP_HwProfFlags(cli, mem_ctx,102 status = dcerpc_PNP_HwProfFlags(b, mem_ctx, 100 103 0, 101 104 devicepath, … … 120 123 const char **argv) 121 124 { 125 struct dcerpc_binding_handle *b = cli->binding_handle; 122 126 NTSTATUS status; 123 127 WERROR werr; … … 128 132 ZERO_STRUCT(info); 129 133 130 status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx,134 status = dcerpc_PNP_GetHwProfInfo(b, mem_ctx, 131 135 idx, 132 136 &info, … … 146 150 const char **argv) 147 151 { 152 struct dcerpc_binding_handle *b = cli->binding_handle; 148 153 NTSTATUS status; 149 154 WERROR werr; … … 171 176 W_ERROR_HAVE_NO_MEMORY(buffer); 172 177 173 status = rpccli_PNP_GetDeviceRegProp(cli, mem_ctx,178 status = dcerpc_PNP_GetDeviceRegProp(b, mem_ctx, 174 179 devicepath, 175 180 property, … … 192 197 const char **argv) 193 198 { 199 struct dcerpc_binding_handle *b = cli->binding_handle; 194 200 NTSTATUS status; 195 201 WERROR werr; … … 211 217 } 212 218 213 status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,219 status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx, 214 220 filter, 215 221 &size, … … 230 236 const char **argv) 231 237 { 238 struct dcerpc_binding_handle *b = cli->binding_handle; 232 239 NTSTATUS status; 233 240 WERROR werr; … … 259 266 } 260 267 261 status = rpccli_PNP_GetDeviceList(cli, mem_ctx,268 status = dcerpc_PNP_GetDeviceList(b, mem_ctx, 262 269 filter, 263 270 buffer, -
vendor/current/source3/rpcclient/cmd_samr.c
r414 r740 26 26 #include "rpcclient.h" 27 27 #include "../libcli/auth/libcli_auth.h" 28 #include "../librpc/gen_ndr/cli_samr.h" 29 30 extern DOM_SID domain_sid; 28 #include "../librpc/gen_ndr/ndr_samr.h" 29 #include "../librpc/gen_ndr/ndr_samr_c.h" 30 #include "rpc_client/cli_samr.h" 31 #include "rpc_client/init_samr.h" 32 #include "rpc_client/init_lsa.h" 33 #include "../libcli/security/security.h" 34 35 extern struct dom_sid domain_sid; 31 36 32 37 /**************************************************************************** … … 277 282 struct policy_handle *domain_pol) 278 283 { 284 struct dcerpc_binding_handle *b = cli->binding_handle; 285 NTSTATUS status = NT_STATUS_INVALID_PARAMETER, result; 279 286 280 287 if (StrCaseCmp(sam, "domain") == 0) { 281 return rpccli_samr_OpenDomain(cli, mem_ctx,288 status = dcerpc_samr_OpenDomain(b, mem_ctx, 282 289 connect_pol, 283 290 access_mask, 284 291 _domain_sid, 285 domain_pol); 292 domain_pol, 293 &result); 286 294 } else if (StrCaseCmp(sam, "builtin") == 0) { 287 return rpccli_samr_OpenDomain(cli, mem_ctx,295 status = dcerpc_samr_OpenDomain(b, mem_ctx, 288 296 connect_pol, 289 297 access_mask, 290 298 CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin), 291 domain_pol); 292 } 293 294 return NT_STATUS_INVALID_PARAMETER; 299 domain_pol, 300 &result); 301 } 302 303 if (!NT_STATUS_IS_OK(status)) { 304 return status; 305 } 306 307 return result; 295 308 } 296 309 … … 303 316 { 304 317 struct policy_handle connect_pol, domain_pol, user_pol; 305 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;318 NTSTATUS status, result; 306 319 uint32 info_level = 21; 307 320 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 308 321 union samr_UserInfo *info = NULL; 309 322 uint32 user_rid = 0; 323 struct dcerpc_binding_handle *b = cli->binding_handle; 310 324 311 325 if ((argc < 2) || (argc > 4)) { … … 323 337 324 338 325 result= rpccli_try_samr_connects(cli, mem_ctx,339 status = rpccli_try_samr_connects(cli, mem_ctx, 326 340 MAXIMUM_ALLOWED_ACCESS, 327 341 &connect_pol); 328 329 if (!NT_STATUS_IS_OK(result))330 goto done;331 332 result = rpccli_samr_OpenDomain(cli, mem_ctx,342 if (!NT_STATUS_IS_OK(status)) { 343 goto done; 344 } 345 346 status = dcerpc_samr_OpenDomain(b, mem_ctx, 333 347 &connect_pol, 334 348 MAXIMUM_ALLOWED_ACCESS, 335 349 &domain_sid, 336 &domain_pol); 337 if (!NT_STATUS_IS_OK(result)) 338 goto done; 339 340 result = rpccli_samr_OpenUser(cli, mem_ctx, 350 &domain_pol, 351 &result); 352 if (!NT_STATUS_IS_OK(status)) { 353 goto done; 354 } 355 if (!NT_STATUS_IS_OK(result)) { 356 status = result; 357 goto done; 358 } 359 360 status = dcerpc_samr_OpenUser(b, mem_ctx, 341 361 &domain_pol, 342 362 access_mask, 343 363 user_rid, 344 &user_pol); 345 364 &user_pol, 365 &result); 366 if (!NT_STATUS_IS_OK(status)) { 367 goto done; 368 } 346 369 if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) && 347 370 (user_rid == 0)) { … … 353 376 init_lsa_String(&lsa_acct_name, argv[1]); 354 377 355 result = rpccli_samr_LookupNames(cli, mem_ctx,378 status = dcerpc_samr_LookupNames(b, mem_ctx, 356 379 &domain_pol, 357 380 1, 358 381 &lsa_acct_name, 359 382 &rids, 360 &types); 361 383 &types, 384 &result); 385 if (!NT_STATUS_IS_OK(status)) { 386 goto done; 387 } 362 388 if (NT_STATUS_IS_OK(result)) { 363 result = rpccli_samr_OpenUser(cli, mem_ctx,389 status = dcerpc_samr_OpenUser(b, mem_ctx, 364 390 &domain_pol, 365 391 access_mask, 366 392 rids.ids[0], 367 &user_pol); 368 } 369 } 370 371 372 if (!NT_STATUS_IS_OK(result)) 373 goto done; 374 375 result = rpccli_samr_QueryUserInfo(cli, mem_ctx, 393 &user_pol, 394 &result); 395 if (!NT_STATUS_IS_OK(status)) { 396 goto done; 397 } 398 } 399 } 400 401 402 if (!NT_STATUS_IS_OK(result)) { 403 status = result; 404 goto done; 405 } 406 407 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 376 408 &user_pol, 377 409 info_level, 378 &info); 379 380 if (!NT_STATUS_IS_OK(result)) 381 goto done; 410 &info, 411 &result); 412 if (!NT_STATUS_IS_OK(status)) { 413 goto done; 414 } 415 if (!NT_STATUS_IS_OK(result)) { 416 status = result; 417 goto done; 418 } 382 419 383 420 switch (info_level) { … … 402 439 } 403 440 404 rpccli_samr_Close(cli, mem_ctx, &user_pol);405 rpccli_samr_Close(cli, mem_ctx, &domain_pol);406 rpccli_samr_Close(cli, mem_ctx, &connect_pol);441 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 442 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 443 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 407 444 408 445 done: 409 return result;446 return status; 410 447 } 411 448 … … 491 528 { 492 529 struct policy_handle connect_pol, domain_pol, group_pol; 493 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;530 NTSTATUS status, result; 494 531 enum samr_GroupInfoEnum info_level = GROUPINFOALL; 495 532 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 496 533 union samr_GroupInfo *group_info = NULL; 497 534 uint32 group_rid; 535 struct dcerpc_binding_handle *b = cli->binding_handle; 498 536 499 537 if ((argc < 2) || (argc > 4)) { … … 510 548 sscanf(argv[3], "%x", &access_mask); 511 549 512 result= rpccli_try_samr_connects(cli, mem_ctx,550 status = rpccli_try_samr_connects(cli, mem_ctx, 513 551 MAXIMUM_ALLOWED_ACCESS, 514 552 &connect_pol); 515 516 if (!NT_STATUS_IS_OK(result))517 goto done;518 519 result = rpccli_samr_OpenDomain(cli, mem_ctx,553 if (!NT_STATUS_IS_OK(status)) { 554 goto done; 555 } 556 557 status = dcerpc_samr_OpenDomain(b, mem_ctx, 520 558 &connect_pol, 521 559 MAXIMUM_ALLOWED_ACCESS, 522 560 &domain_sid, 523 &domain_pol); 524 525 if (!NT_STATUS_IS_OK(result)) 526 goto done; 527 528 result = rpccli_samr_OpenGroup(cli, mem_ctx, 561 &domain_pol, 562 &result); 563 if (!NT_STATUS_IS_OK(status)) { 564 goto done; 565 } 566 if (!NT_STATUS_IS_OK(result)) { 567 status = result; 568 goto done; 569 } 570 571 status = dcerpc_samr_OpenGroup(b, mem_ctx, 529 572 &domain_pol, 530 573 access_mask, 531 574 group_rid, 532 &group_pol); 533 534 if (!NT_STATUS_IS_OK(result)) 535 goto done; 536 537 result = rpccli_samr_QueryGroupInfo(cli, mem_ctx, 575 &group_pol, 576 &result); 577 if (!NT_STATUS_IS_OK(status)) { 578 goto done; 579 } 580 if (!NT_STATUS_IS_OK(result)) { 581 status = result; 582 goto done; 583 } 584 585 status = dcerpc_samr_QueryGroupInfo(b, mem_ctx, 538 586 &group_pol, 539 587 info_level, 540 &group_info); 541 if (!NT_STATUS_IS_OK(result)) { 588 &group_info, 589 &result); 590 if (!NT_STATUS_IS_OK(status)) { 591 goto done; 592 } 593 if (!NT_STATUS_IS_OK(result)) { 594 status = result; 542 595 goto done; 543 596 } … … 545 598 display_group_info(group_info, info_level); 546 599 547 rpccli_samr_Close(cli, mem_ctx, &group_pol);548 rpccli_samr_Close(cli, mem_ctx, &domain_pol);549 rpccli_samr_Close(cli, mem_ctx, &connect_pol);600 dcerpc_samr_Close(b, mem_ctx, &group_pol, &result); 601 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 602 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 550 603 done: 551 return result;604 return status; 552 605 } 553 606 … … 561 614 domain_pol, 562 615 user_pol; 563 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;616 NTSTATUS status, result; 564 617 uint32 user_rid; 565 618 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 566 619 int i; 567 620 struct samr_RidWithAttributeArray *rid_array = NULL; 621 struct dcerpc_binding_handle *b = cli->binding_handle; 568 622 569 623 if ((argc < 2) || (argc > 3)) { … … 577 631 sscanf(argv[2], "%x", &access_mask); 578 632 579 result= rpccli_try_samr_connects(cli, mem_ctx,633 status = rpccli_try_samr_connects(cli, mem_ctx, 580 634 MAXIMUM_ALLOWED_ACCESS, 581 635 &connect_pol); 582 583 if (!NT_STATUS_IS_OK(result))584 goto done;585 586 result = rpccli_samr_OpenDomain(cli, mem_ctx,636 if (!NT_STATUS_IS_OK(status)) { 637 goto done; 638 } 639 640 status = dcerpc_samr_OpenDomain(b, mem_ctx, 587 641 &connect_pol, 588 642 MAXIMUM_ALLOWED_ACCESS, 589 &domain_sid, &domain_pol); 590 591 if (!NT_STATUS_IS_OK(result)) 592 goto done; 593 594 result = rpccli_samr_OpenUser(cli, mem_ctx, 643 &domain_sid, 644 &domain_pol, 645 &result); 646 if (!NT_STATUS_IS_OK(status)) { 647 goto done; 648 } 649 if (!NT_STATUS_IS_OK(result)) { 650 status = result; 651 goto done; 652 } 653 654 status = dcerpc_samr_OpenUser(b, mem_ctx, 595 655 &domain_pol, 596 656 access_mask, 597 657 user_rid, 598 &user_pol); 599 600 if (!NT_STATUS_IS_OK(result)) 601 goto done; 602 603 result = rpccli_samr_GetGroupsForUser(cli, mem_ctx, 658 &user_pol, 659 &result); 660 661 if (!NT_STATUS_IS_OK(status)) { 662 goto done; 663 } 664 if (!NT_STATUS_IS_OK(result)) { 665 status = result; 666 goto done; 667 } 668 669 status = dcerpc_samr_GetGroupsForUser(b, mem_ctx, 604 670 &user_pol, 605 &rid_array); 606 607 if (!NT_STATUS_IS_OK(result)) 608 goto done; 671 &rid_array, 672 &result); 673 if (!NT_STATUS_IS_OK(status)) { 674 goto done; 675 } 676 if (!NT_STATUS_IS_OK(result)) { 677 status = result; 678 goto done; 679 } 609 680 610 681 for (i = 0; i < rid_array->count; i++) { … … 614 685 } 615 686 616 rpccli_samr_Close(cli, mem_ctx, &user_pol);617 rpccli_samr_Close(cli, mem_ctx, &domain_pol);618 rpccli_samr_Close(cli, mem_ctx, &connect_pol);687 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 688 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 689 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 619 690 done: 620 return result;691 return status; 621 692 } 622 693 … … 628 699 { 629 700 struct policy_handle connect_pol, domain_pol; 630 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;631 DOM_SID*sids;632 size_t num_sids;701 NTSTATUS status, result; 702 struct dom_sid *sids; 703 uint32_t num_sids; 633 704 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 634 705 int i; 635 706 struct lsa_SidArray sid_array; 636 707 struct samr_Ids alias_rids; 708 struct dcerpc_binding_handle *b = cli->binding_handle; 637 709 638 710 if (argc < 3) { … … 645 717 646 718 for (i=2; i<argc; i++) { 647 DOM_SIDtmp_sid;719 struct dom_sid tmp_sid; 648 720 if (!string_to_sid(&tmp_sid, argv[i])) { 649 721 printf("%s is not a legal SID\n", argv[i]); … … 665 737 666 738 for (i=0; i<num_sids; i++) { 667 sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);739 sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sids[i]); 668 740 if (!sid_array.sids[i].sid) { 669 741 return NT_STATUS_NO_MEMORY; … … 673 745 sid_array.num_sids = num_sids; 674 746 675 result= rpccli_try_samr_connects(cli, mem_ctx,747 status = rpccli_try_samr_connects(cli, mem_ctx, 676 748 MAXIMUM_ALLOWED_ACCESS, 677 749 &connect_pol); 678 679 if (!NT_STATUS_IS_OK(result))680 goto done;681 682 result= get_domain_handle(cli, mem_ctx, argv[1],750 if (!NT_STATUS_IS_OK(status)) { 751 goto done; 752 } 753 754 status = get_domain_handle(cli, mem_ctx, argv[1], 683 755 &connect_pol, 684 756 access_mask, 685 757 &domain_sid, 686 758 &domain_pol); 687 688 if (!NT_STATUS_IS_OK(result))689 goto done;690 691 result = rpccli_samr_GetAliasMembership(cli, mem_ctx,759 if (!NT_STATUS_IS_OK(status)) { 760 goto done; 761 } 762 763 status = dcerpc_samr_GetAliasMembership(b, mem_ctx, 692 764 &domain_pol, 693 765 &sid_array, 694 &alias_rids); 695 if (!NT_STATUS_IS_OK(result)) 696 goto done; 766 &alias_rids, 767 &result); 768 if (!NT_STATUS_IS_OK(status)) { 769 goto done; 770 } 771 if (!NT_STATUS_IS_OK(result)) { 772 status = result; 773 goto done; 774 } 697 775 698 776 for (i = 0; i < alias_rids.count; i++) { … … 700 778 } 701 779 702 rpccli_samr_Close(cli, mem_ctx, &domain_pol);703 rpccli_samr_Close(cli, mem_ctx, &connect_pol);780 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 781 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 704 782 done: 705 return result;783 return status; 706 784 } 707 785 … … 713 791 { 714 792 struct policy_handle connect_pol, domain_pol, group_pol; 715 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;793 NTSTATUS status, result; 716 794 uint32 group_rid; 717 795 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 718 796 int i; 719 797 unsigned int old_timeout; 720 struct samr_RidTypeArray *rids = NULL; 798 struct samr_RidAttrArray *rids = NULL; 799 struct dcerpc_binding_handle *b = cli->binding_handle; 721 800 722 801 if ((argc < 2) || (argc > 3)) { … … 730 809 sscanf(argv[2], "%x", &access_mask); 731 810 732 result= rpccli_try_samr_connects(cli, mem_ctx,811 status = rpccli_try_samr_connects(cli, mem_ctx, 733 812 MAXIMUM_ALLOWED_ACCESS, 734 813 &connect_pol); 735 736 if (!NT_STATUS_IS_OK(result))737 goto done;738 739 result = rpccli_samr_OpenDomain(cli, mem_ctx,814 if (!NT_STATUS_IS_OK(status)) { 815 goto done; 816 } 817 818 status = dcerpc_samr_OpenDomain(b, mem_ctx, 740 819 &connect_pol, 741 820 MAXIMUM_ALLOWED_ACCESS, 742 821 &domain_sid, 743 &domain_pol); 744 745 if (!NT_STATUS_IS_OK(result)) 746 goto done; 747 748 result = rpccli_samr_OpenGroup(cli, mem_ctx, 822 &domain_pol, 823 &result); 824 if (!NT_STATUS_IS_OK(status)) { 825 goto done; 826 } 827 if (!NT_STATUS_IS_OK(result)) { 828 status = result; 829 goto done; 830 } 831 832 status = dcerpc_samr_OpenGroup(b, mem_ctx, 749 833 &domain_pol, 750 834 access_mask, 751 835 group_rid, 752 &group_pol); 753 754 if (!NT_STATUS_IS_OK(result)) 755 goto done; 836 &group_pol, 837 &result); 838 if (!NT_STATUS_IS_OK(status)) { 839 goto done; 840 } 841 if (!NT_STATUS_IS_OK(result)) { 842 status = result; 843 goto done; 844 } 756 845 757 846 /* Make sure to wait for our DC's reply */ … … 759 848 rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */ 760 849 761 result = rpccli_samr_QueryGroupMember(cli, mem_ctx,850 status = dcerpc_samr_QueryGroupMember(b, mem_ctx, 762 851 &group_pol, 763 &rids); 852 &rids, 853 &result); 764 854 765 855 rpccli_set_timeout(cli, old_timeout); 766 856 767 if (!NT_STATUS_IS_OK(result)) 768 goto done; 857 if (!NT_STATUS_IS_OK(status)) { 858 goto done; 859 } 860 if (!NT_STATUS_IS_OK(result)) { 861 status = result; 862 goto done; 863 } 769 864 770 865 for (i = 0; i < rids->count; i++) { 771 866 printf("\trid:[0x%x] attr:[0x%x]\n", rids->rids[i], 772 rids-> types[i]);773 } 774 775 rpccli_samr_Close(cli, mem_ctx, &group_pol);776 rpccli_samr_Close(cli, mem_ctx, &domain_pol);777 rpccli_samr_Close(cli, mem_ctx, &connect_pol);867 rids->attributes[i]); 868 } 869 870 dcerpc_samr_Close(b, mem_ctx, &group_pol, &result); 871 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 872 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 778 873 done: 779 return result;874 return status; 780 875 } 781 876 … … 787 882 { 788 883 struct policy_handle connect_pol, domain_pol; 789 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;884 NTSTATUS status, result; 790 885 uint32 start_idx, num_dom_users, i; 791 886 struct samr_SamArray *dom_users = NULL; … … 793 888 uint32 acb_mask = ACB_NORMAL; 794 889 uint32_t size = 0xffff; 890 struct dcerpc_binding_handle *b = cli->binding_handle; 795 891 796 892 if ((argc < 1) || (argc > 4)) { … … 813 909 /* Get sam policy handle */ 814 910 815 result= rpccli_try_samr_connects(cli, mem_ctx,911 status = rpccli_try_samr_connects(cli, mem_ctx, 816 912 MAXIMUM_ALLOWED_ACCESS, 817 913 &connect_pol); 818 819 if (!NT_STATUS_IS_OK(result))820 goto done;914 if (!NT_STATUS_IS_OK(status)) { 915 goto done; 916 } 821 917 822 918 /* Get domain policy handle */ 823 919 824 result= get_domain_handle(cli, mem_ctx, "domain",920 status = get_domain_handle(cli, mem_ctx, "domain", 825 921 &connect_pol, 826 922 access_mask, 827 923 &domain_sid, 828 924 &domain_pol); 829 if (!NT_STATUS_IS_OK(result)) 830 goto done; 925 if (!NT_STATUS_IS_OK(status)) { 926 goto done; 927 } 831 928 832 929 /* Enumerate domain users */ … … 835 932 836 933 do { 837 result = rpccli_samr_EnumDomainUsers(cli, mem_ctx,934 status = dcerpc_samr_EnumDomainUsers(b, mem_ctx, 838 935 &domain_pol, 839 936 &start_idx, … … 841 938 &dom_users, 842 939 size, 843 &num_dom_users); 844 940 &num_dom_users, 941 &result); 942 if (!NT_STATUS_IS_OK(status)) { 943 goto done; 944 } 845 945 if (NT_STATUS_IS_OK(result) || 846 946 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) { … … 856 956 done: 857 957 if (is_valid_policy_hnd(&domain_pol)) 858 rpccli_samr_Close(cli, mem_ctx, &domain_pol);958 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 859 959 860 960 if (is_valid_policy_hnd(&connect_pol)) 861 rpccli_samr_Close(cli, mem_ctx, &connect_pol);862 863 return result;961 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 962 963 return status; 864 964 } 865 965 … … 871 971 { 872 972 struct policy_handle connect_pol, domain_pol; 873 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;973 NTSTATUS status, result; 874 974 uint32 start_idx, num_dom_groups, i; 875 975 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 876 976 struct samr_SamArray *dom_groups = NULL; 877 977 uint32_t size = 0xffff; 978 struct dcerpc_binding_handle *b = cli->binding_handle; 878 979 879 980 if ((argc < 1) || (argc > 3)) { … … 892 993 /* Get sam policy handle */ 893 994 894 result= rpccli_try_samr_connects(cli, mem_ctx,995 status = rpccli_try_samr_connects(cli, mem_ctx, 895 996 MAXIMUM_ALLOWED_ACCESS, 896 997 &connect_pol); 897 898 if (!NT_STATUS_IS_OK(result))899 goto done;998 if (!NT_STATUS_IS_OK(status)) { 999 goto done; 1000 } 900 1001 901 1002 /* Get domain policy handle */ 902 1003 903 result= get_domain_handle(cli, mem_ctx, "domain",1004 status = get_domain_handle(cli, mem_ctx, "domain", 904 1005 &connect_pol, 905 1006 access_mask, 906 1007 &domain_sid, 907 1008 &domain_pol); 908 if (!NT_STATUS_IS_OK(result)) 909 goto done; 1009 if (!NT_STATUS_IS_OK(status)) { 1010 goto done; 1011 } 910 1012 911 1013 /* Enumerate domain groups */ … … 914 1016 915 1017 do { 916 result = rpccli_samr_EnumDomainGroups(cli, mem_ctx,1018 status = dcerpc_samr_EnumDomainGroups(b, mem_ctx, 917 1019 &domain_pol, 918 1020 &start_idx, 919 1021 &dom_groups, 920 1022 size, 921 &num_dom_groups); 1023 &num_dom_groups, 1024 &result); 1025 if (!NT_STATUS_IS_OK(status)) { 1026 goto done; 1027 } 922 1028 if (NT_STATUS_IS_OK(result) || 923 1029 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) { … … 933 1039 done: 934 1040 if (is_valid_policy_hnd(&domain_pol)) 935 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1041 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 936 1042 937 1043 if (is_valid_policy_hnd(&connect_pol)) 938 rpccli_samr_Close(cli, mem_ctx, &connect_pol);939 940 return result;1044 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1045 1046 return status; 941 1047 } 942 1048 … … 948 1054 { 949 1055 struct policy_handle connect_pol, domain_pol; 950 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1056 NTSTATUS status, result; 951 1057 uint32 start_idx, num_als_groups, i; 952 1058 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 953 1059 struct samr_SamArray *als_groups = NULL; 954 1060 uint32_t size = 0xffff; 1061 struct dcerpc_binding_handle *b = cli->binding_handle; 955 1062 956 1063 if ((argc < 2) || (argc > 4)) { … … 969 1076 /* Get sam policy handle */ 970 1077 971 result= rpccli_try_samr_connects(cli, mem_ctx,1078 status = rpccli_try_samr_connects(cli, mem_ctx, 972 1079 MAXIMUM_ALLOWED_ACCESS, 973 1080 &connect_pol); 974 975 if (!NT_STATUS_IS_OK(result))976 goto done;1081 if (!NT_STATUS_IS_OK(status)) { 1082 goto done; 1083 } 977 1084 978 1085 /* Get domain policy handle */ 979 1086 980 result= get_domain_handle(cli, mem_ctx, argv[1],1087 status = get_domain_handle(cli, mem_ctx, argv[1], 981 1088 &connect_pol, 982 1089 access_mask, 983 1090 &domain_sid, 984 1091 &domain_pol); 985 986 if (!NT_STATUS_IS_OK(result))987 goto done;1092 if (!NT_STATUS_IS_OK(status)) { 1093 goto done; 1094 } 988 1095 989 1096 /* Enumerate alias groups */ … … 992 1099 993 1100 do { 994 result = rpccli_samr_EnumDomainAliases(cli, mem_ctx,1101 status = dcerpc_samr_EnumDomainAliases(b, mem_ctx, 995 1102 &domain_pol, 996 1103 &start_idx, 997 1104 &als_groups, 998 1105 size, 999 &num_als_groups); 1000 1106 &num_als_groups, 1107 &result); 1108 if (!NT_STATUS_IS_OK(status)) { 1109 goto done; 1110 } 1001 1111 if (NT_STATUS_IS_OK(result) || 1002 1112 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) { … … 1011 1121 done: 1012 1122 if (is_valid_policy_hnd(&domain_pol)) 1013 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1123 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1014 1124 1015 1125 if (is_valid_policy_hnd(&connect_pol)) 1016 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1017 1018 return result;1126 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1127 1128 return status; 1019 1129 } 1020 1130 … … 1026 1136 { 1027 1137 struct policy_handle connect_pol; 1028 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1138 NTSTATUS status, result; 1029 1139 uint32 start_idx, size, num_entries, i; 1030 1140 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1031 1141 struct samr_SamArray *sam = NULL; 1142 struct dcerpc_binding_handle *b = cli->binding_handle; 1032 1143 1033 1144 if ((argc < 1) || (argc > 2)) { … … 1042 1153 /* Get sam policy handle */ 1043 1154 1044 result= rpccli_try_samr_connects(cli, mem_ctx,1155 status = rpccli_try_samr_connects(cli, mem_ctx, 1045 1156 access_mask, 1046 1157 &connect_pol); 1047 1048 if (!NT_STATUS_IS_OK(result)) { 1158 if (!NT_STATUS_IS_OK(status)) { 1049 1159 goto done; 1050 1160 } … … 1056 1166 1057 1167 do { 1058 result = rpccli_samr_EnumDomains(cli, mem_ctx,1168 status = dcerpc_samr_EnumDomains(b, mem_ctx, 1059 1169 &connect_pol, 1060 1170 &start_idx, 1061 1171 &sam, 1062 1172 size, 1063 &num_entries); 1064 1173 &num_entries, 1174 &result); 1175 if (!NT_STATUS_IS_OK(status)) { 1176 goto done; 1177 } 1065 1178 if (NT_STATUS_IS_OK(result) || 1066 1179 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) { … … 1075 1188 done: 1076 1189 if (is_valid_policy_hnd(&connect_pol)) { 1077 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1078 } 1079 1080 return result;1190 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1191 } 1192 1193 return status; 1081 1194 } 1082 1195 … … 1089 1202 { 1090 1203 struct policy_handle connect_pol, domain_pol, alias_pol; 1091 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1204 NTSTATUS status, result; 1092 1205 uint32 alias_rid, i; 1093 1206 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1094 1207 struct lsa_SidArray sid_array; 1208 struct dcerpc_binding_handle *b = cli->binding_handle; 1095 1209 1096 1210 if ((argc < 3) || (argc > 4)) { … … 1106 1220 /* Open SAMR handle */ 1107 1221 1108 result= rpccli_try_samr_connects(cli, mem_ctx,1222 status = rpccli_try_samr_connects(cli, mem_ctx, 1109 1223 MAXIMUM_ALLOWED_ACCESS, 1110 1224 &connect_pol); 1111 1112 if (!NT_STATUS_IS_OK(result))1113 goto done;1225 if (!NT_STATUS_IS_OK(status)) { 1226 goto done; 1227 } 1114 1228 1115 1229 /* Open handle on domain */ 1116 1230 1117 result= get_domain_handle(cli, mem_ctx, argv[1],1231 status = get_domain_handle(cli, mem_ctx, argv[1], 1118 1232 &connect_pol, 1119 1233 MAXIMUM_ALLOWED_ACCESS, 1120 1234 &domain_sid, 1121 1235 &domain_pol); 1122 1123 if (!NT_STATUS_IS_OK(result))1124 goto done;1236 if (!NT_STATUS_IS_OK(status)) { 1237 goto done; 1238 } 1125 1239 1126 1240 /* Open handle on alias */ 1127 1241 1128 result = rpccli_samr_OpenAlias(cli, mem_ctx,1242 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1129 1243 &domain_pol, 1130 1244 access_mask, 1131 1245 alias_rid, 1132 &alias_pol); 1133 if (!NT_STATUS_IS_OK(result)) 1134 goto done; 1135 1136 result = rpccli_samr_GetMembersInAlias(cli, mem_ctx, 1246 &alias_pol, 1247 &result); 1248 if (!NT_STATUS_IS_OK(status)) { 1249 goto done; 1250 } 1251 if (!NT_STATUS_IS_OK(result)) { 1252 status = result; 1253 goto done; 1254 } 1255 1256 status = dcerpc_samr_GetMembersInAlias(b, mem_ctx, 1137 1257 &alias_pol, 1138 &sid_array); 1139 1140 if (!NT_STATUS_IS_OK(result)) 1141 goto done; 1258 &sid_array, 1259 &result); 1260 if (!NT_STATUS_IS_OK(status)) { 1261 goto done; 1262 } 1263 if (!NT_STATUS_IS_OK(result)) { 1264 status = result; 1265 goto done; 1266 } 1142 1267 1143 1268 for (i = 0; i < sid_array.num_sids; i++) { … … 1148 1273 } 1149 1274 1150 rpccli_samr_Close(cli, mem_ctx, &alias_pol);1151 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1152 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1275 dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result); 1276 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1277 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1153 1278 done: 1154 return result;1279 return status; 1155 1280 } 1156 1281 … … 1162 1287 { 1163 1288 struct policy_handle connect_pol, domain_pol, alias_pol; 1164 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1289 NTSTATUS status, result; 1165 1290 uint32_t alias_rid; 1166 1291 uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED; 1167 1292 union samr_AliasInfo *info = NULL; 1168 1293 enum samr_AliasInfoEnum level = ALIASINFOALL; 1294 struct dcerpc_binding_handle *b = cli->binding_handle; 1169 1295 1170 1296 if ((argc < 3) || (argc > 4)) { … … 1186 1312 /* Open SAMR handle */ 1187 1313 1188 result= rpccli_try_samr_connects(cli, mem_ctx,1314 status = rpccli_try_samr_connects(cli, mem_ctx, 1189 1315 SEC_FLAG_MAXIMUM_ALLOWED, 1190 1316 &connect_pol); 1191 1192 if (!NT_STATUS_IS_OK(result)) { 1317 if (!NT_STATUS_IS_OK(status)) { 1193 1318 goto done; 1194 1319 } … … 1196 1321 /* Open handle on domain */ 1197 1322 1198 result= get_domain_handle(cli, mem_ctx, argv[1],1323 status = get_domain_handle(cli, mem_ctx, argv[1], 1199 1324 &connect_pol, 1200 1325 SEC_FLAG_MAXIMUM_ALLOWED, 1201 1326 &domain_sid, 1202 1327 &domain_pol); 1203 1204 if (!NT_STATUS_IS_OK(result)) { 1328 if (!NT_STATUS_IS_OK(status)) { 1205 1329 goto done; 1206 1330 } … … 1208 1332 /* Open handle on alias */ 1209 1333 1210 result = rpccli_samr_OpenAlias(cli, mem_ctx,1334 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1211 1335 &domain_pol, 1212 1336 access_mask, 1213 1337 alias_rid, 1214 &alias_pol); 1215 if (!NT_STATUS_IS_OK(result)) { 1216 goto done; 1217 } 1218 1219 result = rpccli_samr_QueryAliasInfo(cli, mem_ctx, 1338 &alias_pol, 1339 &result); 1340 if (!NT_STATUS_IS_OK(status)) { 1341 goto done; 1342 } 1343 if (!NT_STATUS_IS_OK(result)) { 1344 status = result; 1345 goto done; 1346 } 1347 1348 status = dcerpc_samr_QueryAliasInfo(b, mem_ctx, 1220 1349 &alias_pol, 1221 1350 level, 1222 &info); 1223 1224 if (!NT_STATUS_IS_OK(result)) { 1351 &info, 1352 &result); 1353 if (!NT_STATUS_IS_OK(status)) { 1354 goto done; 1355 } 1356 if (!NT_STATUS_IS_OK(result)) { 1357 status = result; 1225 1358 goto done; 1226 1359 } … … 1242 1375 } 1243 1376 1244 rpccli_samr_Close(cli, mem_ctx, &alias_pol);1245 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1246 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1377 dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result); 1378 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1379 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1247 1380 done: 1248 return result;1381 return status; 1249 1382 } 1250 1383 … … 1257 1390 { 1258 1391 struct policy_handle connect_pol, domain_pol, alias_pol; 1259 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1392 NTSTATUS status, result; 1260 1393 uint32 alias_rid; 1261 1394 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1395 struct dcerpc_binding_handle *b = cli->binding_handle; 1262 1396 1263 1397 if (argc != 3) { … … 1270 1404 /* Open SAMR handle */ 1271 1405 1272 result= rpccli_try_samr_connects(cli, mem_ctx,1406 status = rpccli_try_samr_connects(cli, mem_ctx, 1273 1407 MAXIMUM_ALLOWED_ACCESS, 1274 1408 &connect_pol); 1275 1276 if (!NT_STATUS_IS_OK(result))1277 goto done;1409 if (!NT_STATUS_IS_OK(status)) { 1410 goto done; 1411 } 1278 1412 1279 1413 /* Open handle on domain */ 1280 1414 1281 result= get_domain_handle(cli, mem_ctx, argv[1],1415 status = get_domain_handle(cli, mem_ctx, argv[1], 1282 1416 &connect_pol, 1283 1417 MAXIMUM_ALLOWED_ACCESS, 1284 1418 &domain_sid, 1285 1419 &domain_pol); 1286 1287 if (!NT_STATUS_IS_OK(result))1288 goto done;1420 if (!NT_STATUS_IS_OK(status)) { 1421 goto done; 1422 } 1289 1423 1290 1424 /* Open handle on alias */ 1291 1425 1292 result = rpccli_samr_OpenAlias(cli, mem_ctx,1426 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1293 1427 &domain_pol, 1294 1428 access_mask, 1295 1429 alias_rid, 1296 &alias_pol); 1430 &alias_pol, 1431 &result); 1432 if (!NT_STATUS_IS_OK(status)) { 1433 goto done; 1434 } 1297 1435 if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) { 1298 1436 /* Probably this was a user name, try lookupnames */ … … 1302 1440 init_lsa_String(&lsa_acct_name, argv[2]); 1303 1441 1304 result = rpccli_samr_LookupNames(cli, mem_ctx,1442 status = dcerpc_samr_LookupNames(b, mem_ctx, 1305 1443 &domain_pol, 1306 1444 1, 1307 1445 &lsa_acct_name, 1308 1446 &rids, 1309 &types); 1310 1447 &types, 1448 &result); 1449 if (!NT_STATUS_IS_OK(status)) { 1450 goto done; 1451 } 1311 1452 if (NT_STATUS_IS_OK(result)) { 1312 result = rpccli_samr_OpenAlias(cli, mem_ctx,1453 status = dcerpc_samr_OpenAlias(b, mem_ctx, 1313 1454 &domain_pol, 1314 1455 access_mask, 1315 1456 rids.ids[0], 1316 &alias_pol); 1317 } 1318 } 1319 1320 result = rpccli_samr_DeleteDomAlias(cli, mem_ctx, 1321 &alias_pol); 1322 1323 if (!NT_STATUS_IS_OK(result)) 1324 goto done; 1325 1326 rpccli_samr_Close(cli, mem_ctx, &domain_pol); 1327 rpccli_samr_Close(cli, mem_ctx, &connect_pol); 1457 &alias_pol, 1458 &result); 1459 if (!NT_STATUS_IS_OK(status)) { 1460 goto done; 1461 } 1462 } 1463 } 1464 1465 status = dcerpc_samr_DeleteDomAlias(b, mem_ctx, 1466 &alias_pol, 1467 &result); 1468 if (!NT_STATUS_IS_OK(status)) { 1469 goto done; 1470 } 1471 if (!NT_STATUS_IS_OK(result)) { 1472 status = result; 1473 goto done; 1474 } 1475 1476 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1477 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1328 1478 done: 1329 return result;1479 return status; 1330 1480 } 1331 1481 … … 1338 1488 { 1339 1489 struct policy_handle connect_pol, domain_pol; 1340 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1490 NTSTATUS status, result; 1341 1491 uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries = 0, i; 1342 1492 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; … … 1346 1496 bool got_params = False; /* Use get_query_dispinfo_params() or not? */ 1347 1497 uint32_t total_size, returned_size; 1498 struct dcerpc_binding_handle *b = cli->binding_handle; 1348 1499 1349 1500 if (argc > 6) { … … 1373 1524 /* Get sam policy handle */ 1374 1525 1375 result= rpccli_try_samr_connects(cli, mem_ctx,1526 status = rpccli_try_samr_connects(cli, mem_ctx, 1376 1527 MAXIMUM_ALLOWED_ACCESS, 1377 1528 &connect_pol); 1378 1379 if (!NT_STATUS_IS_OK(result))1380 goto done;1529 if (!NT_STATUS_IS_OK(status)) { 1530 goto done; 1531 } 1381 1532 1382 1533 /* Get domain policy handle */ 1383 1534 1384 result = rpccli_samr_OpenDomain(cli, mem_ctx,1535 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1385 1536 &connect_pol, 1386 1537 access_mask, 1387 1538 &domain_sid, 1388 &domain_pol); 1389 1390 if (!NT_STATUS_IS_OK(result)) 1391 goto done; 1539 &domain_pol, 1540 &result); 1541 if (!NT_STATUS_IS_OK(status)) { 1542 goto done; 1543 } 1544 if (!NT_STATUS_IS_OK(result)) { 1545 status = result; 1546 goto done; 1547 } 1392 1548 1393 1549 /* Query display info */ … … 1396 1552 1397 1553 if (!got_params) 1398 get_query_dispinfo_params(1554 dcerpc_get_query_dispinfo_params( 1399 1555 loop_count, &max_entries, &max_size); 1400 1556 1401 1557 switch (opcode) { 1402 1558 case NDR_SAMR_QUERYDISPLAYINFO: 1403 result = rpccli_samr_QueryDisplayInfo(cli, mem_ctx,1559 status = dcerpc_samr_QueryDisplayInfo(b, mem_ctx, 1404 1560 &domain_pol, 1405 1561 info_level, … … 1409 1565 &total_size, 1410 1566 &returned_size, 1411 &info); 1567 &info, 1568 &result); 1412 1569 break; 1413 1570 case NDR_SAMR_QUERYDISPLAYINFO2: 1414 result = rpccli_samr_QueryDisplayInfo2(cli, mem_ctx,1571 status = dcerpc_samr_QueryDisplayInfo2(b, mem_ctx, 1415 1572 &domain_pol, 1416 1573 info_level, … … 1420 1577 &total_size, 1421 1578 &returned_size, 1422 &info); 1579 &info, 1580 &result); 1423 1581 1424 1582 break; 1425 1583 case NDR_SAMR_QUERYDISPLAYINFO3: 1426 result = rpccli_samr_QueryDisplayInfo3(cli, mem_ctx,1584 status = dcerpc_samr_QueryDisplayInfo3(b, mem_ctx, 1427 1585 &domain_pol, 1428 1586 info_level, … … 1432 1590 &total_size, 1433 1591 &returned_size, 1434 &info); 1592 &info, 1593 &result); 1435 1594 1436 1595 break; … … 1439 1598 } 1440 1599 1600 if (!NT_STATUS_IS_OK(status)) { 1601 break; 1602 } 1603 status = result; 1441 1604 if (!NT_STATUS_IS_OK(result) && 1442 1605 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) && … … 1493 1656 } while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); 1494 1657 1495 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1496 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1658 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1659 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1497 1660 done: 1498 return result;1661 return status; 1499 1662 } 1500 1663 … … 1530 1693 { 1531 1694 struct policy_handle connect_pol, domain_pol; 1532 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1695 NTSTATUS status, result; 1533 1696 uint32 switch_level = 2; 1534 1697 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1535 1698 union samr_DomainInfo *info = NULL; 1699 struct dcerpc_binding_handle *b = cli->binding_handle; 1536 1700 1537 1701 if (argc > 3) { … … 1548 1712 /* Get sam policy handle */ 1549 1713 1550 result= rpccli_try_samr_connects(cli, mem_ctx,1714 status = rpccli_try_samr_connects(cli, mem_ctx, 1551 1715 MAXIMUM_ALLOWED_ACCESS, 1552 1716 &connect_pol); 1553 1554 if (!NT_STATUS_IS_OK(result))1555 goto done;1717 if (!NT_STATUS_IS_OK(status)) { 1718 goto done; 1719 } 1556 1720 1557 1721 /* Get domain policy handle */ 1558 1722 1559 result = rpccli_samr_OpenDomain(cli, mem_ctx,1723 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1560 1724 &connect_pol, 1561 1725 access_mask, 1562 1726 &domain_sid, 1563 &domain_pol); 1564 1565 if (!NT_STATUS_IS_OK(result)) 1566 goto done; 1727 &domain_pol, 1728 &result); 1729 if (!NT_STATUS_IS_OK(status)) { 1730 goto done; 1731 } 1732 if (!NT_STATUS_IS_OK(result)) { 1733 status = result; 1734 goto done; 1735 } 1567 1736 1568 1737 /* Query domain info */ 1569 1738 1570 result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,1739 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1571 1740 &domain_pol, 1572 1741 switch_level, 1573 &info); 1574 1575 if (!NT_STATUS_IS_OK(result)) 1576 goto done; 1742 &info, 1743 &result); 1744 if (!NT_STATUS_IS_OK(status)) { 1745 goto done; 1746 } 1747 if (!NT_STATUS_IS_OK(result)) { 1748 status = result; 1749 goto done; 1750 } 1577 1751 1578 1752 /* Display domain info */ … … 1621 1795 done: 1622 1796 1623 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1624 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1625 return result;1797 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1798 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1799 return status; 1626 1800 } 1627 1801 … … 1633 1807 { 1634 1808 struct policy_handle connect_pol, domain_pol, user_pol; 1635 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1809 NTSTATUS status, result; 1636 1810 struct lsa_String acct_name; 1637 1811 uint32 acb_info; … … 1639 1813 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1640 1814 uint32_t access_granted = 0; 1815 struct dcerpc_binding_handle *b = cli->binding_handle; 1641 1816 1642 1817 if ((argc < 2) || (argc > 3)) { … … 1652 1827 /* Get sam policy handle */ 1653 1828 1654 result= rpccli_try_samr_connects(cli, mem_ctx,1829 status = rpccli_try_samr_connects(cli, mem_ctx, 1655 1830 MAXIMUM_ALLOWED_ACCESS, 1656 1831 &connect_pol); 1657 1658 if (!NT_STATUS_IS_OK(result))1659 goto done;1832 if (!NT_STATUS_IS_OK(status)) { 1833 goto done; 1834 } 1660 1835 1661 1836 /* Get domain policy handle */ 1662 1837 1663 result = rpccli_samr_OpenDomain(cli, mem_ctx,1838 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1664 1839 &connect_pol, 1665 1840 access_mask, 1666 1841 &domain_sid, 1667 &domain_pol); 1668 1669 if (!NT_STATUS_IS_OK(result)) 1670 goto done; 1842 &domain_pol, 1843 &result); 1844 if (!NT_STATUS_IS_OK(status)) { 1845 goto done; 1846 } 1847 if (!NT_STATUS_IS_OK(result)) { 1848 status = result; 1849 goto done; 1850 } 1671 1851 1672 1852 /* Create domain user */ … … 1679 1859 SAMR_USER_ACCESS_SET_ATTRIBUTES; 1680 1860 1681 result = rpccli_samr_CreateUser2(cli, mem_ctx,1861 status = dcerpc_samr_CreateUser2(b, mem_ctx, 1682 1862 &domain_pol, 1683 1863 &acct_name, … … 1686 1866 &user_pol, 1687 1867 &access_granted, 1688 &user_rid); 1689 1690 if (!NT_STATUS_IS_OK(result)) 1691 goto done; 1692 1693 result = rpccli_samr_Close(cli, mem_ctx, &user_pol); 1694 if (!NT_STATUS_IS_OK(result)) goto done; 1695 1696 result = rpccli_samr_Close(cli, mem_ctx, &domain_pol); 1697 if (!NT_STATUS_IS_OK(result)) goto done; 1698 1699 result = rpccli_samr_Close(cli, mem_ctx, &connect_pol); 1700 if (!NT_STATUS_IS_OK(result)) goto done; 1868 &user_rid, 1869 &result); 1870 if (!NT_STATUS_IS_OK(status)) { 1871 goto done; 1872 } 1873 if (!NT_STATUS_IS_OK(result)) { 1874 status = result; 1875 goto done; 1876 } 1877 1878 status = dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 1879 if (!NT_STATUS_IS_OK(status)) goto done; 1880 1881 status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1882 if (!NT_STATUS_IS_OK(status)) goto done; 1883 1884 status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1885 if (!NT_STATUS_IS_OK(status)) goto done; 1701 1886 1702 1887 done: 1703 return result;1888 return status; 1704 1889 } 1705 1890 … … 1711 1896 { 1712 1897 struct policy_handle connect_pol, domain_pol, group_pol; 1713 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1898 NTSTATUS status, result; 1714 1899 struct lsa_String grp_name; 1715 1900 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1716 1901 uint32_t rid = 0; 1902 struct dcerpc_binding_handle *b = cli->binding_handle; 1717 1903 1718 1904 if ((argc < 2) || (argc > 3)) { … … 1728 1914 /* Get sam policy handle */ 1729 1915 1730 result= rpccli_try_samr_connects(cli, mem_ctx,1916 status = rpccli_try_samr_connects(cli, mem_ctx, 1731 1917 MAXIMUM_ALLOWED_ACCESS, 1732 1918 &connect_pol); 1733 1734 if (!NT_STATUS_IS_OK(result))1735 goto done;1919 if (!NT_STATUS_IS_OK(status)) { 1920 goto done; 1921 } 1736 1922 1737 1923 /* Get domain policy handle */ 1738 1924 1739 result = rpccli_samr_OpenDomain(cli, mem_ctx,1925 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1740 1926 &connect_pol, 1741 1927 access_mask, 1742 1928 &domain_sid, 1743 &domain_pol); 1744 1745 if (!NT_STATUS_IS_OK(result)) 1746 goto done; 1929 &domain_pol, 1930 &result); 1931 if (!NT_STATUS_IS_OK(status)) { 1932 goto done; 1933 } 1934 if (!NT_STATUS_IS_OK(result)) { 1935 status = result; 1936 goto done; 1937 } 1747 1938 1748 1939 /* Create domain user */ 1749 result = rpccli_samr_CreateDomainGroup(cli, mem_ctx,1940 status = dcerpc_samr_CreateDomainGroup(b, mem_ctx, 1750 1941 &domain_pol, 1751 1942 &grp_name, 1752 1943 MAXIMUM_ALLOWED_ACCESS, 1753 1944 &group_pol, 1754 &rid); 1755 1756 if (!NT_STATUS_IS_OK(result)) 1757 goto done; 1758 1759 result = rpccli_samr_Close(cli, mem_ctx, &group_pol); 1760 if (!NT_STATUS_IS_OK(result)) goto done; 1761 1762 result = rpccli_samr_Close(cli, mem_ctx, &domain_pol); 1763 if (!NT_STATUS_IS_OK(result)) goto done; 1764 1765 result = rpccli_samr_Close(cli, mem_ctx, &connect_pol); 1766 if (!NT_STATUS_IS_OK(result)) goto done; 1945 &rid, 1946 &result); 1947 if (!NT_STATUS_IS_OK(status)) { 1948 goto done; 1949 } 1950 if (!NT_STATUS_IS_OK(result)) { 1951 status = result; 1952 goto done; 1953 } 1954 1955 status = dcerpc_samr_Close(b, mem_ctx, &group_pol, &result); 1956 if (!NT_STATUS_IS_OK(status)) goto done; 1957 1958 status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 1959 if (!NT_STATUS_IS_OK(status)) goto done; 1960 1961 status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1962 if (!NT_STATUS_IS_OK(status)) goto done; 1767 1963 1768 1964 done: 1769 return result;1965 return status; 1770 1966 } 1771 1967 … … 1777 1973 { 1778 1974 struct policy_handle connect_pol, domain_pol, alias_pol; 1779 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;1975 NTSTATUS status, result; 1780 1976 struct lsa_String alias_name; 1781 1977 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 1782 1978 uint32_t rid = 0; 1979 struct dcerpc_binding_handle *b = cli->binding_handle; 1783 1980 1784 1981 if ((argc < 2) || (argc > 3)) { … … 1794 1991 /* Get sam policy handle */ 1795 1992 1796 result= rpccli_try_samr_connects(cli, mem_ctx,1993 status = rpccli_try_samr_connects(cli, mem_ctx, 1797 1994 MAXIMUM_ALLOWED_ACCESS, 1798 1995 &connect_pol); 1799 1800 if (!NT_STATUS_IS_OK(result))1801 goto done;1996 if (!NT_STATUS_IS_OK(status)) { 1997 goto done; 1998 } 1802 1999 1803 2000 /* Get domain policy handle */ 1804 2001 1805 result = rpccli_samr_OpenDomain(cli, mem_ctx,2002 status = dcerpc_samr_OpenDomain(b, mem_ctx, 1806 2003 &connect_pol, 1807 2004 access_mask, 1808 2005 &domain_sid, 1809 &domain_pol); 1810 1811 if (!NT_STATUS_IS_OK(result)) 1812 goto done; 2006 &domain_pol, 2007 &result); 2008 if (!NT_STATUS_IS_OK(status)) { 2009 goto done; 2010 } 2011 if (!NT_STATUS_IS_OK(result)) { 2012 status = result; 2013 goto done; 2014 } 1813 2015 1814 2016 /* Create domain user */ 1815 2017 1816 result = rpccli_samr_CreateDomAlias(cli, mem_ctx,2018 status = dcerpc_samr_CreateDomAlias(b, mem_ctx, 1817 2019 &domain_pol, 1818 2020 &alias_name, 1819 2021 MAXIMUM_ALLOWED_ACCESS, 1820 2022 &alias_pol, 1821 &rid); 1822 1823 if (!NT_STATUS_IS_OK(result)) 1824 goto done; 1825 1826 result = rpccli_samr_Close(cli, mem_ctx, &alias_pol); 1827 if (!NT_STATUS_IS_OK(result)) goto done; 1828 1829 result = rpccli_samr_Close(cli, mem_ctx, &domain_pol); 1830 if (!NT_STATUS_IS_OK(result)) goto done; 1831 1832 result = rpccli_samr_Close(cli, mem_ctx, &connect_pol); 1833 if (!NT_STATUS_IS_OK(result)) goto done; 2023 &rid, 2024 &result); 2025 if (!NT_STATUS_IS_OK(status)) { 2026 goto done; 2027 } 2028 if (!NT_STATUS_IS_OK(result)) { 2029 status = result; 2030 goto done; 2031 } 2032 2033 2034 status = dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result); 2035 if (!NT_STATUS_IS_OK(status)) goto done; 2036 2037 status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2038 if (!NT_STATUS_IS_OK(status)) goto done; 2039 2040 status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2041 if (!NT_STATUS_IS_OK(status)) goto done; 1834 2042 1835 2043 done: 1836 return result;2044 return status; 1837 2045 } 1838 2046 … … 1843 2051 int argc, const char **argv) 1844 2052 { 1845 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2053 NTSTATUS status, result; 1846 2054 struct policy_handle connect_pol, domain_pol; 1847 2055 uint32 num_names; 1848 2056 struct samr_Ids rids, name_types; 1849 2057 int i; 1850 struct lsa_String *names = NULL;; 2058 struct lsa_String *names = NULL; 2059 struct dcerpc_binding_handle *b = cli->binding_handle; 1851 2060 1852 2061 if (argc < 3) { … … 1859 2068 /* Get sam policy and domain handles */ 1860 2069 1861 result= rpccli_try_samr_connects(cli, mem_ctx,2070 status = rpccli_try_samr_connects(cli, mem_ctx, 1862 2071 MAXIMUM_ALLOWED_ACCESS, 1863 2072 &connect_pol); 1864 1865 if (!NT_STATUS_IS_OK(result))1866 goto done;1867 1868 result= get_domain_handle(cli, mem_ctx, argv[1],2073 if (!NT_STATUS_IS_OK(status)) { 2074 goto done; 2075 } 2076 2077 status = get_domain_handle(cli, mem_ctx, argv[1], 1869 2078 &connect_pol, 1870 2079 MAXIMUM_ALLOWED_ACCESS, 1871 2080 &domain_sid, 1872 2081 &domain_pol); 1873 1874 if (!NT_STATUS_IS_OK(result))1875 goto done;2082 if (!NT_STATUS_IS_OK(status)) { 2083 goto done; 2084 } 1876 2085 1877 2086 /* Look up names */ … … 1880 2089 1881 2090 if ((names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names)) == NULL) { 1882 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1883 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1884 result= NT_STATUS_NO_MEMORY;2091 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2092 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2093 status = NT_STATUS_NO_MEMORY; 1885 2094 goto done; 1886 2095 } … … 1890 2099 } 1891 2100 1892 result = rpccli_samr_LookupNames(cli, mem_ctx,2101 status = dcerpc_samr_LookupNames(b, mem_ctx, 1893 2102 &domain_pol, 1894 2103 num_names, 1895 2104 names, 1896 2105 &rids, 1897 &name_types); 1898 1899 if (!NT_STATUS_IS_OK(result)) 1900 goto done; 2106 &name_types, 2107 &result); 2108 if (!NT_STATUS_IS_OK(status)) { 2109 goto done; 2110 } 2111 if (!NT_STATUS_IS_OK(result)) { 2112 status = result; 2113 goto done; 2114 } 1901 2115 1902 2116 /* Display results */ … … 1906 2120 name_types.ids[i]); 1907 2121 1908 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1909 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2122 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2123 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1910 2124 done: 1911 return result;2125 return status; 1912 2126 } 1913 2127 … … 1918 2132 int argc, const char **argv) 1919 2133 { 1920 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2134 NTSTATUS status, result; 1921 2135 struct policy_handle connect_pol, domain_pol; 1922 2136 uint32_t num_rids, *rids; 1923 2137 struct lsa_Strings names; 1924 2138 struct samr_Ids types; 2139 struct dcerpc_binding_handle *b = cli->binding_handle; 1925 2140 1926 2141 int i; … … 1933 2148 /* Get sam policy and domain handles */ 1934 2149 1935 result= rpccli_try_samr_connects(cli, mem_ctx,2150 status = rpccli_try_samr_connects(cli, mem_ctx, 1936 2151 MAXIMUM_ALLOWED_ACCESS, 1937 2152 &connect_pol); 1938 1939 if (!NT_STATUS_IS_OK(result))1940 goto done;1941 1942 result= get_domain_handle(cli, mem_ctx, argv[1],2153 if (!NT_STATUS_IS_OK(status)) { 2154 goto done; 2155 } 2156 2157 status = get_domain_handle(cli, mem_ctx, argv[1], 1943 2158 &connect_pol, 1944 2159 MAXIMUM_ALLOWED_ACCESS, 1945 2160 &domain_sid, 1946 2161 &domain_pol); 1947 1948 if (!NT_STATUS_IS_OK(result))1949 goto done;2162 if (!NT_STATUS_IS_OK(status)) { 2163 goto done; 2164 } 1950 2165 1951 2166 /* Look up rids */ … … 1954 2169 1955 2170 if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) { 1956 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1957 rpccli_samr_Close(cli, mem_ctx, &connect_pol);1958 result= NT_STATUS_NO_MEMORY;2171 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2172 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2173 status = NT_STATUS_NO_MEMORY; 1959 2174 goto done; 1960 2175 } … … 1963 2178 sscanf(argv[i + 2], "%i", &rids[i]); 1964 2179 1965 result = rpccli_samr_LookupRids(cli, mem_ctx,2180 status = dcerpc_samr_LookupRids(b, mem_ctx, 1966 2181 &domain_pol, 1967 2182 num_rids, 1968 2183 rids, 1969 2184 &names, 1970 &types); 1971 2185 &types, 2186 &result); 2187 if (!NT_STATUS_IS_OK(status)) { 2188 goto done; 2189 } 2190 status = result; 1972 2191 if (!NT_STATUS_IS_OK(result) && 1973 2192 !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) … … 1981 2200 } 1982 2201 1983 rpccli_samr_Close(cli, mem_ctx, &domain_pol);1984 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2202 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2203 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 1985 2204 done: 1986 return result;2205 return status; 1987 2206 } 1988 2207 … … 1993 2212 int argc, const char **argv) 1994 2213 { 1995 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2214 NTSTATUS status, result; 1996 2215 struct policy_handle connect_pol, domain_pol, group_pol; 1997 2216 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2217 struct dcerpc_binding_handle *b = cli->binding_handle; 1998 2218 1999 2219 if ((argc < 2) || (argc > 3)) { … … 2007 2227 /* Get sam policy and domain handles */ 2008 2228 2009 result= rpccli_try_samr_connects(cli, mem_ctx,2229 status = rpccli_try_samr_connects(cli, mem_ctx, 2010 2230 MAXIMUM_ALLOWED_ACCESS, 2011 2231 &connect_pol); 2012 2013 if (!NT_STATUS_IS_OK(result))2014 goto done;2015 2016 result = rpccli_samr_OpenDomain(cli, mem_ctx,2232 if (!NT_STATUS_IS_OK(status)) { 2233 goto done; 2234 } 2235 2236 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2017 2237 &connect_pol, 2018 2238 MAXIMUM_ALLOWED_ACCESS, 2019 2239 &domain_sid, 2020 &domain_pol); 2021 2022 if (!NT_STATUS_IS_OK(result)) 2023 goto done; 2240 &domain_pol, 2241 &result); 2242 if (!NT_STATUS_IS_OK(status)) { 2243 goto done; 2244 } 2245 if (!NT_STATUS_IS_OK(result)) { 2246 status = result; 2247 goto done; 2248 } 2024 2249 2025 2250 /* Get handle on group */ … … 2031 2256 init_lsa_String(&lsa_acct_name, argv[1]); 2032 2257 2033 result = rpccli_samr_LookupNames(cli, mem_ctx,2258 status = dcerpc_samr_LookupNames(b, mem_ctx, 2034 2259 &domain_pol, 2035 2260 1, 2036 2261 &lsa_acct_name, 2037 2262 &group_rids, 2038 &name_types); 2039 if (!NT_STATUS_IS_OK(result)) 2263 &name_types, 2264 &result); 2265 if (!NT_STATUS_IS_OK(status)) { 2040 2266 goto done; 2041 2042 result = rpccli_samr_OpenGroup(cli, mem_ctx, 2267 } 2268 if (!NT_STATUS_IS_OK(result)) { 2269 status = result; 2270 goto done; 2271 } 2272 2273 status = dcerpc_samr_OpenGroup(b, mem_ctx, 2043 2274 &domain_pol, 2044 2275 access_mask, 2045 2276 group_rids.ids[0], 2046 &group_pol );2047 2048 if (!NT_STATUS_IS_OK( result))2277 &group_pol, 2278 &result); 2279 if (!NT_STATUS_IS_OK(status)) { 2049 2280 goto done; 2281 } 2282 if (!NT_STATUS_IS_OK(result)) { 2283 status = result; 2284 goto done; 2285 } 2050 2286 } 2051 2287 2052 2288 /* Delete group */ 2053 2289 2054 result = rpccli_samr_DeleteDomainGroup(cli, mem_ctx, 2055 &group_pol); 2056 2057 if (!NT_STATUS_IS_OK(result)) 2058 goto done; 2290 status = dcerpc_samr_DeleteDomainGroup(b, mem_ctx, 2291 &group_pol, 2292 &result); 2293 if (!NT_STATUS_IS_OK(status)) { 2294 goto done; 2295 } 2296 if (!NT_STATUS_IS_OK(result)) { 2297 status = result; 2298 goto done; 2299 } 2059 2300 2060 2301 /* Display results */ 2061 2302 2062 rpccli_samr_Close(cli, mem_ctx, &group_pol);2063 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2064 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2303 dcerpc_samr_Close(b, mem_ctx, &group_pol, &result); 2304 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2305 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2065 2306 2066 2307 done: 2067 return result;2308 return status; 2068 2309 } 2069 2310 … … 2074 2315 int argc, const char **argv) 2075 2316 { 2076 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2317 NTSTATUS status, result; 2077 2318 struct policy_handle connect_pol, domain_pol, user_pol; 2078 2319 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2320 struct dcerpc_binding_handle *b = cli->binding_handle; 2079 2321 2080 2322 if ((argc < 2) || (argc > 3)) { … … 2088 2330 /* Get sam policy and domain handles */ 2089 2331 2090 result= rpccli_try_samr_connects(cli, mem_ctx,2332 status = rpccli_try_samr_connects(cli, mem_ctx, 2091 2333 MAXIMUM_ALLOWED_ACCESS, 2092 2334 &connect_pol); 2093 2094 if (!NT_STATUS_IS_OK(result))2095 goto done;2096 2097 result = rpccli_samr_OpenDomain(cli, mem_ctx,2335 if (!NT_STATUS_IS_OK(status)) { 2336 goto done; 2337 } 2338 2339 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2098 2340 &connect_pol, 2099 2341 MAXIMUM_ALLOWED_ACCESS, 2100 2342 &domain_sid, 2101 &domain_pol); 2102 2103 if (!NT_STATUS_IS_OK(result)) 2104 goto done; 2343 &domain_pol, 2344 &result); 2345 if (!NT_STATUS_IS_OK(status)) { 2346 goto done; 2347 } 2348 if (!NT_STATUS_IS_OK(result)) { 2349 status = result; 2350 goto done; 2351 } 2105 2352 2106 2353 /* Get handle on user */ … … 2112 2359 init_lsa_String(&lsa_acct_name, argv[1]); 2113 2360 2114 result = rpccli_samr_LookupNames(cli, mem_ctx,2361 status = dcerpc_samr_LookupNames(b, mem_ctx, 2115 2362 &domain_pol, 2116 2363 1, 2117 2364 &lsa_acct_name, 2118 2365 &user_rids, 2119 &name_types );2120 2121 if (!NT_STATUS_IS_OK( result))2366 &name_types, 2367 &result); 2368 if (!NT_STATUS_IS_OK(status)) { 2122 2369 goto done; 2123 2124 result = rpccli_samr_OpenUser(cli, mem_ctx, 2370 } 2371 if (!NT_STATUS_IS_OK(result)) { 2372 status = result; 2373 goto done; 2374 } 2375 2376 status = dcerpc_samr_OpenUser(b, mem_ctx, 2125 2377 &domain_pol, 2126 2378 access_mask, 2127 2379 user_rids.ids[0], 2128 &user_pol );2129 2130 if (!NT_STATUS_IS_OK( result))2380 &user_pol, 2381 &result); 2382 if (!NT_STATUS_IS_OK(status)) { 2131 2383 goto done; 2384 } 2385 if (!NT_STATUS_IS_OK(result)) { 2386 status = result; 2387 goto done; 2388 } 2132 2389 } 2133 2390 2134 2391 /* Delete user */ 2135 2392 2136 result = rpccli_samr_DeleteUser(cli, mem_ctx, 2137 &user_pol); 2138 2139 if (!NT_STATUS_IS_OK(result)) 2140 goto done; 2393 status = dcerpc_samr_DeleteUser(b, mem_ctx, 2394 &user_pol, 2395 &result); 2396 if (!NT_STATUS_IS_OK(status)) { 2397 goto done; 2398 } 2399 if (!NT_STATUS_IS_OK(result)) { 2400 status = result; 2401 goto done; 2402 } 2141 2403 2142 2404 /* Display results */ 2143 2405 2144 rpccli_samr_Close(cli, mem_ctx, &user_pol);2145 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2146 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2406 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 2407 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2408 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2147 2409 2148 2410 done: 2149 return result;2411 return status; 2150 2412 } 2151 2413 … … 2158 2420 { 2159 2421 struct policy_handle connect_pol, domain_pol, user_pol, *pol; 2160 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2161 uint32 sec_info = DACL_SECURITY_INFORMATION;2422 NTSTATUS status, result; 2423 uint32 sec_info = SECINFO_DACL; 2162 2424 uint32 user_rid = 0; 2163 2425 TALLOC_CTX *ctx = NULL; 2164 SEC_DESC_BUF*sec_desc_buf=NULL;2426 struct sec_desc_buf *sec_desc_buf=NULL; 2165 2427 bool domain = False; 2428 struct dcerpc_binding_handle *b = cli->binding_handle; 2166 2429 2167 2430 ctx=talloc_init("cmd_samr_query_sec_obj"); … … 2185 2448 } 2186 2449 2187 result= rpccli_try_samr_connects(cli, mem_ctx,2450 status = rpccli_try_samr_connects(cli, mem_ctx, 2188 2451 MAXIMUM_ALLOWED_ACCESS, 2189 2452 &connect_pol); 2190 2191 if (!NT_STATUS_IS_OK(result))2192 goto done;2193 2194 if (domain || user_rid) 2195 result = rpccli_samr_OpenDomain(cli, mem_ctx,2453 if (!NT_STATUS_IS_OK(status)) { 2454 goto done; 2455 } 2456 2457 if (domain || user_rid) { 2458 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2196 2459 &connect_pol, 2197 2460 MAXIMUM_ALLOWED_ACCESS, 2198 2461 &domain_sid, 2199 &domain_pol); 2200 2201 if (!NT_STATUS_IS_OK(result)) 2202 goto done; 2203 2204 if (user_rid) 2205 result = rpccli_samr_OpenUser(cli, mem_ctx, 2462 &domain_pol, 2463 &result); 2464 if (!NT_STATUS_IS_OK(status)) { 2465 goto done; 2466 } 2467 if (!NT_STATUS_IS_OK(result)) { 2468 status = result; 2469 goto done; 2470 } 2471 } 2472 2473 if (user_rid) { 2474 status = dcerpc_samr_OpenUser(b, mem_ctx, 2206 2475 &domain_pol, 2207 2476 MAXIMUM_ALLOWED_ACCESS, 2208 2477 user_rid, 2209 &user_pol); 2210 2211 if (!NT_STATUS_IS_OK(result)) 2212 goto done; 2478 &user_pol, 2479 &result); 2480 if (!NT_STATUS_IS_OK(status)) { 2481 goto done; 2482 } 2483 if (!NT_STATUS_IS_OK(result)) { 2484 status = result; 2485 goto done; 2486 } 2487 } 2213 2488 2214 2489 /* Pick which query pol to use */ … … 2224 2499 /* Query SAM security object */ 2225 2500 2226 result = rpccli_samr_QuerySecurity(cli, mem_ctx,2501 status = dcerpc_samr_QuerySecurity(b, mem_ctx, 2227 2502 pol, 2228 2503 sec_info, 2229 &sec_desc_buf); 2230 2231 if (!NT_STATUS_IS_OK(result)) 2232 goto done; 2504 &sec_desc_buf, 2505 &result); 2506 if (!NT_STATUS_IS_OK(status)) { 2507 goto done; 2508 } 2509 if (!NT_STATUS_IS_OK(result)) { 2510 status = result; 2511 goto done; 2512 } 2233 2513 2234 2514 display_sec_desc(sec_desc_buf->sd); 2235 2515 2236 rpccli_samr_Close(cli, mem_ctx, &user_pol);2237 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2238 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2516 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 2517 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2518 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2239 2519 done: 2240 2520 talloc_destroy(ctx); 2241 return result;2521 return status; 2242 2522 } 2243 2523 … … 2246 2526 int argc, const char **argv) 2247 2527 { 2248 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2528 NTSTATUS status, result; 2249 2529 struct policy_handle connect_pol, domain_pol, user_pol; 2250 2530 struct samr_PwInfo info; 2251 2531 uint32_t rid; 2532 struct dcerpc_binding_handle *b = cli->binding_handle; 2252 2533 2253 2534 if (argc != 2) { … … 2258 2539 sscanf(argv[1], "%i", &rid); 2259 2540 2260 result= rpccli_try_samr_connects(cli, mem_ctx,2541 status = rpccli_try_samr_connects(cli, mem_ctx, 2261 2542 MAXIMUM_ALLOWED_ACCESS, 2262 2543 &connect_pol); 2263 2264 if (!NT_STATUS_IS_OK(result)) { 2265 goto done; 2266 } 2267 2268 result = rpccli_samr_OpenDomain(cli, mem_ctx, 2544 if (!NT_STATUS_IS_OK(status)) { 2545 goto done; 2546 } 2547 2548 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2269 2549 &connect_pol, 2270 2550 MAXIMUM_ALLOWED_ACCESS, 2271 2551 &domain_sid, 2272 &domain_pol); 2273 2274 if (!NT_STATUS_IS_OK(result)) { 2275 goto done; 2276 } 2277 2278 result = rpccli_samr_OpenUser(cli, mem_ctx, 2552 &domain_pol, 2553 &result); 2554 if (!NT_STATUS_IS_OK(status)) { 2555 goto done; 2556 } 2557 if (!NT_STATUS_IS_OK(result)) { 2558 status = result; 2559 goto done; 2560 } 2561 2562 status = dcerpc_samr_OpenUser(b, mem_ctx, 2279 2563 &domain_pol, 2280 2564 MAXIMUM_ALLOWED_ACCESS, 2281 2565 rid, 2282 &user_pol); 2283 2284 if (!NT_STATUS_IS_OK(result)) { 2285 goto done; 2286 } 2287 2288 result = rpccli_samr_GetUserPwInfo(cli, mem_ctx, &user_pol, &info); 2566 &user_pol, 2567 &result); 2568 if (!NT_STATUS_IS_OK(status)) { 2569 goto done; 2570 } 2571 if (!NT_STATUS_IS_OK(result)) { 2572 status = result; 2573 goto done; 2574 } 2575 2576 status = dcerpc_samr_GetUserPwInfo(b, mem_ctx, 2577 &user_pol, 2578 &info, 2579 &result); 2580 if (!NT_STATUS_IS_OK(status)) { 2581 goto done; 2582 } 2583 status = result; 2289 2584 if (NT_STATUS_IS_OK(result)) { 2290 2585 printf("min_password_length: %d\n", info.min_password_length); … … 2295 2590 2296 2591 done: 2297 rpccli_samr_Close(cli, mem_ctx, &user_pol);2298 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2299 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2300 2301 return result;2592 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 2593 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2594 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2595 2596 return status; 2302 2597 } 2303 2598 … … 2306 2601 int argc, const char **argv) 2307 2602 { 2308 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2603 NTSTATUS status, result; 2309 2604 struct lsa_String domain_name; 2310 2605 struct samr_PwInfo info; 2606 struct dcerpc_binding_handle *b = cli->binding_handle; 2311 2607 2312 2608 if (argc < 1 || argc > 3) { … … 2317 2613 init_lsa_String(&domain_name, argv[1]); 2318 2614 2319 result = rpccli_samr_GetDomPwInfo(cli, mem_ctx, &domain_name, &info); 2320 2615 status = dcerpc_samr_GetDomPwInfo(b, mem_ctx, 2616 &domain_name, 2617 &info, 2618 &result); 2619 if (!NT_STATUS_IS_OK(status)) { 2620 return status; 2621 } 2321 2622 if (NT_STATUS_IS_OK(result)) { 2322 2623 printf("min_password_length: %d\n", info.min_password_length); … … 2334 2635 { 2335 2636 struct policy_handle connect_pol, domain_pol; 2336 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2637 NTSTATUS status, result; 2337 2638 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2338 2639 fstring sid_string; 2339 2640 struct lsa_String domain_name; 2340 DOM_SID *sid = NULL; 2641 struct dom_sid *sid = NULL; 2642 struct dcerpc_binding_handle *b = cli->binding_handle; 2341 2643 2342 2644 if (argc != 2) { … … 2347 2649 init_lsa_String(&domain_name, argv[1]); 2348 2650 2349 result= rpccli_try_samr_connects(cli, mem_ctx,2651 status = rpccli_try_samr_connects(cli, mem_ctx, 2350 2652 access_mask, 2351 2653 &connect_pol); 2352 2353 if (!NT_STATUS_IS_OK(result))2354 goto done;2355 2356 result = rpccli_samr_OpenDomain(cli, mem_ctx,2654 if (!NT_STATUS_IS_OK(status)) { 2655 goto done; 2656 } 2657 2658 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2357 2659 &connect_pol, 2358 2660 access_mask, 2359 2661 &domain_sid, 2360 &domain_pol); 2361 2362 if (!NT_STATUS_IS_OK(result)) 2363 goto done; 2364 2365 result = rpccli_samr_LookupDomain(cli, mem_ctx, 2662 &domain_pol, 2663 &result); 2664 if (!NT_STATUS_IS_OK(status)) { 2665 goto done; 2666 } 2667 if (!NT_STATUS_IS_OK(result)) { 2668 status = result; 2669 goto done; 2670 } 2671 2672 status = dcerpc_samr_LookupDomain(b, mem_ctx, 2366 2673 &connect_pol, 2367 2674 &domain_name, 2368 &sid); 2675 &sid, 2676 &result); 2677 if (!NT_STATUS_IS_OK(status)) { 2678 goto done; 2679 } 2680 if (!NT_STATUS_IS_OK(result)) { 2681 status = result; 2682 goto done; 2683 } 2369 2684 2370 2685 if (NT_STATUS_IS_OK(result)) { … … 2374 2689 } 2375 2690 2376 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2377 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2691 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2692 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2378 2693 done: 2379 return result;2694 return status; 2380 2695 } 2381 2696 … … 2387 2702 { 2388 2703 struct policy_handle connect_pol, domain_pol, user_pol; 2389 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2704 NTSTATUS status, result; 2390 2705 const char *user, *oldpass, *newpass; 2391 2706 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2392 2707 struct samr_Ids rids, types; 2393 2708 struct lsa_String lsa_acct_name; 2709 struct dcerpc_binding_handle *b = cli->binding_handle; 2394 2710 2395 2711 if (argc < 3) { … … 2404 2720 /* Get sam policy handle */ 2405 2721 2406 result= rpccli_try_samr_connects(cli, mem_ctx,2722 status = rpccli_try_samr_connects(cli, mem_ctx, 2407 2723 MAXIMUM_ALLOWED_ACCESS, 2408 2724 &connect_pol); 2409 2410 if (!NT_STATUS_IS_OK(result)) { 2725 if (!NT_STATUS_IS_OK(status)) { 2411 2726 goto done; 2412 2727 } … … 2414 2729 /* Get domain policy handle */ 2415 2730 2416 result = rpccli_samr_OpenDomain(cli, mem_ctx,2731 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2417 2732 &connect_pol, 2418 2733 access_mask, 2419 2734 &domain_sid, 2420 &domain_pol); 2421 2422 if (!NT_STATUS_IS_OK(result)) { 2735 &domain_pol, 2736 &result); 2737 if (!NT_STATUS_IS_OK(status)) { 2738 goto done; 2739 } 2740 if (!NT_STATUS_IS_OK(result)) { 2741 status = result; 2423 2742 goto done; 2424 2743 } … … 2426 2745 init_lsa_String(&lsa_acct_name, user); 2427 2746 2428 result = rpccli_samr_LookupNames(cli, mem_ctx,2747 status = dcerpc_samr_LookupNames(b, mem_ctx, 2429 2748 &domain_pol, 2430 2749 1, 2431 2750 &lsa_acct_name, 2432 2751 &rids, 2433 &types); 2434 2435 if (!NT_STATUS_IS_OK(result)) { 2436 goto done; 2437 } 2438 2439 result = rpccli_samr_OpenUser(cli, mem_ctx, 2752 &types, 2753 &result); 2754 if (!NT_STATUS_IS_OK(status)) { 2755 goto done; 2756 } 2757 if (!NT_STATUS_IS_OK(result)) { 2758 status = result; 2759 goto done; 2760 } 2761 2762 status = dcerpc_samr_OpenUser(b, mem_ctx, 2440 2763 &domain_pol, 2441 2764 access_mask, 2442 2765 rids.ids[0], 2443 &user_pol); 2444 2445 if (!NT_STATUS_IS_OK(result)) { 2766 &user_pol, 2767 &result); 2768 if (!NT_STATUS_IS_OK(status)) { 2769 goto done; 2770 } 2771 if (!NT_STATUS_IS_OK(result)) { 2772 status = result; 2446 2773 goto done; 2447 2774 } 2448 2775 2449 2776 /* Change user password */ 2450 result= rpccli_samr_chgpasswd_user(cli, mem_ctx,2777 status = rpccli_samr_chgpasswd_user(cli, mem_ctx, 2451 2778 &user_pol, 2452 2779 newpass, 2453 2780 oldpass); 2454 2455 if (!NT_STATUS_IS_OK(result)) { 2781 if (!NT_STATUS_IS_OK(status)) { 2456 2782 goto done; 2457 2783 } … … 2459 2785 done: 2460 2786 if (is_valid_policy_hnd(&user_pol)) { 2461 rpccli_samr_Close(cli, mem_ctx, &user_pol);2787 dcerpc_samr_Close(b, mem_ctx, &user_pol, &result); 2462 2788 } 2463 2789 if (is_valid_policy_hnd(&domain_pol)) { 2464 rpccli_samr_Close(cli, mem_ctx, &domain_pol);2790 dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2465 2791 } 2466 2792 if (is_valid_policy_hnd(&connect_pol)) { 2467 rpccli_samr_Close(cli, mem_ctx, &connect_pol);2468 } 2469 2470 return result;2793 dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2794 } 2795 2796 return status; 2471 2797 } 2472 2798 … … 2479 2805 { 2480 2806 struct policy_handle connect_pol, domain_pol; 2481 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2807 NTSTATUS status, result; 2482 2808 const char *user, *oldpass, *newpass; 2483 2809 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2810 struct dcerpc_binding_handle *b = cli->binding_handle; 2484 2811 2485 2812 if (argc < 3) { … … 2494 2821 /* Get sam policy handle */ 2495 2822 2496 result= rpccli_try_samr_connects(cli, mem_ctx,2823 status = rpccli_try_samr_connects(cli, mem_ctx, 2497 2824 MAXIMUM_ALLOWED_ACCESS, 2498 2825 &connect_pol); 2499 2500 if (!NT_STATUS_IS_OK(result))2501 goto done;2826 if (!NT_STATUS_IS_OK(status)) { 2827 goto done; 2828 } 2502 2829 2503 2830 /* Get domain policy handle */ 2504 2831 2505 result = rpccli_samr_OpenDomain(cli, mem_ctx,2832 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2506 2833 &connect_pol, 2507 2834 access_mask, 2508 2835 &domain_sid, 2509 &domain_pol); 2510 2511 if (!NT_STATUS_IS_OK(result)) 2512 goto done; 2836 &domain_pol, 2837 &result); 2838 if (!NT_STATUS_IS_OK(status)) { 2839 goto done; 2840 } 2841 if (!NT_STATUS_IS_OK(result)) { 2842 status = result; 2843 goto done; 2844 } 2513 2845 2514 2846 /* Change user password */ 2515 result = rpccli_samr_chgpasswd_user2(cli, mem_ctx, user, newpass, oldpass); 2516 2517 if (!NT_STATUS_IS_OK(result)) 2518 goto done; 2519 2520 result = rpccli_samr_Close(cli, mem_ctx, &domain_pol); 2521 if (!NT_STATUS_IS_OK(result)) goto done; 2522 2523 result = rpccli_samr_Close(cli, mem_ctx, &connect_pol); 2524 if (!NT_STATUS_IS_OK(result)) goto done; 2847 status = rpccli_samr_chgpasswd_user2(cli, mem_ctx, user, newpass, oldpass); 2848 2849 if (!NT_STATUS_IS_OK(status)) { 2850 goto done; 2851 } 2852 2853 status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2854 if (!NT_STATUS_IS_OK(status)) goto done; 2855 2856 status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2857 if (!NT_STATUS_IS_OK(status)) goto done; 2525 2858 2526 2859 done: 2527 return result;2860 return status; 2528 2861 } 2529 2862 … … 2536 2869 { 2537 2870 struct policy_handle connect_pol, domain_pol; 2538 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;2871 NTSTATUS status, result; 2539 2872 const char *user, *oldpass, *newpass; 2540 2873 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; 2541 2874 struct samr_DomInfo1 *info = NULL; 2542 struct samr_ChangeReject *reject = NULL; 2875 struct userPwdChangeFailureInformation *reject = NULL; 2876 struct dcerpc_binding_handle *b = cli->binding_handle; 2543 2877 2544 2878 if (argc < 3) { … … 2553 2887 /* Get sam policy handle */ 2554 2888 2555 result= rpccli_try_samr_connects(cli, mem_ctx,2889 status = rpccli_try_samr_connects(cli, mem_ctx, 2556 2890 MAXIMUM_ALLOWED_ACCESS, 2557 2891 &connect_pol); 2558 2559 if (!NT_STATUS_IS_OK(result))2560 goto done;2892 if (!NT_STATUS_IS_OK(status)) { 2893 goto done; 2894 } 2561 2895 2562 2896 /* Get domain policy handle */ 2563 2897 2564 result = rpccli_samr_OpenDomain(cli, mem_ctx,2898 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2565 2899 &connect_pol, 2566 2900 access_mask, 2567 2901 &domain_sid, 2568 &domain_pol); 2569 2570 if (!NT_STATUS_IS_OK(result)) 2571 goto done; 2902 &domain_pol, 2903 &result); 2904 if (!NT_STATUS_IS_OK(status)) { 2905 goto done; 2906 } 2907 if (!NT_STATUS_IS_OK(result)) { 2908 status = result; 2909 goto done; 2910 } 2572 2911 2573 2912 /* Change user password */ 2574 result= rpccli_samr_chgpasswd_user3(cli, mem_ctx,2913 status = rpccli_samr_chgpasswd_user3(cli, mem_ctx, 2575 2914 user, 2576 2915 newpass, … … 2578 2917 &info, 2579 2918 &reject); 2919 if (!NT_STATUS_IS_OK(status)) { 2920 goto done; 2921 } 2580 2922 2581 2923 if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) { … … 2583 2925 display_sam_dom_info_1(info); 2584 2926 2585 switch (reject-> reason) {2586 case SAM R_REJECT_TOO_SHORT:2587 d_printf("SAM R_REJECT_TOO_SHORT\n");2927 switch (reject->extendedFailureReason) { 2928 case SAM_PWD_CHANGE_PASSWORD_TOO_SHORT: 2929 d_printf("SAM_PWD_CHANGE_PASSWORD_TOO_SHORT\n"); 2588 2930 break; 2589 case SAM R_REJECT_IN_HISTORY:2590 d_printf("SAM R_REJECT_IN_HISTORY\n");2931 case SAM_PWD_CHANGE_PWD_IN_HISTORY: 2932 d_printf("SAM_PWD_CHANGE_PWD_IN_HISTORY\n"); 2591 2933 break; 2592 case SAMR_REJECT_COMPLEXITY: 2593 d_printf("SAMR_REJECT_COMPLEXITY\n"); 2594 break; 2595 case SAMR_REJECT_OTHER: 2596 d_printf("SAMR_REJECT_OTHER\n"); 2934 case SAM_PWD_CHANGE_NOT_COMPLEX: 2935 d_printf("SAM_PWD_CHANGE_NOT_COMPLEX\n"); 2597 2936 break; 2598 2937 default: 2599 2938 d_printf("unknown reject reason: %d\n", 2600 reject-> reason);2939 reject->extendedFailureReason); 2601 2940 break; 2602 2941 } 2603 2942 } 2604 2943 2605 if (!NT_STATUS_IS_OK(result)) 2606 goto done; 2607 2608 result = rpccli_samr_Close(cli, mem_ctx, &domain_pol); 2609 if (!NT_STATUS_IS_OK(result)) goto done; 2610 2611 result = rpccli_samr_Close(cli, mem_ctx, &connect_pol); 2612 if (!NT_STATUS_IS_OK(result)) goto done; 2944 if (!NT_STATUS_IS_OK(result)) { 2945 status = result; 2946 goto done; 2947 } 2948 2949 status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result); 2950 if (!NT_STATUS_IS_OK(status)) goto done; 2951 2952 status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result); 2953 if (!NT_STATUS_IS_OK(status)) goto done; 2613 2954 2614 2955 done: 2615 return result;2956 return status; 2616 2957 } 2617 2958 … … 2622 2963 { 2623 2964 struct policy_handle connect_pol, domain_pol, user_pol; 2624 NTSTATUS status = NT_STATUS_UNSUCCESSFUL;2965 NTSTATUS status, result; 2625 2966 const char *user, *param; 2626 2967 uint32_t access_mask = MAXIMUM_ALLOWED_ACCESS; … … 2634 2975 DATA_BLOB session_key; 2635 2976 uint8_t password_expired = 0; 2977 struct dcerpc_binding_handle *b = cli->binding_handle; 2636 2978 2637 2979 if (argc < 4) { … … 2763 3105 MAXIMUM_ALLOWED_ACCESS, 2764 3106 &connect_pol); 2765 2766 if (!NT_STATUS_IS_OK(status))2767 goto done;3107 if (!NT_STATUS_IS_OK(status)) { 3108 goto done; 3109 } 2768 3110 2769 3111 /* Get domain policy handle */ 2770 3112 2771 status = rpccli_samr_OpenDomain(cli, mem_ctx,3113 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2772 3114 &connect_pol, 2773 3115 access_mask, 2774 3116 &domain_sid, 2775 &domain_pol); 3117 &domain_pol, 3118 &result); 2776 3119 2777 3120 if (!NT_STATUS_IS_OK(status)) 2778 3121 goto done; 3122 if (!NT_STATUS_IS_OK(result)) { 3123 status = result; 3124 goto done; 3125 } 2779 3126 2780 3127 user_rid = strtol(user, NULL, 0); 2781 3128 if (user_rid) { 2782 status = rpccli_samr_OpenUser(cli, mem_ctx,3129 status = dcerpc_samr_OpenUser(b, mem_ctx, 2783 3130 &domain_pol, 2784 3131 access_mask, 2785 3132 user_rid, 2786 &user_pol); 3133 &user_pol, 3134 &result); 3135 if (!NT_STATUS_IS_OK(status)) { 3136 goto done; 3137 } 3138 3139 status = result; 2787 3140 } 2788 3141 … … 2796 3149 init_lsa_String(&lsa_acct_name, user); 2797 3150 2798 status = rpccli_samr_LookupNames(cli, mem_ctx,3151 status = dcerpc_samr_LookupNames(b, mem_ctx, 2799 3152 &domain_pol, 2800 3153 1, 2801 3154 &lsa_acct_name, 2802 3155 &rids, 2803 &types); 3156 &types, 3157 &result); 2804 3158 if (!NT_STATUS_IS_OK(status)) { 2805 3159 return status; 2806 3160 } 2807 2808 status = rpccli_samr_OpenUser(cli, mem_ctx, 3161 if (!NT_STATUS_IS_OK(result)) { 3162 return result; 3163 } 3164 3165 3166 status = dcerpc_samr_OpenUser(b, mem_ctx, 2809 3167 &domain_pol, 2810 3168 access_mask, 2811 3169 rids.ids[0], 2812 &user_pol); 3170 &user_pol, 3171 &result); 2813 3172 if (!NT_STATUS_IS_OK(status)) { 2814 3173 return status; 2815 3174 } 3175 if (!NT_STATUS_IS_OK(result)) { 3176 return result; 3177 } 2816 3178 } 2817 3179 2818 3180 switch (opcode) { 2819 3181 case NDR_SAMR_SETUSERINFO: 2820 status = rpccli_samr_SetUserInfo(cli, mem_ctx,3182 status = dcerpc_samr_SetUserInfo(b, mem_ctx, 2821 3183 &user_pol, 2822 3184 level, 2823 &info); 3185 &info, 3186 &result); 2824 3187 break; 2825 3188 case NDR_SAMR_SETUSERINFO2: 2826 status = rpccli_samr_SetUserInfo2(cli, mem_ctx,3189 status = dcerpc_samr_SetUserInfo2(b, mem_ctx, 2827 3190 &user_pol, 2828 3191 level, 2829 &info); 3192 &info, 3193 &result); 2830 3194 break; 2831 3195 default: 2832 3196 return NT_STATUS_INVALID_PARAMETER; 2833 3197 } 2834 3198 if (!NT_STATUS_IS_OK(status)) { 3199 DEBUG(0,("status: %s\n", nt_errstr(status))); 3200 goto done; 3201 } 3202 if (!NT_STATUS_IS_OK(result)) { 3203 status = result; 3204 DEBUG(0,("result: %s\n", nt_errstr(status))); 3205 goto done; 3206 } 2835 3207 done: 2836 3208 return status; … … 2857 3229 int argc, const char **argv) 2858 3230 { 2859 NTSTATUS status ;3231 NTSTATUS status, result; 2860 3232 struct policy_handle connect_handle; 2861 3233 struct policy_handle domain_handle; … … 2863 3235 struct lsa_String name; 2864 3236 uint32_t idx = 0; 3237 struct dcerpc_binding_handle *b = cli->binding_handle; 2865 3238 2866 3239 if (argc < 2 || argc > 3) { … … 2878 3251 SEC_FLAG_MAXIMUM_ALLOWED, 2879 3252 &connect_handle); 2880 2881 if (!NT_STATUS_IS_OK(status)) { 2882 goto done; 2883 } 2884 2885 status = rpccli_samr_OpenDomain(cli, mem_ctx, 3253 if (!NT_STATUS_IS_OK(status)) { 3254 goto done; 3255 } 3256 3257 status = dcerpc_samr_OpenDomain(b, mem_ctx, 2886 3258 &connect_handle, 2887 3259 SEC_FLAG_MAXIMUM_ALLOWED, 2888 3260 &domain_sid, 2889 &domain_handle); 2890 2891 if (!NT_STATUS_IS_OK(status)) 2892 goto done; 2893 2894 2895 status = rpccli_samr_GetDisplayEnumerationIndex(cli, mem_ctx, 3261 &domain_handle, 3262 &result); 3263 if (!NT_STATUS_IS_OK(status)) { 3264 goto done; 3265 } 3266 if (!NT_STATUS_IS_OK(result)) { 3267 status = result; 3268 goto done; 3269 } 3270 3271 status = dcerpc_samr_GetDisplayEnumerationIndex(b, mem_ctx, 2896 3272 &domain_handle, 2897 3273 level, 2898 3274 &name, 2899 &idx); 3275 &idx, 3276 &result); 3277 if (!NT_STATUS_IS_OK(status)) { 3278 goto done; 3279 } 3280 3281 status = result; 2900 3282 2901 3283 if (NT_STATUS_IS_OK(status) || … … 2906 3288 2907 3289 if (is_valid_policy_hnd(&domain_handle)) { 2908 rpccli_samr_Close(cli, mem_ctx, &domain_handle);3290 dcerpc_samr_Close(b, mem_ctx, &domain_handle, &result); 2909 3291 } 2910 3292 if (is_valid_policy_hnd(&connect_handle)) { 2911 rpccli_samr_Close(cli, mem_ctx, &connect_handle);3293 dcerpc_samr_Close(b, mem_ctx, &connect_handle, &result); 2912 3294 } 2913 3295 -
vendor/current/source3/rpcclient/cmd_spoolss.c
r594 r740 25 25 #include "includes.h" 26 26 #include "rpcclient.h" 27 #include "../librpc/gen_ndr/cli_spoolss.h" 27 #include "../librpc/gen_ndr/ndr_spoolss_c.h" 28 #include "rpc_client/cli_spoolss.h" 29 #include "rpc_client/init_spoolss.h" 30 #include "registry/reg_objects.h" 31 #include "nt_printing.h" 32 #include "../libcli/security/display_sec.h" 33 #include "../libcli/security/security_descriptor.h" 34 #include "../libcli/registry/util_reg.h" 35 #include "libsmb/libsmb.h" 28 36 29 37 #define RPCCLIENT_PRINTERNAME(_printername, _cli, _arg) \ … … 72 80 int i=-1; 73 81 74 DEBUG(107,("Getting architecture depend ant directory\n"));82 DEBUG(107,("Getting architecture dependent directory\n")); 75 83 do { 76 84 i++; … … 102 110 WERROR werror; 103 111 struct policy_handle hnd; 104 105 if (argc != 2) { 106 printf("Usage: %s <printername>\n", argv[0]); 112 uint32_t access_mask = PRINTER_ALL_ACCESS; 113 struct dcerpc_binding_handle *b = cli->binding_handle; 114 115 if (argc < 2) { 116 printf("Usage: %s <printername> [access_mask]\n", argv[0]); 107 117 return WERR_OK; 108 118 } 109 119 110 if (!cli) 111 return WERR_GENERAL_FAILURE; 120 if (argc >= 3) { 121 sscanf(argv[2], "%x", &access_mask); 122 } 112 123 113 124 /* Open the printer handle */ … … 115 126 werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx, 116 127 argv[1], 117 PRINTER_ALL_ACCESS,128 access_mask, 118 129 &hnd); 119 130 if (W_ERROR_IS_OK(werror)) { 120 131 printf("Printer %s opened successfully\n", argv[1]); 121 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, &werror);132 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &werror); 122 133 123 134 if (!W_ERROR_IS_OK(werror)) { … … 130 141 } 131 142 143 /**************************************************************************** 144 ****************************************************************************/ 145 146 static WERROR cmd_spoolss_open_printer(struct rpc_pipe_client *cli, 147 TALLOC_CTX *mem_ctx, 148 int argc, const char **argv) 149 { 150 WERROR werror; 151 struct policy_handle hnd; 152 uint32_t access_mask = PRINTER_ALL_ACCESS; 153 NTSTATUS status; 154 struct spoolss_DevmodeContainer devmode_ctr; 155 struct dcerpc_binding_handle *b = cli->binding_handle; 156 157 ZERO_STRUCT(devmode_ctr); 158 159 if (argc < 2) { 160 printf("Usage: %s <printername> [access_mask]\n", argv[0]); 161 return WERR_OK; 162 } 163 164 if (argc >= 3) { 165 sscanf(argv[2], "%x", &access_mask); 166 } 167 168 /* Open the printer handle */ 169 170 status = dcerpc_spoolss_OpenPrinter(b, mem_ctx, 171 argv[1], 172 NULL, 173 devmode_ctr, 174 access_mask, 175 &hnd, 176 &werror); 177 if (!NT_STATUS_IS_OK(status)) { 178 return ntstatus_to_werror(status); 179 } 180 if (W_ERROR_IS_OK(werror)) { 181 printf("Printer %s opened successfully\n", argv[1]); 182 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &werror); 183 184 if (!W_ERROR_IS_OK(werror)) { 185 printf("Error closing printer handle! (%s)\n", 186 get_dos_error_msg(werror)); 187 } 188 } 189 190 return werror; 191 } 132 192 133 193 /**************************************************************************** … … 467 527 struct spoolss_DevmodeContainer devmode_ctr; 468 528 struct sec_desc_buf secdesc_ctr; 529 struct dcerpc_binding_handle *b = cli->binding_handle; 469 530 470 531 if (argc == 1 || argc > 3) { … … 509 570 info_ctr.info.info2 = &info2; 510 571 511 status = rpccli_spoolss_SetPrinter(cli, mem_ctx,572 status = dcerpc_spoolss_SetPrinter(b, mem_ctx, 512 573 &pol, 513 574 &info_ctr, … … 516 577 0, /* command */ 517 578 &result); 579 if (!NT_STATUS_IS_OK(status)) { 580 result = ntstatus_to_werror(status); 581 goto done; 582 } 518 583 if (W_ERROR_IS_OK(result)) 519 584 printf("Success in setting comment.\n"); 520 585 521 586 done: 522 if (is_valid_policy_hnd(&pol)) 523 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 587 if (is_valid_policy_hnd(&pol)) { 588 WERROR _result; 589 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 590 } 524 591 525 592 return result; … … 544 611 struct spoolss_DevmodeContainer devmode_ctr; 545 612 struct sec_desc_buf secdesc_ctr; 613 struct dcerpc_binding_handle *b = cli->binding_handle; 546 614 547 615 ZERO_STRUCT(devmode_ctr); … … 585 653 info_ctr.info.info2 = &info2; 586 654 587 status = rpccli_spoolss_SetPrinter(cli, mem_ctx,655 status = dcerpc_spoolss_SetPrinter(b, mem_ctx, 588 656 &pol, 589 657 &info_ctr, … … 592 660 0, /* command */ 593 661 &result); 662 if (!NT_STATUS_IS_OK(status)) { 663 result = ntstatus_to_werror(status); 664 goto done; 665 } 594 666 if (W_ERROR_IS_OK(result)) 595 667 printf("Success in setting printername.\n"); 596 668 597 669 done: 598 if (is_valid_policy_hnd(&pol)) 599 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 670 if (is_valid_policy_hnd(&pol)) { 671 WERROR _result; 672 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 673 } 600 674 601 675 return result; … … 614 688 const char *printername; 615 689 union spoolss_PrinterInfo info; 690 struct dcerpc_binding_handle *b = cli->binding_handle; 616 691 617 692 if (argc == 1 || argc > 3) { … … 680 755 done: 681 756 if (is_valid_policy_hnd(&pol)) { 682 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 757 WERROR _result; 758 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 683 759 } 684 760 … … 689 765 ****************************************************************************/ 690 766 691 static void display_reg_value(struct regval_blob value)767 static void display_reg_value(struct regval_blob *value) 692 768 { 693 769 const char *text = NULL; 694 770 DATA_BLOB blob; 695 771 696 switch( value.type) {772 switch(regval_type(value)) { 697 773 case REG_DWORD: 698 printf("%s: REG_DWORD: 0x%08x\n", value.valuename,699 *((uint32_t *) value.data_p));774 printf("%s: REG_DWORD: 0x%08x\n", regval_name(value), 775 *((uint32_t *) regval_data_p(value))); 700 776 break; 701 777 case REG_SZ: 702 blob = data_blob_const( value.data_p, value.size);778 blob = data_blob_const(regval_data_p(value), regval_size(value)); 703 779 pull_reg_sz(talloc_tos(), &blob, &text); 704 printf("%s: REG_SZ: %s\n", value.valuename, text ? text : "");780 printf("%s: REG_SZ: %s\n", regval_name(value), text ? text : ""); 705 781 break; 706 782 case REG_BINARY: { 707 char *hex = hex_encode_talloc(NULL, value.data_p, value.size);783 char *hex = hex_encode_talloc(NULL, regval_data_p(value), regval_size(value)); 708 784 size_t i, len; 709 printf("%s: REG_BINARY:", value.valuename);785 printf("%s: REG_BINARY:", regval_name(value)); 710 786 len = strlen(hex); 711 787 for (i=0; i<len; i++) { … … 725 801 uint32_t i; 726 802 const char **values; 727 blob = data_blob_const( value.data_p, value.size);803 blob = data_blob_const(regval_data_p(value), regval_size(value)); 728 804 729 805 if (!pull_reg_multi_sz(NULL, &blob, &values)) { … … 732 808 } 733 809 734 printf("%s: REG_MULTI_SZ: \n", value.valuename);810 printf("%s: REG_MULTI_SZ: \n", regval_name(value)); 735 811 for (i=0; values[i] != NULL; i++) { 736 812 d_printf("%s\n", values[i]); … … 740 816 } 741 817 default: 742 printf("%s: unknown type %d\n", value.valuename, value.type);818 printf("%s: unknown type %d\n", regval_name(value), regval_type(value)); 743 819 } 744 820 … … 816 892 uint8_t *data; 817 893 uint32_t needed; 894 struct dcerpc_binding_handle *b = cli->binding_handle; 818 895 819 896 if (argc != 3) { … … 858 935 859 936 done: 860 if (is_valid_policy_hnd(&pol)) 861 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 937 if (is_valid_policy_hnd(&pol)) { 938 WERROR _result; 939 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 940 } 862 941 863 942 return result; … … 881 960 uint32_t offered = 0; 882 961 uint32_t needed; 962 struct dcerpc_binding_handle *b = cli->binding_handle; 883 963 884 964 if (argc != 4) { … … 915 995 } 916 996 917 status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx,997 status = dcerpc_spoolss_GetPrinterDataEx(b, mem_ctx, 918 998 &pol, 919 999 keyname, … … 924 1004 &needed, 925 1005 &result); 1006 if (!NT_STATUS_IS_OK(status)) { 1007 result = ntstatus_to_werror(status); 1008 goto done; 1009 } 926 1010 if (W_ERROR_EQUAL(result, WERR_MORE_DATA)) { 927 1011 offered = needed; … … 930 1014 goto done; 931 1015 } 932 status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx,1016 status = dcerpc_spoolss_GetPrinterDataEx(b, mem_ctx, 933 1017 &pol, 934 1018 keyname, … … 942 1026 943 1027 if (!NT_STATUS_IS_OK(status)) { 1028 result = ntstatus_to_werror(status); 944 1029 goto done; 945 1030 } … … 954 1039 955 1040 done: 956 if (is_valid_policy_hnd(&pol)) 957 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 1041 if (is_valid_policy_hnd(&pol)) { 1042 WERROR _result; 1043 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 1044 } 958 1045 959 1046 return result; … … 1187 1274 uint32_t server_major_version; 1188 1275 uint32_t server_minor_version; 1276 struct dcerpc_binding_handle *b = cli->binding_handle; 1189 1277 1190 1278 if ((argc == 1) || (argc > 3)) { … … 1267 1355 1268 1356 if (is_valid_policy_hnd(&pol)) { 1269 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 1357 WERROR _result; 1358 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 1270 1359 } 1271 1360 … … 1429 1518 union spoolss_DriverDirectoryInfo info; 1430 1519 uint32_t needed; 1520 struct dcerpc_binding_handle *b = cli->binding_handle; 1431 1521 1432 1522 if (argc > 2) { … … 1443 1533 /* Get the directory. Only use Info level 1 */ 1444 1534 1445 status = rpccli_spoolss_GetPrinterDriverDirectory(cli, mem_ctx,1535 status = dcerpc_spoolss_GetPrinterDriverDirectory(b, mem_ctx, 1446 1536 cli->srv_name_slash, 1447 1537 env, … … 1452 1542 &needed, 1453 1543 &result); 1544 if (!NT_STATUS_IS_OK(status)) { 1545 return ntstatus_to_werror(status); 1546 } 1454 1547 if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) { 1455 1548 offered = needed; 1456 1549 buffer = data_blob_talloc_zero(mem_ctx, needed); 1457 1550 1458 status = rpccli_spoolss_GetPrinterDriverDirectory(cli, mem_ctx,1551 status = dcerpc_spoolss_GetPrinterDriverDirectory(b, mem_ctx, 1459 1552 cli->srv_name_slash, 1460 1553 env, … … 1465 1558 &needed, 1466 1559 &result); 1560 if (!NT_STATUS_IS_OK(status)) { 1561 return ntstatus_to_werror(status); 1562 } 1467 1563 } 1468 1564 … … 1610 1706 const char *arch; 1611 1707 char *driver_args; 1708 struct dcerpc_binding_handle *b = cli->binding_handle; 1612 1709 1613 1710 /* parse the command arguments */ … … 1628 1725 arch = cmd_spoolss_get_short_archi(argv[1]); 1629 1726 if (!arch) { 1630 printf ("Error Unknown architec hture [%s]\n", argv[1]);1727 printf ("Error Unknown architecture [%s]\n", argv[1]); 1631 1728 return WERR_INVALID_PARAM; 1632 1729 } … … 1653 1750 info_ctr.info.info3 = &info3; 1654 1751 1655 status = rpccli_spoolss_AddPrinterDriver(cli, mem_ctx,1752 status = dcerpc_spoolss_AddPrinterDriver(b, mem_ctx, 1656 1753 cli->srv_name_slash, 1657 1754 &info_ctr, … … 1741 1838 struct spoolss_DevmodeContainer devmode_ctr; 1742 1839 struct sec_desc_buf secdesc_ctr; 1840 struct dcerpc_binding_handle *b = cli->binding_handle; 1743 1841 1744 1842 ZERO_STRUCT(devmode_ctr); … … 1783 1881 info_ctr.info.info2 = &info2; 1784 1882 1785 status = rpccli_spoolss_SetPrinter(cli, mem_ctx,1883 status = dcerpc_spoolss_SetPrinter(b, mem_ctx, 1786 1884 &pol, 1787 1885 &info_ctr, … … 1790 1888 0, /* command */ 1791 1889 &result); 1890 if (!NT_STATUS_IS_OK(status)) { 1891 result = ntstatus_to_werror(status); 1892 goto done; 1893 } 1792 1894 if (!W_ERROR_IS_OK(result)) { 1793 1895 printf("SetPrinter call failed!\n"); 1794 goto done; ;1896 goto done; 1795 1897 } 1796 1898 … … 1800 1902 /* Cleanup */ 1801 1903 1802 if (is_valid_policy_hnd(&pol)) 1803 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 1904 if (is_valid_policy_hnd(&pol)) { 1905 WERROR _result; 1906 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 1907 } 1804 1908 1805 1909 return result; … … 1816 1920 WERROR result, ret = WERR_UNKNOWN_PRINTER_DRIVER; 1817 1921 NTSTATUS status; 1922 struct dcerpc_binding_handle *b = cli->binding_handle; 1818 1923 1819 1924 int i; … … 1848 1953 1849 1954 /* make the call to remove the driver */ 1850 status = rpccli_spoolss_DeletePrinterDriverEx(cli, mem_ctx,1955 status = dcerpc_spoolss_DeletePrinterDriverEx(b, mem_ctx, 1851 1956 cli->srv_name_slash, 1852 1957 archi_table[i].long_archi, … … 1855 1960 archi_table[i].version, 1856 1961 &result); 1857 1962 if (!NT_STATUS_IS_OK(status)) { 1963 return ntstatus_to_werror(status); 1964 } 1858 1965 if ( !W_ERROR_IS_OK(result) ) 1859 1966 { … … 1885 1992 NTSTATUS status; 1886 1993 int i; 1994 struct dcerpc_binding_handle *b = cli->binding_handle; 1887 1995 1888 1996 /* parse the command arguments */ … … 1897 2005 1898 2006 /* make the call to remove the driver */ 1899 status = rpccli_spoolss_DeletePrinterDriver(cli, mem_ctx,2007 status = dcerpc_spoolss_DeletePrinterDriver(b, mem_ctx, 1900 2008 cli->srv_name_slash, 1901 2009 archi_table[i].long_archi, … … 1903 2011 &result); 1904 2012 if (!NT_STATUS_IS_OK(status)) { 1905 if (W_ERROR_IS_OK(result)) { 1906 result = ntstatus_to_werror(status); 1907 } 2013 result = ntstatus_to_werror(status); 2014 continue; 1908 2015 } 1909 2016 if ( !W_ERROR_IS_OK(result) ) { 1910 2017 if ( !W_ERROR_EQUAL(result, WERR_UNKNOWN_PRINTER_DRIVER) ) { 1911 printf ("Failed to remove driver %s for arch [%s] - error 0x%x!\n",2018 printf ("Failed to remove driver %s for arch [%s] - error %s!\n", 1912 2019 argv[1], archi_table[i].long_archi, 1913 W_ERROR_V(result));2020 win_errstr(result)); 1914 2021 } 1915 2022 } else { … … 1936 2043 union spoolss_PrintProcessorDirectoryInfo info; 1937 2044 uint32_t needed; 2045 struct dcerpc_binding_handle *b = cli->binding_handle; 1938 2046 1939 2047 /* parse the command arguments */ … … 1947 2055 } 1948 2056 1949 status = rpccli_spoolss_GetPrintProcessorDirectory(cli, mem_ctx,2057 status = dcerpc_spoolss_GetPrintProcessorDirectory(b, mem_ctx, 1950 2058 cli->srv_name_slash, 1951 2059 environment, … … 1956 2064 &needed, 1957 2065 &result); 2066 if (!NT_STATUS_IS_OK(status)) { 2067 return ntstatus_to_werror(status); 2068 } 1958 2069 if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) { 1959 2070 offered = needed; 1960 2071 buffer = data_blob_talloc_zero(mem_ctx, needed); 1961 2072 1962 status = rpccli_spoolss_GetPrintProcessorDirectory(cli, mem_ctx,2073 status = dcerpc_spoolss_GetPrintProcessorDirectory(b, mem_ctx, 1963 2074 cli->srv_name_slash, 1964 2075 environment, … … 1969 2080 &needed, 1970 2081 &result); 2082 if (!NT_STATUS_IS_OK(status)) { 2083 return ntstatus_to_werror(status); 2084 } 1971 2085 } 1972 2086 … … 1992 2106 struct spoolss_AddFormInfo2 info2; 1993 2107 uint32_t level = 1; 2108 struct dcerpc_binding_handle *b = cli->binding_handle; 1994 2109 1995 2110 /* Parse the command arguments */ … … 2050 2165 2051 2166 break; 2167 default: 2168 werror = WERR_INVALID_PARAM; 2169 goto done; 2052 2170 } 2053 2171 … … 2055 2173 2056 2174 2057 status = rpccli_spoolss_AddForm(cli, mem_ctx,2175 status = dcerpc_spoolss_AddForm(b, mem_ctx, 2058 2176 &handle, 2059 2177 level, 2060 2178 info, 2061 2179 &werror); 2062 2180 if (!NT_STATUS_IS_OK(status)) { 2181 werror = ntstatus_to_werror(status); 2182 goto done; 2183 } 2063 2184 done: 2064 if (is_valid_policy_hnd(&handle)) 2065 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 2185 if (is_valid_policy_hnd(&handle)) { 2186 WERROR _result; 2187 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 2188 } 2066 2189 2067 2190 return werror; … … 2080 2203 union spoolss_AddFormInfo info; 2081 2204 struct spoolss_AddFormInfo1 info1; 2205 struct dcerpc_binding_handle *b = cli->binding_handle; 2082 2206 2083 2207 /* Parse the command arguments */ … … 2114 2238 /* Set the form */ 2115 2239 2116 status = rpccli_spoolss_SetForm(cli, mem_ctx,2240 status = dcerpc_spoolss_SetForm(b, mem_ctx, 2117 2241 &handle, 2118 2242 argv[2], … … 2120 2244 info, 2121 2245 &werror); 2122 2246 if (!NT_STATUS_IS_OK(status)) { 2247 werror = ntstatus_to_werror(status); 2248 goto done; 2249 } 2123 2250 done: 2124 if (is_valid_policy_hnd(&handle)) 2125 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 2251 if (is_valid_policy_hnd(&handle)) { 2252 WERROR _result; 2253 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 2254 } 2126 2255 2127 2256 return werror; … … 2197 2326 uint32_t needed; 2198 2327 uint32_t level = 1; 2328 struct dcerpc_binding_handle *b = cli->binding_handle; 2199 2329 2200 2330 /* Parse the command arguments */ … … 2222 2352 /* Get the form */ 2223 2353 2224 status = rpccli_spoolss_GetForm(cli, mem_ctx,2354 status = dcerpc_spoolss_GetForm(b, mem_ctx, 2225 2355 &handle, 2226 2356 argv[2], … … 2231 2361 &needed, 2232 2362 &werror); 2363 if (!NT_STATUS_IS_OK(status)) { 2364 werror = ntstatus_to_werror(status); 2365 goto done; 2366 } 2233 2367 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) { 2234 2368 buffer = data_blob_talloc_zero(mem_ctx, needed); 2235 2369 offered = needed; 2236 status = rpccli_spoolss_GetForm(cli, mem_ctx,2370 status = dcerpc_spoolss_GetForm(b, mem_ctx, 2237 2371 &handle, 2238 2372 argv[2], … … 2243 2377 &needed, 2244 2378 &werror); 2245 } 2246 2247 if (!NT_STATUS_IS_OK(status)) { 2248 return werror; 2379 if (!NT_STATUS_IS_OK(status)) { 2380 werror = ntstatus_to_werror(status); 2381 goto done; 2382 } 2383 } 2384 2385 if (!W_ERROR_IS_OK(werror)) { 2386 goto done; 2249 2387 } 2250 2388 … … 2259 2397 2260 2398 done: 2261 if (is_valid_policy_hnd(&handle)) 2262 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 2399 if (is_valid_policy_hnd(&handle)) { 2400 WERROR _result; 2401 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 2402 } 2263 2403 2264 2404 return werror; … … 2276 2416 NTSTATUS status; 2277 2417 const char *printername; 2418 struct dcerpc_binding_handle *b = cli->binding_handle; 2278 2419 2279 2420 /* Parse the command arguments */ … … 2297 2438 /* Delete the form */ 2298 2439 2299 status = rpccli_spoolss_DeleteForm(cli, mem_ctx,2440 status = dcerpc_spoolss_DeleteForm(b, mem_ctx, 2300 2441 &handle, 2301 2442 argv[2], 2302 2443 &werror); 2303 2444 if (!NT_STATUS_IS_OK(status)) { 2304 return ntstatus_to_werror(status); 2445 werror = ntstatus_to_werror(status); 2446 goto done; 2305 2447 } 2306 2448 2307 2449 done: 2308 if (is_valid_policy_hnd(&handle)) 2309 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 2450 if (is_valid_policy_hnd(&handle)) { 2451 WERROR _result; 2452 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 2453 } 2310 2454 2311 2455 return werror; … … 2324 2468 uint32_t num_forms, level = 1, i; 2325 2469 union spoolss_FormInfo *forms; 2470 struct dcerpc_binding_handle *b = cli->binding_handle; 2326 2471 2327 2472 /* Parse the command arguments */ … … 2373 2518 2374 2519 done: 2375 if (is_valid_policy_hnd(&handle)) 2376 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 2520 if (is_valid_policy_hnd(&handle)) { 2521 WERROR _result; 2522 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 2523 } 2377 2524 2378 2525 return werror; … … 2394 2541 union spoolss_PrinterData data; 2395 2542 DATA_BLOB blob; 2543 struct dcerpc_binding_handle *b = cli->binding_handle; 2396 2544 2397 2545 /* parse the command arguments */ … … 2400 2548 " <value> <data>\n", 2401 2549 argv[0]); 2402 result = WERR_INVALID_PARAM; 2403 goto done; 2550 return WERR_OK; 2404 2551 } 2405 2552 … … 2501 2648 } 2502 2649 2503 status = rpccli_spoolss_SetPrinterData(cli, mem_ctx,2650 status = dcerpc_spoolss_SetPrinterData(b, mem_ctx, 2504 2651 &pol, 2505 2652 argv[3], /* value_name */ … … 2508 2655 blob.length, 2509 2656 &result); 2657 if (!NT_STATUS_IS_OK(status)) { 2658 printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]); 2659 result = ntstatus_to_werror(status); 2660 goto done; 2661 } 2510 2662 if (!W_ERROR_IS_OK(result)) { 2511 2663 printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]); … … 2529 2681 /* cleanup */ 2530 2682 if (is_valid_policy_hnd(&pol)) { 2531 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL); 2683 WERROR _result; 2684 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result); 2532 2685 } 2533 2686 … … 2588 2741 struct policy_handle hnd; 2589 2742 union spoolss_JobInfo *info; 2743 struct dcerpc_binding_handle *b = cli->binding_handle; 2590 2744 2591 2745 if (argc < 2 || argc > 3) { … … 2639 2793 done: 2640 2794 if (is_valid_policy_hnd(&hnd)) { 2641 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 2795 WERROR _result; 2796 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2642 2797 } 2643 2798 … … 2658 2813 uint32_t level = 1; 2659 2814 union spoolss_JobInfo info; 2815 struct dcerpc_binding_handle *b = cli->binding_handle; 2660 2816 2661 2817 if (argc < 3 || argc > 4) { … … 2715 2871 done: 2716 2872 if (is_valid_policy_hnd(&hnd)) { 2717 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 2873 WERROR _result; 2874 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2718 2875 } 2719 2876 … … 2723 2880 /**************************************************************************** 2724 2881 ****************************************************************************/ 2882 2883 static struct { 2884 const char *name; 2885 enum spoolss_JobControl val; 2886 } cmdvals[] = { 2887 {"PAUSE", SPOOLSS_JOB_CONTROL_PAUSE}, 2888 {"RESUME", SPOOLSS_JOB_CONTROL_RESUME}, 2889 {"CANCEL", SPOOLSS_JOB_CONTROL_CANCEL}, 2890 {"RESTART", SPOOLSS_JOB_CONTROL_RESTART}, 2891 {"DELETE", SPOOLSS_JOB_CONTROL_DELETE}, 2892 {"SEND_TO_PRINTER", SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER}, 2893 {"EJECTED", SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED}, 2894 {"RETAIN", SPOOLSS_JOB_CONTROL_RETAIN}, 2895 {"RELEASE", SPOOLSS_JOB_CONTROL_RELEASE} 2896 }; 2897 2898 static enum spoolss_JobControl parse_setjob_command(const char *cmd) 2899 { 2900 int i; 2901 2902 for (i = 0; i < sizeof(cmdvals)/sizeof(cmdvals[0]); i++) { 2903 if (strequal(cmdvals[i].name, cmd)) { 2904 return cmdvals[i].val; 2905 } 2906 } 2907 return (enum spoolss_JobControl)atoi(cmd); 2908 } 2725 2909 2726 2910 static WERROR cmd_spoolss_set_job(struct rpc_pipe_client *cli, … … 2734 2918 uint32_t job_id; 2735 2919 enum spoolss_JobControl command; 2920 struct dcerpc_binding_handle *b = cli->binding_handle; 2736 2921 2737 2922 if (argc != 4) { 2738 2923 printf("Usage: %s printername job_id command\n", argv[0]); 2924 printf("command = [PAUSE|RESUME|CANCEL|RESTART|DELETE|" 2925 "SEND_TO_PRINTER|EJECTED|RETAIN|RELEASE]\n"); 2739 2926 return WERR_OK; 2740 2927 } 2741 2928 2742 2929 job_id = atoi(argv[2]); 2743 command = atoi(argv[3]);2930 command = parse_setjob_command(argv[3]); 2744 2931 2745 2932 /* Open printer handle */ … … 2757 2944 /* Set Job */ 2758 2945 2759 status = rpccli_spoolss_SetJob(cli, mem_ctx,2946 status = dcerpc_spoolss_SetJob(b, mem_ctx, 2760 2947 &hnd, 2761 2948 job_id, … … 2763 2950 command, 2764 2951 &result); 2765 2952 if (!NT_STATUS_IS_OK(status)) { 2953 result = ntstatus_to_werror(status); 2954 goto done; 2955 } 2766 2956 if (!W_ERROR_IS_OK(result)) { 2767 2957 goto done; … … 2770 2960 done: 2771 2961 if (is_valid_policy_hnd(&hnd)) { 2772 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 2962 WERROR _result; 2963 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2773 2964 } 2774 2965 … … 2785 2976 WERROR result; 2786 2977 NTSTATUS status; 2787 uint32_t i = 0;2788 2978 const char *printername; 2789 2979 struct policy_handle hnd; 2790 uint32_t value_offered = 0;2791 const char *value_name = NULL;2792 2980 uint32_t value_needed; 2793 2981 enum winreg_Type type; 2794 uint8_t *data = NULL;2795 uint32_t data_offered = 0;2796 2982 uint32_t data_needed; 2983 struct dcerpc_binding_handle *b = cli->binding_handle; 2984 struct spoolss_EnumPrinterData r; 2797 2985 2798 2986 if (argc != 2) { … … 2815 3003 /* Enumerate data */ 2816 3004 2817 status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx, 2818 &hnd, 2819 i, 2820 value_name, 2821 value_offered, 2822 &value_needed, 2823 &type, 2824 data, 2825 data_offered, 2826 &data_needed, 2827 &result); 2828 2829 data_offered = data_needed; 2830 value_offered = value_needed; 2831 data = talloc_zero_array(mem_ctx, uint8_t, data_needed); 2832 value_name = talloc_zero_array(mem_ctx, char, value_needed); 2833 2834 while (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) { 2835 2836 status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx, 2837 &hnd, 2838 i++, 2839 value_name, 2840 value_offered, 2841 &value_needed, 2842 &type, 2843 data, 2844 data_offered, 2845 &data_needed, 2846 &result); 2847 if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) { 2848 struct regval_blob v; 2849 fstrcpy(v.valuename, value_name); 2850 v.type = type; 2851 v.size = data_offered; 2852 v.data_p = data; 3005 r.in.handle = &hnd; 3006 r.in.enum_index = 0; 3007 r.in.value_offered = 0; 3008 r.in.data_offered = 0; 3009 r.out.value_name = NULL; 3010 r.out.value_needed = &value_needed; 3011 r.out.type = &type; 3012 r.out.data = NULL; 3013 r.out.data_needed = &data_needed; 3014 3015 status = dcerpc_spoolss_EnumPrinterData_r(b, mem_ctx, &r); 3016 if (!NT_STATUS_IS_OK(status)) { 3017 result = ntstatus_to_werror(status); 3018 goto done; 3019 } 3020 3021 if (!W_ERROR_IS_OK(r.out.result)) { 3022 result = r.out.result; 3023 goto done; 3024 } 3025 3026 r.in.data_offered = *r.out.data_needed; 3027 r.in.value_offered = *r.out.value_needed; 3028 r.out.data = talloc_zero_array(mem_ctx, uint8_t, r.in.data_offered); 3029 r.out.value_name = talloc_zero_array(mem_ctx, char, r.in.value_offered); 3030 3031 do { 3032 3033 status = dcerpc_spoolss_EnumPrinterData_r(b, mem_ctx, &r); 3034 if (!NT_STATUS_IS_OK(status)) { 3035 result = ntstatus_to_werror(status); 3036 goto done; 3037 } 3038 3039 if (W_ERROR_EQUAL(r.out.result, WERR_NO_MORE_ITEMS)) { 3040 result = WERR_OK; 3041 break; 3042 } 3043 3044 r.in.enum_index++; 3045 3046 { 3047 struct regval_blob *v; 3048 3049 v = regval_compose(talloc_tos(), 3050 r.out.value_name, 3051 *r.out.type, 3052 r.out.data, 3053 r.in.data_offered); 3054 if (v == NULL) { 3055 result = WERR_NOMEM; 3056 goto done; 3057 } 3058 2853 3059 display_reg_value(v); 2854 } 2855 } 2856 2857 if (W_ERROR_V(result) == ERRnomoreitems) { 2858 result = W_ERROR(ERRsuccess); 2859 } 3060 talloc_free(v); 3061 } 3062 3063 } while (W_ERROR_IS_OK(r.out.result)); 2860 3064 2861 3065 done: 2862 3066 if (is_valid_policy_hnd(&hnd)) { 2863 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 3067 WERROR _result; 3068 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2864 3069 } 2865 3070 … … 2880 3085 uint32_t count; 2881 3086 struct spoolss_PrinterEnumValues *info; 3087 struct dcerpc_binding_handle *b = cli->binding_handle; 2882 3088 2883 3089 if (argc != 3) { … … 2919 3125 done: 2920 3126 if (is_valid_policy_hnd(&hnd)) { 2921 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 3127 WERROR _result; 3128 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2922 3129 } 2923 3130 … … 2939 3146 int i; 2940 3147 uint32_t offered = 0; 3148 struct dcerpc_binding_handle *b = cli->binding_handle; 2941 3149 2942 3150 if (argc < 2 || argc > 4) { … … 2986 3194 2987 3195 if (is_valid_policy_hnd(&hnd)) { 2988 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 3196 WERROR _result; 3197 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 2989 3198 } 2990 3199 … … 3005 3214 NTSTATUS status; 3006 3215 struct spoolss_NotifyOption option; 3216 struct dcerpc_binding_handle *b = cli->binding_handle; 3007 3217 3008 3218 if (argc != 2) { … … 3062 3272 /* Send rffpcnex */ 3063 3273 3064 status = rpccli_spoolss_RemoteFindFirstPrinterChangeNotifyEx(cli, mem_ctx,3274 status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(b, mem_ctx, 3065 3275 &hnd, 3066 3276 0, … … 3070 3280 &option, 3071 3281 &result); 3282 if (!NT_STATUS_IS_OK(status)) { 3283 result = ntstatus_to_werror(status); 3284 goto done; 3285 } 3072 3286 if (!W_ERROR_IS_OK(result)) { 3073 3287 printf("Error rffpcnex %s\n", argv[1]); … … 3076 3290 3077 3291 done: 3078 if (is_valid_policy_hnd(&hnd)) 3079 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL); 3292 if (is_valid_policy_hnd(&hnd)) { 3293 WERROR _result; 3294 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result); 3295 } 3080 3296 3081 3297 return result; … … 3132 3348 WERROR werror; 3133 3349 TALLOC_CTX *mem_ctx = talloc_init("compare_printer_secdesc"); 3134 SEC_DESC*sd1, *sd2;3350 struct security_descriptor *sd1, *sd2; 3135 3351 bool result = true; 3136 3352 … … 3221 3437 get_cmdline_auth_info_password(rpcclient_auth_info), 3222 3438 get_cmdline_auth_info_use_kerberos(rpcclient_auth_info) ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, 3223 get_cmdline_auth_info_signing_state(rpcclient_auth_info) , NULL);3439 get_cmdline_auth_info_signing_state(rpcclient_auth_info)); 3224 3440 3225 3441 if ( !NT_STATUS_IS_OK(nt_status) ) … … 3274 3490 3275 3491 printf("Closing printers..."); 3276 rpccli_spoolss_ClosePrinter( cli, mem_ctx, &hPrinter1, NULL ); 3277 rpccli_spoolss_ClosePrinter( cli2, mem_ctx, &hPrinter2, NULL ); 3492 { 3493 WERROR _result; 3494 dcerpc_spoolss_ClosePrinter(cli->binding_handle, mem_ctx, &hPrinter1, &_result); 3495 dcerpc_spoolss_ClosePrinter(cli2->binding_handle, mem_ctx, &hPrinter2, &_result); 3496 } 3278 3497 printf("ok\n"); 3279 3498 … … 3463 3682 const char *printername; 3464 3683 struct spoolss_DevmodeContainer devmode_ctr; 3684 struct dcerpc_binding_handle *b = cli->binding_handle; 3465 3685 3466 3686 RPCCLIENT_PRINTERNAME(printername, cli, argv[1]); … … 3476 3696 ZERO_STRUCT(devmode_ctr); 3477 3697 3478 status = rpccli_spoolss_CreatePrinterIC(cli, mem_ctx,3698 status = dcerpc_spoolss_CreatePrinterIC(b, mem_ctx, 3479 3699 &handle, 3480 3700 &gdi_handle, 3481 3701 &devmode_ctr, 3482 3702 &result); 3703 if (!NT_STATUS_IS_OK(status)) { 3704 result = ntstatus_to_werror(status); 3705 goto done; 3706 } 3483 3707 if (!W_ERROR_IS_OK(result)) { 3484 3708 goto done; … … 3487 3711 done: 3488 3712 if (is_valid_policy_hnd(&gdi_handle)) { 3489 rpccli_spoolss_DeletePrinterIC(cli, mem_ctx, &gdi_handle, NULL); 3713 WERROR _result; 3714 dcerpc_spoolss_DeletePrinterIC(b, mem_ctx, &gdi_handle, &_result); 3490 3715 } 3491 3716 if (is_valid_policy_hnd(&handle)) { 3492 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); 3717 WERROR _result; 3718 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result); 3493 3719 } 3494 3720 … … 3519 3745 { "getdriverdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriverdir, &ndr_table_spoolss.syntax_id, NULL, "Get print driver upload directory", "" }, 3520 3746 { "getprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinter, &ndr_table_spoolss.syntax_id, NULL, "Get printer info", "" }, 3521 { "openprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex, &ndr_table_spoolss.syntax_id, NULL, "Open printer handle", "" }, 3747 { "openprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer, &ndr_table_spoolss.syntax_id, NULL, "Open printer handle", "" }, 3748 { "openprinter_ex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex, &ndr_table_spoolss.syntax_id, NULL, "Open printer handle", "" }, 3522 3749 { "setdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver, &ndr_table_spoolss.syntax_id, NULL, "Set printer driver", "" }, 3523 3750 { "getprintprocdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprintprocdir, &ndr_table_spoolss.syntax_id, NULL, "Get print processor directory", "" }, -
vendor/current/source3/rpcclient/cmd_srvsvc.c
r414 r740 23 23 #include "includes.h" 24 24 #include "rpcclient.h" 25 #include "../librpc/gen_ndr/cli_srvsvc.h" 25 #include "../librpc/gen_ndr/ndr_srvsvc.h" 26 #include "../librpc/gen_ndr/ndr_srvsvc_c.h" 27 #include "../libcli/security/display_sec.h" 26 28 27 29 /* Display server query info */ … … 174 176 WERROR result; 175 177 NTSTATUS status; 176 177 if (argc > 2) { 178 printf("Usage: %s [infolevel]\n", argv[0]); 179 return WERR_OK; 180 } 181 182 if (argc == 2) 178 const char *server_unc = cli->srv_name_slash; 179 struct dcerpc_binding_handle *b = cli->binding_handle; 180 181 if (argc > 3) { 182 printf("Usage: %s [infolevel] [server_unc]\n", argv[0]); 183 return WERR_OK; 184 } 185 186 if (argc >= 2) { 183 187 info_level = atoi(argv[1]); 184 185 status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, 186 cli->srv_name_slash, 188 } 189 190 if (argc >= 3) { 191 server_unc = argv[2]; 192 } 193 194 status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx, 195 server_unc, 187 196 info_level, 188 197 &info, … … 268 277 uint32_t *resume_handle_p = NULL; 269 278 uint32 preferred_len = 0xffffffff, i; 279 struct dcerpc_binding_handle *b = cli->binding_handle; 270 280 271 281 if (argc > 3) { … … 332 342 switch (opcode) { 333 343 case NDR_SRVSVC_NETSHAREENUM: 334 status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,344 status = dcerpc_srvsvc_NetShareEnum(b, mem_ctx, 335 345 cli->desthost, 336 346 &info_ctr, … … 341 351 break; 342 352 case NDR_SRVSVC_NETSHAREENUMALL: 343 status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,353 status = dcerpc_srvsvc_NetShareEnumAll(b, mem_ctx, 344 354 cli->desthost, 345 355 &info_ctr, … … 353 363 } 354 364 355 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 365 if (!NT_STATUS_IS_OK(status)) { 366 result = ntstatus_to_werror(status); 367 goto done; 368 } 369 if (!W_ERROR_IS_OK(result)) { 356 370 goto done; 357 371 } … … 407 421 WERROR result; 408 422 NTSTATUS status; 423 struct dcerpc_binding_handle *b = cli->binding_handle; 409 424 410 425 if (argc < 2 || argc > 3) { … … 416 431 info_level = atoi(argv[2]); 417 432 418 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,433 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 419 434 cli->desthost, 420 435 argv[1], … … 423 438 &result); 424 439 425 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 440 if (!NT_STATUS_IS_OK(status)) { 441 result = ntstatus_to_werror(status); 442 goto done; 443 } 444 if (!W_ERROR_IS_OK(result)) { 426 445 goto done; 427 446 } … … 457 476 NTSTATUS status; 458 477 uint32_t parm_err = 0; 478 struct dcerpc_binding_handle *b = cli->binding_handle; 459 479 460 480 if (argc > 3) { … … 464 484 465 485 /* retrieve share info */ 466 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,486 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 467 487 cli->desthost, 468 488 argv[1], … … 471 491 &result); 472 492 473 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 493 if (!NT_STATUS_IS_OK(status)) { 494 result = ntstatus_to_werror(status); 495 goto done; 496 } 497 if (!W_ERROR_IS_OK(result)) { 474 498 goto done; 475 499 } … … 478 502 479 503 /* set share info */ 480 status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,504 status = dcerpc_srvsvc_NetShareSetInfo(b, mem_ctx, 481 505 cli->desthost, 482 506 argv[1], … … 486 510 &result); 487 511 488 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 512 if (!NT_STATUS_IS_OK(status)) { 513 result = ntstatus_to_werror(status); 514 goto done; 515 } 516 if (!W_ERROR_IS_OK(result)) { 489 517 goto done; 490 518 } 491 519 492 520 /* re-retrieve share info and display */ 493 status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,521 status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx, 494 522 cli->desthost, 495 523 argv[1], … … 497 525 &info_get, 498 526 &result); 499 500 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 527 if (!NT_STATUS_IS_OK(status)) { 528 result = ntstatus_to_werror(status); 529 goto done; 530 } 531 if (!W_ERROR_IS_OK(result)) { 501 532 goto done; 502 533 } … … 515 546 WERROR result; 516 547 NTSTATUS status; 548 struct dcerpc_binding_handle *b = cli->binding_handle; 517 549 518 550 if (argc > 1) { … … 521 553 } 522 554 523 status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,555 status = dcerpc_srvsvc_NetRemoteTOD(b, mem_ctx, 524 556 cli->srv_name_slash, 525 557 &tod, … … 549 581 uint32_t total_entries = 0; 550 582 uint32_t resume_handle = 0; 583 struct dcerpc_binding_handle *b = cli->binding_handle; 551 584 552 585 if (argc > 2) { … … 564 597 info_ctr.ctr.ctr3 = &ctr3; 565 598 566 status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,599 status = dcerpc_srvsvc_NetFileEnum(b, mem_ctx, 567 600 cli->desthost, 568 601 NULL, … … 573 606 &resume_handle, 574 607 &result); 575 576 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) 577 goto done; 608 if (!NT_STATUS_IS_OK(status)) { 609 result = ntstatus_to_werror(status); 610 goto done; 611 } 612 613 if (!W_ERROR_IS_OK(result)) { 614 goto done; 615 } 578 616 579 617 done: … … 589 627 uint32_t name_type = 9; 590 628 uint32_t flags = 0; 629 struct dcerpc_binding_handle *b = cli->binding_handle; 591 630 592 631 if (argc < 2 || argc > 3) { … … 599 638 } 600 639 601 status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,640 status = dcerpc_srvsvc_NetNameValidate(b, mem_ctx, 602 641 cli->desthost, 603 642 argv[1], … … 605 644 flags, 606 645 &result); 646 if (!NT_STATUS_IS_OK(status)) { 647 result = ntstatus_to_werror(status); 648 goto done; 649 } 607 650 608 651 if (!W_ERROR_IS_OK(result)) … … 620 663 NTSTATUS status; 621 664 struct sec_desc_buf *sd_buf = NULL; 665 struct dcerpc_binding_handle *b = cli->binding_handle; 622 666 623 667 if (argc < 2 || argc > 4) { … … 626 670 } 627 671 628 status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,672 status = dcerpc_srvsvc_NetGetFileSecurity(b, mem_ctx, 629 673 cli->desthost, 630 674 argv[1], … … 633 677 &sd_buf, 634 678 &result); 635 636 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 679 if (!NT_STATUS_IS_OK(status)) { 680 result = ntstatus_to_werror(status); 681 goto done; 682 } 683 684 if (!W_ERROR_IS_OK(result)) { 637 685 goto done; 638 686 } … … 650 698 WERROR result; 651 699 NTSTATUS status; 700 struct dcerpc_binding_handle *b = cli->binding_handle; 652 701 653 702 if (argc < 2 || argc > 4) { … … 656 705 } 657 706 658 status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,707 status = dcerpc_srvsvc_NetSessDel(b, mem_ctx, 659 708 cli->desthost, 660 709 argv[1], 661 710 argv[2], 662 711 &result); 663 664 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 712 if (!NT_STATUS_IS_OK(status)) { 713 result = ntstatus_to_werror(status); 714 goto done; 715 } 716 717 if (!W_ERROR_IS_OK(result)) { 665 718 goto done; 666 719 } … … 688 741 const char *client = NULL; 689 742 const char *user = NULL; 743 struct dcerpc_binding_handle *b = cli->binding_handle; 690 744 691 745 if (argc > 6) { … … 740 794 } 741 795 742 status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,796 status = dcerpc_srvsvc_NetSessEnum(b, mem_ctx, 743 797 cli->desthost, 744 798 client, … … 750 804 &result); 751 805 752 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 806 if (!NT_STATUS_IS_OK(status)) { 807 result = ntstatus_to_werror(status); 808 goto done; 809 } 810 811 if (!W_ERROR_IS_OK(result)) { 753 812 goto done; 754 813 } … … 768 827 uint32_t resume_handle = 0; 769 828 uint32_t level = 0; 829 struct dcerpc_binding_handle *b = cli->binding_handle; 770 830 771 831 if (argc > 4) { … … 784 844 ZERO_STRUCT(info); 785 845 786 status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,846 status = dcerpc_srvsvc_NetDiskEnum(b, mem_ctx, 787 847 cli->desthost, 788 848 level, … … 792 852 &resume_handle, 793 853 &result); 794 795 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 854 if (!NT_STATUS_IS_OK(status)) { 855 result = ntstatus_to_werror(status); 856 goto done; 857 } 858 859 if (!W_ERROR_IS_OK(result)) { 796 860 goto done; 797 861 } … … 815 879 uint32_t level = 1; 816 880 const char *path = "IPC$"; 881 struct dcerpc_binding_handle *b = cli->binding_handle; 817 882 818 883 if (argc > 4) { … … 851 916 } 852 917 853 status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,918 status = dcerpc_srvsvc_NetConnEnum(b, mem_ctx, 854 919 cli->desthost, 855 920 path, … … 860 925 &result); 861 926 862 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 927 if (!NT_STATUS_IS_OK(status)) { 928 result = ntstatus_to_werror(status); 929 goto done; 930 } 931 932 if (!W_ERROR_IS_OK(result)) { 863 933 goto done; 864 934 } -
vendor/current/source3/rpcclient/cmd_test.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/cli_lsa.h" 23 #include "../librpc/gen_ndr/ndr_lsa_c.h" 24 #include "rpc_client/cli_lsarpc.h" 25 #include "../librpc/gen_ndr/ndr_samr.h" 26 #include "../librpc/gen_ndr/winreg.h" 24 27 25 28 static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, … … 27 30 { 28 31 struct rpc_pipe_client *lsa_pipe = NULL, *samr_pipe = NULL; 29 NTSTATUS status = NT_STATUS_UNSUCCESSFUL ;32 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result; 30 33 struct policy_handle pol; 34 struct dcerpc_binding_handle *b; 31 35 32 36 d_printf("testme\n"); … … 46 50 } 47 51 52 b = lsa_pipe->binding_handle; 53 48 54 status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False, 49 55 KEY_QUERY_VALUE, &pol); … … 52 58 goto done; 53 59 54 status = rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);60 status = dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 55 61 56 62 if (!NT_STATUS_IS_OK(status)) 57 63 goto done; 64 if (!NT_STATUS_IS_OK(result)) { 65 status = result; 66 goto done; 67 } 58 68 59 69 done: -
vendor/current/source3/rpcclient/cmd_wkssvc.c
r414 r740 21 21 #include "includes.h" 22 22 #include "rpcclient.h" 23 #include "../librpc/gen_ndr/ cli_wkssvc.h"23 #include "../librpc/gen_ndr/ndr_wkssvc_c.h" 24 24 25 25 static WERROR cmd_wkssvc_wkstagetinfo(struct rpc_pipe_client *cli, … … 33 33 union wkssvc_NetWkstaInfo info; 34 34 const char *server_name; 35 struct dcerpc_binding_handle *b = cli->binding_handle; 35 36 36 37 if (argc > 2) { … … 45 46 server_name = cli->desthost; 46 47 47 status = rpccli_wkssvc_NetWkstaGetInfo(cli, mem_ctx,48 status = dcerpc_wkssvc_NetWkstaGetInfo(b, mem_ctx, 48 49 server_name, 49 50 level, … … 67 68 NTSTATUS status; 68 69 WERROR werr; 70 struct dcerpc_binding_handle *b = cli->binding_handle; 69 71 70 72 server_name = cli->desthost; 71 73 name_buffer = ""; 72 74 73 status = rpccli_wkssvc_NetrGetJoinInformation(cli, mem_ctx,75 status = dcerpc_wkssvc_NetrGetJoinInformation(b, mem_ctx, 74 76 server_name, 75 77 &name_buffer, … … 100 102 NTSTATUS status; 101 103 WERROR werr; 104 struct dcerpc_binding_handle *b = cli->binding_handle; 102 105 103 106 if (argc > 1) { … … 111 114 } 112 115 113 status = rpccli_wkssvc_NetrMessageBufferSend(cli, mem_ctx,116 status = dcerpc_wkssvc_NetrMessageBufferSend(b, mem_ctx, 114 117 server_name, 115 118 message_name, … … 135 138 struct wkssvc_ComputerNamesCtr *ctr = NULL; 136 139 WERROR werr; 140 struct dcerpc_binding_handle *b = cli->binding_handle; 137 141 138 142 server_name = cli->desthost; … … 142 146 } 143 147 144 status = rpccli_wkssvc_NetrEnumerateComputerNames(cli, mem_ctx,148 status = dcerpc_wkssvc_NetrEnumerateComputerNames(b, mem_ctx, 145 149 server_name, 146 150 name_type, 0, … … 171 175 WERROR werr; 172 176 uint32_t i, num_entries, resume_handle; 177 struct dcerpc_binding_handle *b = cli->binding_handle; 173 178 174 179 server_name = cli->desthost; … … 180 185 } 181 186 182 status = rpccli_wkssvc_NetWkstaEnumUsers(cli, mem_ctx, server_name,187 status = dcerpc_wkssvc_NetWkstaEnumUsers(b, mem_ctx, server_name, 183 188 &info, 1000, &num_entries, 184 189 &resume_handle, &werr); -
vendor/current/source3/rpcclient/rpcclient.c
r587 r740 10 10 the Free Software Foundation; either version 3 of the License, or 11 11 (at your option) any later version. 12 12 13 13 This program is distributed in the hope that it will be useful, 14 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 GNU General Public License for more details. 17 17 18 18 You should have received a copy of the GNU General Public License 19 19 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 21 21 22 22 #include "includes.h" 23 #include "popt_common.h" 23 24 #include "rpcclient.h" 24 25 #include "../libcli/auth/libcli_auth.h" 25 #include "../librpc/gen_ndr/cli_lsa.h" 26 27 DOM_SID domain_sid; 28 29 static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; 26 #include "../librpc/gen_ndr/ndr_lsa_c.h" 27 #include "rpc_client/cli_lsarpc.h" 28 #include "../librpc/gen_ndr/ndr_netlogon.h" 29 #include "rpc_client/cli_netlogon.h" 30 #include "../libcli/smbreadline/smbreadline.h" 31 #include "../libcli/security/security.h" 32 #include "passdb.h" 33 #include "libsmb/libsmb.h" 34 35 enum pipe_auth_type_spnego { 36 PIPE_AUTH_TYPE_SPNEGO_NONE = 0, 37 PIPE_AUTH_TYPE_SPNEGO_NTLMSSP, 38 PIPE_AUTH_TYPE_SPNEGO_KRB5 39 }; 40 41 struct dom_sid domain_sid; 42 43 static enum dcerpc_AuthType pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE; 44 static enum pipe_auth_type_spnego pipe_default_auth_spnego_type = 0; 30 45 static enum dcerpc_AuthLevel pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE; 31 46 static unsigned int timeout = 0; … … 83 98 break; 84 99 } 85 100 86 101 for (i=0; commands->cmd_set[i].name; i++) { 87 102 if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) && … … 102 117 } 103 118 commands = commands->next; 104 105 119 } 106 120 … … 117 131 char *command; 118 132 char *p; 119 133 120 134 if (!cmdstr || !(*cmdstr)) 121 135 return NULL; 122 136 123 137 p = strchr_m(*cmdstr, ';'); 124 138 if (p) … … 129 143 else 130 144 *cmdstr = NULL; 131 145 132 146 return command; 133 147 } … … 138 152 { 139 153 struct policy_handle pol; 140 NTSTATUS result = NT_STATUS_OK ;154 NTSTATUS result = NT_STATUS_OK, status; 141 155 static bool got_domain_sid; 142 156 TALLOC_CTX *mem_ctx; 143 157 struct rpc_pipe_client *lsapipe = NULL; 144 158 union lsa_PolicyInformation *info = NULL; 159 struct dcerpc_binding_handle *b; 145 160 146 161 if (got_domain_sid) return; … … 157 172 goto error; 158 173 } 159 174 175 b = lsapipe->binding_handle; 176 160 177 result = rpccli_lsa_open_policy(lsapipe, mem_ctx, True, 161 178 SEC_FLAG_MAXIMUM_ALLOWED, … … 165 182 } 166 183 167 result = rpccli_lsa_QueryInfoPolicy(lsapipe, mem_ctx,184 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx, 168 185 &pol, 169 186 LSA_POLICY_INFO_ACCOUNT_DOMAIN, 170 &info); 187 &info, 188 &result); 189 if (!NT_STATUS_IS_OK(status)) { 190 result = status; 191 goto error; 192 } 171 193 if (!NT_STATUS_IS_OK(result)) { 172 194 goto error; … … 176 198 sid_copy(&domain_sid, info->account_domain.sid); 177 199 178 rpccli_lsa_Close(lsapipe, mem_ctx, &pol);200 dcerpc_lsa_Close(b, mem_ctx, &pol, &result); 179 201 TALLOC_FREE(lsapipe); 180 202 talloc_destroy(mem_ctx); … … 218 240 { 219 241 tmp_set = tmp->cmd_set; 220 242 221 243 if (!StrCaseCmp(argv[1], tmp_set->name)) 222 244 { … … 232 254 printf("\n"); 233 255 } 234 256 235 257 /* drop out of the loop */ 236 258 break; … … 261 283 if (argc == 2) { 262 284 for (tmp = cmd_list; tmp; tmp = tmp->next) { 263 285 264 286 tmp_set = tmp->cmd_set; 265 287 … … 313 335 314 336 if (argc == 2) { 315 DEBUGLEVEL = atoi(argv[1]);337 lp_set_cmdline("log level", argv[1]); 316 338 } 317 339 … … 380 402 int argc, const char **argv) 381 403 { 404 const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]"; 382 405 const char *type = "NTLMSSP"; 383 406 384 407 pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; 385 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;408 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 386 409 387 410 if (argc > 2) { 388 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);411 printf("Usage: %s %s\n", argv[0], p); 389 412 return NT_STATUS_OK; 390 413 } … … 392 415 if (argc == 2) { 393 416 type = argv[1]; 394 if (strequal(type, "NTLMSSP")) { 395 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; 417 if (strequal(type, "KRB5")) { 418 pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5; 419 } else if (strequal(type, "KRB5_SPNEGO")) { 420 pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO; 421 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5; 422 } else if (strequal(type, "NTLMSSP")) { 423 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 396 424 } else if (strequal(type, "NTLMSSP_SPNEGO")) { 397 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 425 pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO; 426 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 398 427 } else if (strequal(type, "SCHANNEL")) { 399 pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;428 pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL; 400 429 } else { 401 430 printf("unknown type %s\n", type); 431 printf("Usage: %s %s\n", argv[0], p); 402 432 return NT_STATUS_INVALID_LEVEL; 403 433 } … … 412 442 int argc, const char **argv) 413 443 { 444 const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]"; 414 445 const char *type = "NTLMSSP"; 415 446 416 447 pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY; 417 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;448 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 418 449 419 450 if (argc > 2) { 420 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);451 printf("Usage: %s %s\n", argv[0], p); 421 452 return NT_STATUS_OK; 422 453 } … … 424 455 if (argc == 2) { 425 456 type = argv[1]; 426 if (strequal(type, "NTLMSSP")) { 427 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; 457 if (strequal(type, "KRB5")) { 458 pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5; 459 } else if (strequal(type, "KRB5_SPNEGO")) { 460 pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO; 461 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5; 462 } else if (strequal(type, "NTLMSSP")) { 463 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 428 464 } else if (strequal(type, "NTLMSSP_SPNEGO")) { 429 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 465 pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO; 466 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 430 467 } else if (strequal(type, "SCHANNEL")) { 431 pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;468 pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL; 432 469 } else { 433 470 printf("unknown type %s\n", type); 471 printf("Usage: %s %s\n", argv[0], p); 434 472 return NT_STATUS_INVALID_LEVEL; 435 473 } … … 455 493 456 494 for (tmp = cmd_list; tmp; tmp = tmp->next) { 457 495 458 496 struct cmd_set *tmp_set; 459 497 … … 478 516 { 479 517 pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE; 480 pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; 518 pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE; 519 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NONE; 481 520 482 521 return cmd_set_ss_level(); … … 488 527 d_printf("Setting schannel - sign and seal\n"); 489 528 pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY; 490 pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;529 pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL; 491 530 492 531 return cmd_set_ss_level(); … … 498 537 d_printf("Setting schannel - sign only\n"); 499 538 pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; 500 pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;539 pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL; 501 540 502 541 return cmd_set_ss_level(); … … 549 588 { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL, NULL, NULL, "Force RPC pipe connections to be sealed with 'schannel'. Assumes valid machine account to this domain controller.", "" }, 550 589 { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL, NULL, NULL, "Force RPC pipe connections to be signed (not sealed) with 'schannel'. Assumes valid machine account to this domain controller.", "" }, 551 { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL, NULL, NULL, "Set timeout (in millise onds) for RPC operations", "" },590 { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL, NULL, NULL, "Set timeout (in milliseconds) for RPC operations", "" }, 552 591 { "transport", RPC_RTYPE_NTSTATUS, cmd_choose_transport, NULL, NULL, NULL, "Choose ncacn transport for RPC operations", "" }, 553 592 { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL, NULL, NULL, "Force RPC pipe connections to have no special properties", "" }, … … 579 618 extern struct cmd_set drsuapi_commands[]; 580 619 extern struct cmd_set eventlog_commands[]; 620 extern struct cmd_set winreg_commands[]; 581 621 582 622 static struct cmd_set *rpcclient_command_list[] = { … … 597 637 drsuapi_commands, 598 638 eventlog_commands, 639 winreg_commands, 599 640 NULL 600 641 }; … … 629 670 NTSTATUS ntresult; 630 671 WERROR wresult; 631 672 632 673 TALLOC_CTX *mem_ctx; 633 674 … … 643 684 if ((cmd_entry->interface != NULL) && (cmd_entry->rpc_pipe == NULL)) { 644 685 switch (pipe_default_auth_type) { 645 case PIPE_AUTH_TYPE_NONE: 646 ntresult = cli_rpc_pipe_open_noauth_transport( 647 cli, default_transport, 648 cmd_entry->interface, 649 &cmd_entry->rpc_pipe); 650 break; 686 case DCERPC_AUTH_TYPE_NONE: 687 ntresult = cli_rpc_pipe_open_noauth_transport( 688 cli, default_transport, 689 cmd_entry->interface, 690 &cmd_entry->rpc_pipe); 691 break; 692 case DCERPC_AUTH_TYPE_SPNEGO: 693 switch (pipe_default_auth_spnego_type) { 651 694 case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP: 652 695 ntresult = cli_rpc_pipe_open_spnego_ntlmssp( 653 cli, cmd_entry->interface,654 default_transport,655 pipe_default_auth_level,656 get_cmdline_auth_info_domain(auth_info),657 get_cmdline_auth_info_username(auth_info),658 get_cmdline_auth_info_password(auth_info),659 &cmd_entry->rpc_pipe);696 cli, cmd_entry->interface, 697 default_transport, 698 pipe_default_auth_level, 699 get_cmdline_auth_info_domain(auth_info), 700 get_cmdline_auth_info_username(auth_info), 701 get_cmdline_auth_info_password(auth_info), 702 &cmd_entry->rpc_pipe); 660 703 break; 661 case PIPE_AUTH_TYPE_NTLMSSP: 662 ntresult = cli_rpc_pipe_open_ntlmssp( 663 cli, cmd_entry->interface, 664 default_transport, 665 pipe_default_auth_level, 666 get_cmdline_auth_info_domain(auth_info), 667 get_cmdline_auth_info_username(auth_info), 668 get_cmdline_auth_info_password(auth_info), 669 &cmd_entry->rpc_pipe); 670 break; 671 case PIPE_AUTH_TYPE_SCHANNEL: 672 ntresult = cli_rpc_pipe_open_schannel( 673 cli, cmd_entry->interface, 674 default_transport, 675 pipe_default_auth_level, 676 get_cmdline_auth_info_domain(auth_info), 677 &cmd_entry->rpc_pipe); 704 case PIPE_AUTH_TYPE_SPNEGO_KRB5: 705 ntresult = cli_rpc_pipe_open_spnego_krb5( 706 cli, cmd_entry->interface, 707 default_transport, 708 pipe_default_auth_level, 709 cli->desthost, 710 NULL, NULL, 711 &cmd_entry->rpc_pipe); 678 712 break; 679 713 default: 680 DEBUG(0, ("Could not initialise %s. Invalid " 681 "auth type %u\n", 682 get_pipe_name_from_syntax( 683 talloc_tos(), 684 cmd_entry->interface), 685 pipe_default_auth_type )); 686 return NT_STATUS_UNSUCCESSFUL; 714 ntresult = NT_STATUS_INTERNAL_ERROR; 715 } 716 break; 717 case DCERPC_AUTH_TYPE_NTLMSSP: 718 ntresult = cli_rpc_pipe_open_ntlmssp( 719 cli, cmd_entry->interface, 720 default_transport, 721 pipe_default_auth_level, 722 get_cmdline_auth_info_domain(auth_info), 723 get_cmdline_auth_info_username(auth_info), 724 get_cmdline_auth_info_password(auth_info), 725 &cmd_entry->rpc_pipe); 726 break; 727 case DCERPC_AUTH_TYPE_SCHANNEL: 728 ntresult = cli_rpc_pipe_open_schannel( 729 cli, cmd_entry->interface, 730 default_transport, 731 pipe_default_auth_level, 732 get_cmdline_auth_info_domain(auth_info), 733 &cmd_entry->rpc_pipe); 734 break; 735 case DCERPC_AUTH_TYPE_KRB5: 736 ntresult = cli_rpc_pipe_open_krb5( 737 cli, cmd_entry->interface, 738 default_transport, 739 pipe_default_auth_level, 740 cli->desthost, 741 NULL, NULL, 742 &cmd_entry->rpc_pipe); 743 break; 744 default: 745 DEBUG(0, ("Could not initialise %s. Invalid " 746 "auth type %u\n", 747 get_pipe_name_from_syntax( 748 talloc_tos(), 749 cmd_entry->interface), 750 pipe_default_auth_type )); 751 return NT_STATUS_UNSUCCESSFUL; 687 752 } 688 753 if (!NT_STATUS_IS_OK(ntresult)) { … … 858 923 /* the following functions are part of the Samba debugging 859 924 facilities. See lib/debug.c */ 860 setup_logging("rpcclient", True);925 setup_logging("rpcclient", DEBUG_STDOUT); 861 926 862 927 rpcclient_auth_info = user_auth_info_init(frame); … … 969 1034 if (binding->flags & DCERPC_SIGN) { 970 1035 pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY; 971 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;1036 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 972 1037 } 973 1038 if (binding->flags & DCERPC_SEAL) { 974 1039 pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY; 975 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;1040 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 976 1041 } 977 1042 if (binding->flags & DCERPC_AUTH_SPNEGO) { 978 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 1043 pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO; 1044 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 979 1045 } 980 1046 if (binding->flags & DCERPC_AUTH_NTLM) { 981 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; 1047 /* If neither Integrity or Privacy are requested then 1048 * Use just Connect level */ 1049 if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { 1050 pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; 1051 } 1052 1053 if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) { 1054 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; 1055 } else { 1056 pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP; 1057 } 982 1058 } 983 1059 if (binding->flags & DCERPC_AUTH_KRB5) { 984 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_KRB5; 1060 /* If neither Integrity or Privacy are requested then 1061 * Use just Connect level */ 1062 if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) { 1063 pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT; 1064 } 1065 1066 if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) { 1067 pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5; 1068 } else { 1069 pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5; 1070 } 985 1071 } 986 1072 … … 1013 1099 get_cmdline_auth_info_password(rpcclient_auth_info), 1014 1100 flags, 1015 get_cmdline_auth_info_signing_state(rpcclient_auth_info), 1016 NULL); 1101 get_cmdline_auth_info_signing_state(rpcclient_auth_info)); 1017 1102 1018 1103 if (!NT_STATUS_IS_OK(nt_status)) { -
vendor/current/source3/rpcclient/rpcclient.h
r414 r740 22 22 #define RPCCLIENT_H 23 23 24 #include "rpc_client/cli_pipe.h" 25 24 26 typedef enum { 25 27 RPC_RTYPE_NTSTATUS = 0,
Note:
See TracChangeset
for help on using the changeset viewer.