Changeset 740 for vendor/current/source3/lib/netapi
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/source3/lib/netapi
- Files:
-
- 1 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/netapi/cm.c
r587 r740 19 19 20 20 #include "includes.h" 21 #include "popt_common.h" 21 22 22 23 #include "lib/netapi/netapi.h" 23 24 #include "lib/netapi/netapi_private.h" 25 #include "libsmb/libsmb.h" 26 #include "rpc_client/cli_pipe.h" 24 27 25 28 /******************************************************************** … … 251 254 return WERR_OK; 252 255 } 256 257 /******************************************************************** 258 ********************************************************************/ 259 260 WERROR libnetapi_get_binding_handle(struct libnetapi_ctx *ctx, 261 const char *server_name, 262 const struct ndr_syntax_id *interface, 263 struct dcerpc_binding_handle **binding_handle) 264 { 265 struct rpc_pipe_client *pipe_cli; 266 WERROR result; 267 268 *binding_handle = NULL; 269 270 result = libnetapi_open_pipe(ctx, server_name, interface, &pipe_cli); 271 if (!W_ERROR_IS_OK(result)) { 272 return result; 273 } 274 275 *binding_handle = pipe_cli->binding_handle; 276 277 return WERR_OK; 278 } -
vendor/current/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
r478 r740 479 479 p = strchr(newname, '.'); 480 480 if (p) { 481 *p = NULL;481 *p = '\0'; 482 482 } 483 483 -
vendor/current/source3/lib/netapi/examples/netlogon/nltest.c
r414 r740 31 31 32 32 enum { 33 OPT_DBFLAG = 1, 33 OPT_SERVER = 1, 34 OPT_DBFLAG, 34 35 OPT_SC_QUERY, 35 36 OPT_SC_RESET, 36 37 OPT_SC_VERIFY, 37 OPT_SC_CHANGE_PWD 38 OPT_SC_CHANGE_PWD, 39 OPT_DSGETDC, 40 OPT_PDC, 41 OPT_DS, 42 OPT_DSP, 43 OPT_GC, 44 OPT_KDC, 45 OPT_TIMESERV, 46 OPT_GTIMESERV, 47 OPT_WS, 48 OPT_NETBIOS, 49 OPT_DNS, 50 OPT_IP, 51 OPT_FORCE, 52 OPT_WRITABLE, 53 OPT_AVOIDSELF, 54 OPT_LDAPONLY, 55 OPT_BACKG, 56 OPT_DS_6, 57 OPT_TRY_NEXT_CLOSEST_SITE, 58 OPT_SITE, 59 OPT_ACCOUNT, 60 OPT_RET_DNS, 61 OPT_RET_NETBIOS, 62 OPT_DSREGDNS 38 63 }; 39 64 … … 41 66 ****************************************************************/ 42 67 43 static void print_ result(uint32_t level,44 uint8_t *buffer)68 static void print_netlogon_info_result(uint32_t level, 69 uint8_t *buffer) 45 70 { 46 71 struct NETLOGON_INFO_1 *i1 = NULL; … … 101 126 ****************************************************************/ 102 127 128 static void print_dc_info_flags(uint32_t flags) 129 { 130 if (flags & DS_PDC_FLAG) 131 printf("PDC "); 132 if (flags & DS_GC_FLAG) 133 printf("GC "); 134 if (flags & DS_DS_FLAG) 135 printf("DS "); 136 if (flags & DS_LDAP_FLAG) 137 printf("LDAP "); 138 if (flags & DS_KDC_FLAG) 139 printf("KDC "); 140 if (flags & DS_TIMESERV_FLAG) 141 printf("TIMESERV "); 142 if (flags & DS_GOOD_TIMESERV_FLAG) 143 printf("GTIMESERV "); 144 if (flags & DS_WRITABLE_FLAG) 145 printf("WRITABLE "); 146 if (flags & DS_DNS_FOREST_FLAG) 147 printf("DNS_FOREST "); 148 if (flags & DS_CLOSEST_FLAG) 149 printf("CLOSE_SITE "); 150 if (flags & DS_FULL_SECRET_DOMAIN_6_FLAG) 151 printf("FULL_SECRET "); 152 /* "WS" */ 153 printf("\n"); 154 } 155 156 /**************************************************************** 157 ****************************************************************/ 158 159 static void print_dc_info(struct DOMAIN_CONTROLLER_INFO *dc_info) 160 { 161 if (dc_info->flags) { 162 printf(" DC: %s\n", dc_info->domain_controller_name); 163 printf(" Address: %s\n", dc_info->domain_controller_address); 164 /* printf(" Dom Guid: %s\n", X(domain_guid)); */ 165 printf(" Dom Name: %s\n", dc_info->domain_name); 166 printf(" Forest Name: %s\n", dc_info->dns_forest_name); 167 printf(" Dc Site Name: %s\n", dc_info->dc_site_name); 168 printf("Our Site Name: %s\n", dc_info->client_site_name); 169 printf(" Flags: "); 170 print_dc_info_flags(dc_info->flags); 171 } else { 172 printf(" DC: %s\n", dc_info->domain_controller_name); 173 printf(" Address: %s\n", dc_info->domain_controller_address); 174 printf(" Dom Name: %s\n", dc_info->domain_name); 175 } 176 } 177 178 /**************************************************************** 179 ****************************************************************/ 180 103 181 int main(int argc, const char **argv) 104 182 { … … 106 184 NET_API_STATUS status; 107 185 struct libnetapi_ctx *ctx = NULL; 108 c onst char *server_name= NULL;186 char *opt_server = NULL; 109 187 char *opt_domain = NULL; 110 188 int opt_dbflag = 0; 111 uint32_t query_level; 189 int opt_pdc = 0; 190 int opt_ds = 0; 191 int opt_dsp = 0; 192 int opt_gc = 0; 193 int opt_kdc = 0; 194 int opt_timeserv = 0; 195 int opt_gtimeserv = 0; 196 int opt_ws = 0; 197 int opt_netbios = 0; 198 int opt_dns = 0; 199 int opt_ip = 0; 200 int opt_force = 0; 201 int opt_writable = 0; 202 int opt_avoidself = 0; 203 int opt_ldaponly = 0; 204 int opt_backg = 0; 205 int opt_ds_6 = 0; 206 int opt_try_next_closest_site = 0; 207 char *opt_site = NULL; 208 char *opt_account = NULL; 209 int opt_ret_dns = 0; 210 int opt_ret_netbios = 0; 211 int opt_dsregdns = 0; 212 uint32_t query_level = 0; 112 213 uint8_t *buffer = NULL; 214 uint32_t flags = 0; 215 struct DOMAIN_CONTROLLER_INFO *dc_info = NULL; 113 216 114 217 poptContext pc; 115 218 struct poptOption long_options[] = { 116 219 POPT_AUTOHELP 220 {"server", 0, POPT_ARG_STRING, &opt_server, OPT_SERVER, "Servername", "SERVER"}, 117 221 {"dbflag", 0, POPT_ARG_INT, &opt_dbflag, OPT_DBFLAG, "New Debug Flag", "HEXFLAGS"}, 118 222 {"sc_query", 0, POPT_ARG_STRING, &opt_domain, OPT_SC_QUERY, "Query secure channel for domain on server", "DOMAIN"}, … … 120 224 {"sc_verify", 0, POPT_ARG_STRING, &opt_domain, OPT_SC_VERIFY, "Verify secure channel for domain on server", "DOMAIN"}, 121 225 {"sc_change_pwd", 0, POPT_ARG_STRING, &opt_domain, OPT_SC_CHANGE_PWD, "Change a secure channel password for domain on server", "DOMAIN"}, 226 {"dsgetdc", 0, POPT_ARG_STRING, &opt_domain, OPT_DSGETDC, "Call DsGetDcName", "DOMAIN"}, 227 {"pdc", 0, POPT_ARG_NONE, &opt_pdc, OPT_PDC, NULL}, 228 {"ds", 0, POPT_ARG_NONE, &opt_ds, OPT_DS, NULL}, 229 {"dsp", 0, POPT_ARG_NONE, &opt_dsp, OPT_DSP, NULL}, 230 {"gc", 0, POPT_ARG_NONE, &opt_gc, OPT_GC, NULL}, 231 {"kdc", 0, POPT_ARG_NONE, &opt_kdc, OPT_KDC, NULL}, 232 {"timeserv", 0, POPT_ARG_NONE, &opt_timeserv, OPT_TIMESERV, NULL}, 233 {"gtimeserv", 0, POPT_ARG_NONE, &opt_gtimeserv, OPT_GTIMESERV, NULL}, 234 {"ws", 0, POPT_ARG_NONE, &opt_ws, OPT_WS, NULL}, 235 {"netbios", 0, POPT_ARG_NONE, &opt_netbios, OPT_NETBIOS, NULL}, 236 {"dns", 0, POPT_ARG_NONE, &opt_dns, OPT_DNS, NULL}, 237 {"ip", 0, POPT_ARG_NONE, &opt_ip, OPT_IP, NULL}, 238 {"force", 0, POPT_ARG_NONE, &opt_force, OPT_FORCE, NULL}, 239 {"writable", 0, POPT_ARG_NONE, &opt_writable, OPT_WRITABLE, NULL}, 240 {"avoidself", 0, POPT_ARG_NONE, &opt_avoidself, OPT_AVOIDSELF, NULL}, 241 {"ldaponly", 0, POPT_ARG_NONE, &opt_ldaponly, OPT_LDAPONLY, NULL}, 242 {"backg", 0, POPT_ARG_NONE, &opt_backg, OPT_BACKG, NULL}, 243 {"ds_6", 0, POPT_ARG_NONE, &opt_ds_6, OPT_DS_6, NULL}, 244 {"try_next_closest_site", 0, POPT_ARG_NONE, &opt_try_next_closest_site, OPT_TRY_NEXT_CLOSEST_SITE, NULL}, 245 {"site", 0, POPT_ARG_STRING, &opt_site, OPT_SITE, "SITE"}, 246 {"account", 0, POPT_ARG_STRING, &opt_account, OPT_ACCOUNT, "ACCOUNT"}, 247 {"ret_dns", 0, POPT_ARG_NONE, &opt_ret_dns, OPT_RET_DNS, NULL}, 248 {"ret_netbios", 0, POPT_ARG_NONE, &opt_ret_netbios, OPT_RET_NETBIOS, NULL}, 249 {"dsregdns", 0, POPT_ARG_NONE, &opt_dsregdns, OPT_DSREGDNS, "Force registration of all DC-specific DNS records"}, 122 250 POPT_COMMON_LIBNETAPI_EXAMPLES 123 251 POPT_TABLEEND … … 131 259 pc = poptGetContext("nltest", argc, argv, long_options, 0); 132 260 133 poptSetOtherOptionHelp(pc, " server_name");261 poptSetOtherOptionHelp(pc, "<options>"); 134 262 while((opt = poptGetNextOpt(pc)) != -1) { 135 263 } 136 137 if (!poptPeekArg(pc)) {138 poptPrintHelp(pc, stderr, 0);139 goto done;140 }141 server_name = poptGetArg(pc);142 264 143 265 if (argc == 1) { … … 146 268 } 147 269 148 if (!server_name || poptGetArg(pc)) {149 poptPrintHelp(pc, stderr, 0);150 goto done;151 }152 153 if ((server_name[0] == '/' && server_name[1] == '/') ||154 (server_name[0] == '\\' && server_name[1] == '\\')) {155 server_name += 2;156 }157 158 270 poptResetContext(pc); 159 271 … … 161 273 switch (opt) { 162 274 275 case OPT_SERVER: 276 277 if ((opt_server[0] == '/' && opt_server[1] == '/') || 278 (opt_server[0] == '\\' && opt_server[1] == '\\')) { 279 opt_server += 2; 280 } 281 282 break; 283 163 284 case OPT_DBFLAG: 164 285 query_level = 1; 165 status = I_NetLogonControl2( server_name,286 status = I_NetLogonControl2(opt_server, 166 287 NETLOGON_CONTROL_SET_DBFLAG, 167 288 query_level, … … 174 295 goto done; 175 296 } 297 298 print_netlogon_info_result(query_level, buffer); 299 176 300 break; 177 301 case OPT_SC_QUERY: 178 302 query_level = 2; 179 status = I_NetLogonControl2( server_name,303 status = I_NetLogonControl2(opt_server, 180 304 NETLOGON_CONTROL_TC_QUERY, 181 305 query_level, … … 188 312 goto done; 189 313 } 314 315 print_netlogon_info_result(query_level, buffer); 316 190 317 break; 191 318 case OPT_SC_VERIFY: 192 319 query_level = 2; 193 status = I_NetLogonControl2( server_name,320 status = I_NetLogonControl2(opt_server, 194 321 NETLOGON_CONTROL_TC_VERIFY, 195 322 query_level, … … 202 329 goto done; 203 330 } 331 332 print_netlogon_info_result(query_level, buffer); 333 204 334 break; 205 335 case OPT_SC_RESET: 206 336 query_level = 2; 207 status = I_NetLogonControl2( server_name,337 status = I_NetLogonControl2(opt_server, 208 338 NETLOGON_CONTROL_REDISCOVER, 209 339 query_level, … … 216 346 goto done; 217 347 } 348 349 print_netlogon_info_result(query_level, buffer); 350 218 351 break; 219 352 case OPT_SC_CHANGE_PWD: 220 353 query_level = 1; 221 status = I_NetLogonControl2( server_name,354 status = I_NetLogonControl2(opt_server, 222 355 NETLOGON_CONTROL_CHANGE_PASSWORD, 223 356 query_level, … … 230 363 goto done; 231 364 } 365 366 print_netlogon_info_result(query_level, buffer); 367 368 break; 369 case OPT_DSREGDNS: 370 query_level = 1; 371 status = I_NetLogonControl2(opt_server, 372 NETLOGON_CONTROL_FORCE_DNS_REG, 373 query_level, 374 NULL, 375 &buffer); 376 if (status != 0) { 377 fprintf(stderr, "I_NetlogonControl failed: Status = %d 0x%x %s\n", 378 status, status, 379 libnetapi_get_error_string(ctx, status)); 380 goto done; 381 } 382 383 print_netlogon_info_result(query_level, buffer); 384 385 break; 386 case OPT_DSGETDC: 387 if (opt_pdc) 388 flags |= DS_PDC_REQUIRED; 389 if (opt_ds) 390 flags |= DS_DIRECTORY_SERVICE_REQUIRED; 391 if (opt_dsp) 392 flags |= DS_DIRECTORY_SERVICE_PREFERRED; 393 if (opt_kdc) 394 flags |= DS_KDC_REQUIRED; 395 if (opt_timeserv) 396 flags |= DS_TIMESERV_REQUIRED; 397 if (opt_gtimeserv) 398 flags |= DS_GOOD_TIMESERV_PREFERRED; 399 if (opt_ws) 400 flags |= DS_WEB_SERVICE_REQUIRED; 401 if (opt_netbios) 402 flags |= DS_IS_FLAT_NAME; 403 if (opt_dns) 404 flags |= DS_IS_DNS_NAME; 405 if (opt_ip) 406 flags |= DS_IP_REQUIRED; 407 if (opt_force) 408 flags |= DS_FORCE_REDISCOVERY; 409 if (opt_writable) 410 flags |= DS_WRITABLE_REQUIRED; 411 if (opt_avoidself) 412 flags |= DS_AVOID_SELF; 413 if (opt_ldaponly) 414 flags |= DS_ONLY_LDAP_NEEDED; 415 if (opt_backg) 416 flags |= DS_BACKGROUND_ONLY; 417 if (opt_ds_6) 418 flags |= DS_DIRECTORY_SERVICE_6_REQUIRED; 419 if (opt_try_next_closest_site) 420 flags |= DS_TRY_NEXTCLOSEST_SITE; 421 if (opt_ret_dns) 422 flags |= DS_RETURN_DNS_NAME; 423 if (opt_ret_netbios) 424 flags |= DS_RETURN_FLAT_NAME; 425 426 status = DsGetDcName(opt_server, 427 opt_domain, 428 NULL, /* domain_guid */ 429 opt_site, 430 flags, 431 &dc_info); 432 if (status != 0) { 433 fprintf(stderr, "DsGetDcName failed: Status = %d 0x%x %s\n", 434 status, status, 435 libnetapi_get_error_string(ctx, status)); 436 goto done; 437 } 438 439 print_dc_info(dc_info); 440 232 441 break; 233 442 default: 234 poptPrintHelp(pc, stderr, 0); 235 goto done; 443 continue; 236 444 } 237 445 } 238 239 print_result(query_level, buffer);240 446 241 447 printf("The command completed successfully\n"); -
vendor/current/source3/lib/netapi/file.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/ cli_srvsvc.h"26 #include "../librpc/gen_ndr/ndr_srvsvc_c.h" 27 27 28 28 /**************************************************************** … … 34 34 WERROR werr; 35 35 NTSTATUS status; 36 struct rpc_pipe_client *pipe_cli = NULL;37 38 werr = libnetapi_ open_pipe(ctx, r->in.server_name,39 &ndr_table_srvsvc.syntax_id,40 &pipe_cli);41 if (!W_ERROR_IS_OK(werr)) { 42 goto done; 43 } 44 45 status = rpccli_srvsvc_NetFileClose(pipe_cli, talloc_tos(),36 struct dcerpc_binding_handle *b; 37 38 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 39 &ndr_table_srvsvc.syntax_id, 40 &b); 41 if (!W_ERROR_IS_OK(werr)) { 42 goto done; 43 } 44 45 status = dcerpc_srvsvc_NetFileClose(b, talloc_tos(), 46 46 r->in.server_name, 47 47 r->in.fileid, … … 114 114 WERROR werr; 115 115 NTSTATUS status; 116 struct rpc_pipe_client *pipe_cli = NULL;117 116 union srvsvc_NetFileInfo info; 118 117 uint32_t num_entries = 0; 118 struct dcerpc_binding_handle *b; 119 119 120 120 if (!r->out.buffer) { … … 130 130 } 131 131 132 werr = libnetapi_ open_pipe(ctx, r->in.server_name,133 &ndr_table_srvsvc.syntax_id,134 &pipe_cli);135 if (!W_ERROR_IS_OK(werr)) { 136 goto done; 137 } 138 139 status = rpccli_srvsvc_NetFileGetInfo(pipe_cli, talloc_tos(),132 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 133 &ndr_table_srvsvc.syntax_id, 134 &b); 135 if (!W_ERROR_IS_OK(werr)) { 136 goto done; 137 } 138 139 status = dcerpc_srvsvc_NetFileGetInfo(b, talloc_tos(), 140 140 r->in.server_name, 141 141 r->in.fileid, … … 143 143 &info, 144 144 &werr); 145 if (!NT_STATUS_IS_OK(status)) { 146 werr = ntstatus_to_werror(status); 147 goto done; 148 } 149 145 150 if (!W_ERROR_IS_OK(werr)) { 146 151 goto done; … … 177 182 WERROR werr; 178 183 NTSTATUS status; 179 struct rpc_pipe_client *pipe_cli = NULL;180 184 struct srvsvc_NetFileInfoCtr info_ctr; 181 185 struct srvsvc_NetFileCtr2 ctr2; … … 183 187 uint32_t num_entries = 0; 184 188 uint32_t i; 189 struct dcerpc_binding_handle *b; 185 190 186 191 if (!r->out.buffer) { … … 196 201 } 197 202 198 werr = libnetapi_ open_pipe(ctx, r->in.server_name,199 &ndr_table_srvsvc.syntax_id,200 &pipe_cli);203 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 204 &ndr_table_srvsvc.syntax_id, 205 &b); 201 206 if (!W_ERROR_IS_OK(werr)) { 202 207 goto done; … … 217 222 } 218 223 219 status = rpccli_srvsvc_NetFileEnum(pipe_cli, talloc_tos(),224 status = dcerpc_srvsvc_NetFileEnum(b, talloc_tos(), 220 225 r->in.server_name, 221 226 r->in.base_path, … … 226 231 r->out.resume_handle, 227 232 &werr); 228 if (NT_STATUS_IS_ERR(status)) { 233 if (!NT_STATUS_IS_OK(status)) { 234 werr = ntstatus_to_werror(status); 235 goto done; 236 } 237 238 if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) { 229 239 goto done; 230 240 } -
vendor/current/source3/lib/netapi/getdc.c
r594 r740 20 20 #include "includes.h" 21 21 22 #include "../librpc/gen_ndr/ndr_netlogon_c.h" 22 23 #include "librpc/gen_ndr/libnetapi.h" 23 24 #include "lib/netapi/netapi.h" 24 25 #include "lib/netapi/netapi_private.h" 25 26 #include "lib/netapi/libnetapi.h" 26 #include "libnet/libnet.h"27 #include "../librpc/gen_ndr/cli_netlogon.h"28 27 29 28 /******************************************************************** … … 42 41 struct NetGetDCName *r) 43 42 { 44 struct rpc_pipe_client *pipe_cli = NULL;45 43 NTSTATUS status; 46 44 WERROR werr; 45 struct dcerpc_binding_handle *b; 47 46 48 werr = libnetapi_ open_pipe(ctx, r->in.server_name,49 &ndr_table_netlogon.syntax_id,50 &pipe_cli);47 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 48 &ndr_table_netlogon.syntax_id, 49 &b); 51 50 if (!W_ERROR_IS_OK(werr)) { 52 51 goto done; 53 52 } 54 53 55 status = rpccli_netr_GetDcName(pipe_cli, talloc_tos(),54 status = dcerpc_netr_GetDcName(b, talloc_tos(), 56 55 r->in.server_name, 57 56 r->in.domain_name, … … 82 81 struct NetGetAnyDCName *r) 83 82 { 84 struct rpc_pipe_client *pipe_cli = NULL;85 83 NTSTATUS status; 86 84 WERROR werr; 85 struct dcerpc_binding_handle *b; 87 86 88 werr = libnetapi_ open_pipe(ctx, r->in.server_name,89 &ndr_table_netlogon.syntax_id,90 &pipe_cli);87 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 88 &ndr_table_netlogon.syntax_id, 89 &b); 91 90 if (!W_ERROR_IS_OK(werr)) { 92 91 goto done; 93 92 } 94 93 95 status = rpccli_netr_GetAnyDCName(pipe_cli, talloc_tos(),94 status = dcerpc_netr_GetAnyDCName(b, talloc_tos(), 96 95 r->in.server_name, 97 96 r->in.domain_name, … … 99 98 &werr); 100 99 if (!NT_STATUS_IS_OK(status)) { 100 werr = ntstatus_to_werror(status); 101 101 goto done; 102 102 } … … 114 114 { 115 115 NTSTATUS status; 116 struct libnetapi_private_ctx *priv; 117 118 priv = talloc_get_type_abort(ctx->private_data, 119 struct libnetapi_private_ctx); 116 120 117 121 status = dsgetdcname(ctx, 118 NULL,122 priv->msg_ctx, 119 123 r->in.domain_name, 120 124 r->in.domain_guid, … … 139 143 WERROR werr; 140 144 NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; 141 struct rpc_pipe_client *pipe_cli = NULL;145 struct dcerpc_binding_handle *b; 142 146 143 werr = libnetapi_ open_pipe(ctx, r->in.server_name,144 &ndr_table_netlogon.syntax_id,145 &pipe_cli);147 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 148 &ndr_table_netlogon.syntax_id, 149 &b); 146 150 if (!W_ERROR_IS_OK(werr)) { 147 151 goto done; 148 152 } 149 153 150 status = rpccli_netr_DsRGetDCName(pipe_cli, 154 status = dcerpc_netr_DsRGetDCNameEx(b, 155 ctx, 156 r->in.server_name, 157 r->in.domain_name, 158 r->in.domain_guid, 159 r->in.site_name, 160 r->in.flags, 161 (struct netr_DsRGetDCNameInfo **)r->out.dc_info, 162 &werr); 163 if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(werr)) { 164 goto done; 165 } 166 167 status = dcerpc_netr_DsRGetDCName(b, 151 168 ctx, 152 169 r->in.server_name, -
vendor/current/source3/lib/netapi/group.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/cli_samr.h" 26 #include "rpc_client/rpc_client.h" 27 #include "../librpc/gen_ndr/ndr_samr_c.h" 28 #include "rpc_client/init_lsa.h" 29 #include "../libcli/security/security.h" 27 30 28 31 /**************************************************************** … … 33 36 { 34 37 struct rpc_pipe_client *pipe_cli = NULL; 35 NTSTATUS status ;38 NTSTATUS status, result; 36 39 WERROR werr; 37 40 struct policy_handle connect_handle, domain_handle, group_handle; … … 39 42 struct dom_sid2 *domain_sid = NULL; 40 43 uint32_t rid = 0; 44 struct dcerpc_binding_handle *b = NULL; 41 45 42 46 struct GROUP_INFO_0 *info0 = NULL; … … 78 82 goto done; 79 83 } 84 85 b = pipe_cli->binding_handle; 80 86 81 87 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 106 112 } 107 113 108 status = rpccli_samr_CreateDomainGroup(pipe_cli, talloc_tos(),114 status = dcerpc_samr_CreateDomainGroup(b, talloc_tos(), 109 115 &domain_handle, 110 116 &lsa_group_name, … … 112 118 SAMR_GROUP_ACCESS_SET_INFO, 113 119 &group_handle, 114 &rid); 115 116 if (!NT_STATUS_IS_OK(status)) { 117 werr = ntstatus_to_werror(status); 120 &rid, 121 &result); 122 123 if (!NT_STATUS_IS_OK(status)) { 124 werr = ntstatus_to_werror(status); 125 goto done; 126 } 127 if (!NT_STATUS_IS_OK(result)) { 128 werr = ntstatus_to_werror(result); 118 129 goto done; 119 130 } … … 125 136 info1->grpi1_comment); 126 137 127 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),138 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 128 139 &group_handle, 129 140 GROUPINFODESCRIPTION, 130 &info); 141 &info, 142 &result); 131 143 } 132 144 break; … … 136 148 info2->grpi2_comment); 137 149 138 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),150 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 139 151 &group_handle, 140 152 GROUPINFODESCRIPTION, 141 &info); 153 &info, 154 &result); 142 155 if (!NT_STATUS_IS_OK(status)) { 143 156 werr = ntstatus_to_werror(status); 144 157 goto failed; 145 158 } 159 if (!NT_STATUS_IS_OK(result)) { 160 werr = ntstatus_to_werror(result); 161 goto failed; 162 } 146 163 } 147 164 148 165 if (info2->grpi2_attributes != 0) { 149 166 info.attributes.attributes = info2->grpi2_attributes; 150 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),167 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 151 168 &group_handle, 152 169 GROUPINFOATTRIBUTES, 153 &info); 170 &info, 171 &result); 154 172 155 173 } … … 160 178 info3->grpi3_comment); 161 179 162 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),180 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 163 181 &group_handle, 164 182 GROUPINFODESCRIPTION, 165 &info); 183 &info, 184 &result); 166 185 if (!NT_STATUS_IS_OK(status)) { 167 186 werr = ntstatus_to_werror(status); 168 187 goto failed; 169 188 } 189 if (!NT_STATUS_IS_OK(result)) { 190 werr = ntstatus_to_werror(result); 191 goto failed; 192 } 170 193 } 171 194 172 195 if (info3->grpi3_attributes != 0) { 173 196 info.attributes.attributes = info3->grpi3_attributes; 174 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),197 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 175 198 &group_handle, 176 199 GROUPINFOATTRIBUTES, 177 &info); 200 &info, 201 &result); 178 202 } 179 203 break; … … 184 208 if (!NT_STATUS_IS_OK(status)) { 185 209 werr = ntstatus_to_werror(status); 210 goto failed; 211 } 212 if (!NT_STATUS_IS_OK(result)) { 213 werr = ntstatus_to_werror(result); 186 214 goto failed; 187 215 } … … 191 219 192 220 failed: 193 rpccli_samr_DeleteDomainGroup(pipe_cli, talloc_tos(),194 &group_handle );221 dcerpc_samr_DeleteDomainGroup(b, talloc_tos(), 222 &group_handle, &result); 195 223 196 224 done: 197 225 if (is_valid_policy_hnd(&group_handle)) { 198 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);226 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 199 227 } 200 228 … … 223 251 { 224 252 struct rpc_pipe_client *pipe_cli = NULL; 225 NTSTATUS status ;253 NTSTATUS status, result; 226 254 WERROR werr; 227 255 struct policy_handle connect_handle, domain_handle, group_handle; … … 229 257 struct dom_sid2 *domain_sid = NULL; 230 258 int i = 0; 259 struct dcerpc_binding_handle *b = NULL; 231 260 232 261 struct samr_Ids rids; 233 262 struct samr_Ids types; 234 263 union samr_GroupInfo *info = NULL; 235 struct samr_Rid TypeArray *rid_array = NULL;264 struct samr_RidAttrArray *rid_array = NULL; 236 265 237 266 ZERO_STRUCT(connect_handle); … … 249 278 goto done; 250 279 } 280 281 b = pipe_cli->binding_handle; 251 282 252 283 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 263 294 init_lsa_String(&lsa_group_name, r->in.group_name); 264 295 265 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),296 status = dcerpc_samr_LookupNames(b, talloc_tos(), 266 297 &domain_handle, 267 298 1, 268 299 &lsa_group_name, 269 300 &rids, 270 &types); 271 if (!NT_STATUS_IS_OK(status)) { 272 werr = ntstatus_to_werror(status); 301 &types, 302 &result); 303 if (!NT_STATUS_IS_OK(status)) { 304 werr = ntstatus_to_werror(status); 305 goto done; 306 } 307 if (!NT_STATUS_IS_OK(result)) { 308 werr = ntstatus_to_werror(result); 273 309 goto done; 274 310 } … … 279 315 } 280 316 281 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),317 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 282 318 &domain_handle, 283 319 SEC_STD_DELETE | … … 287 323 SAMR_GROUP_ACCESS_LOOKUP_INFO, 288 324 rids.ids[0], 289 &group_handle); 290 if (!NT_STATUS_IS_OK(status)) { 291 werr = ntstatus_to_werror(status); 292 goto done; 293 } 294 295 status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(), 325 &group_handle, 326 &result); 327 if (!NT_STATUS_IS_OK(status)) { 328 werr = ntstatus_to_werror(status); 329 goto done; 330 } 331 if (!NT_STATUS_IS_OK(result)) { 332 werr = ntstatus_to_werror(result); 333 goto done; 334 } 335 336 status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(), 296 337 &group_handle, 297 338 GROUPINFOATTRIBUTES, 298 &info); 299 if (!NT_STATUS_IS_OK(status)) { 300 werr = ntstatus_to_werror(status); 339 &info, 340 &result); 341 if (!NT_STATUS_IS_OK(status)) { 342 werr = ntstatus_to_werror(status); 343 goto done; 344 } 345 if (!NT_STATUS_IS_OK(result)) { 346 werr = ntstatus_to_werror(result); 301 347 goto done; 302 348 } … … 309 355 } 310 356 #endif 311 status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(),357 status = dcerpc_samr_QueryGroupMember(b, talloc_tos(), 312 358 &group_handle, 313 &rid_array); 314 if (!NT_STATUS_IS_OK(status)) { 315 werr = ntstatus_to_werror(status); 359 &rid_array, 360 &result); 361 if (!NT_STATUS_IS_OK(status)) { 362 werr = ntstatus_to_werror(status); 363 goto done; 364 } 365 if (!NT_STATUS_IS_OK(result)) { 366 werr = ntstatus_to_werror(result); 316 367 goto done; 317 368 } … … 321 372 struct samr_Ids member_types; 322 373 323 status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),374 status = dcerpc_samr_LookupRids(b, talloc_tos(), 324 375 &domain_handle, 325 376 rid_array->count, 326 377 rid_array->rids, 327 378 &names, 328 &member_types); 329 if (!NT_STATUS_IS_OK(status)) { 330 werr = ntstatus_to_werror(status); 379 &member_types, 380 &result); 381 if (!NT_STATUS_IS_OK(status)) { 382 werr = ntstatus_to_werror(status); 383 goto done; 384 } 385 if (!NT_STATUS_IS_OK(result)) { 386 werr = ntstatus_to_werror(result); 331 387 goto done; 332 388 } … … 335 391 for (i=0; i < rid_array->count; i++) { 336 392 337 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),393 status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(), 338 394 &group_handle, 339 rid_array->rids[i]); 395 rid_array->rids[i], 396 &result); 340 397 if (!NT_STATUS_IS_OK(status)) { 341 398 werr = ntstatus_to_werror(status); 342 399 goto done; 343 400 } 344 } 345 346 status = rpccli_samr_DeleteDomainGroup(pipe_cli, talloc_tos(), 347 &group_handle); 348 if (!NT_STATUS_IS_OK(status)) { 349 werr = ntstatus_to_werror(status); 401 if (!NT_STATUS_IS_OK(result)) { 402 werr = ntstatus_to_werror(result); 403 goto done; 404 } 405 } 406 407 status = dcerpc_samr_DeleteDomainGroup(b, talloc_tos(), 408 &group_handle, 409 &result); 410 if (!NT_STATUS_IS_OK(status)) { 411 werr = ntstatus_to_werror(status); 412 goto done; 413 } 414 if (!NT_STATUS_IS_OK(result)) { 415 werr = ntstatus_to_werror(result); 350 416 goto done; 351 417 } … … 357 423 done: 358 424 if (is_valid_policy_hnd(&group_handle)) { 359 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);425 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 360 426 } 361 427 … … 384 450 { 385 451 struct rpc_pipe_client *pipe_cli = NULL; 386 NTSTATUS status ;452 NTSTATUS status, result; 387 453 WERROR werr; 388 454 struct policy_handle connect_handle, domain_handle, group_handle; 389 455 struct lsa_String lsa_group_name; 390 456 struct dom_sid2 *domain_sid = NULL; 457 struct dcerpc_binding_handle *b = NULL; 391 458 392 459 struct samr_Ids rids; … … 415 482 } 416 483 484 b = pipe_cli->binding_handle; 485 417 486 werr = libnetapi_samr_open_domain(ctx, pipe_cli, 418 487 SAMR_ACCESS_ENUM_DOMAINS | … … 428 497 init_lsa_String(&lsa_group_name, r->in.group_name); 429 498 430 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),499 status = dcerpc_samr_LookupNames(b, talloc_tos(), 431 500 &domain_handle, 432 501 1, 433 502 &lsa_group_name, 434 503 &rids, 435 &types); 436 if (!NT_STATUS_IS_OK(status)) { 437 werr = ntstatus_to_werror(status); 504 &types, 505 &result); 506 if (!NT_STATUS_IS_OK(status)) { 507 werr = ntstatus_to_werror(status); 508 goto done; 509 } 510 if (!NT_STATUS_IS_OK(result)) { 511 werr = ntstatus_to_werror(result); 438 512 goto done; 439 513 } … … 444 518 } 445 519 446 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),520 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 447 521 &domain_handle, 448 522 SAMR_GROUP_ACCESS_SET_INFO | 449 523 SAMR_GROUP_ACCESS_LOOKUP_INFO, 450 524 rids.ids[0], 451 &group_handle); 452 if (!NT_STATUS_IS_OK(status)) { 453 werr = ntstatus_to_werror(status); 525 &group_handle, 526 &result); 527 if (!NT_STATUS_IS_OK(status)) { 528 werr = ntstatus_to_werror(status); 529 goto done; 530 } 531 if (!NT_STATUS_IS_OK(result)) { 532 werr = ntstatus_to_werror(result); 454 533 goto done; 455 534 } … … 459 538 g0 = (struct GROUP_INFO_0 *)r->in.buffer; 460 539 init_lsa_String(&info.name, g0->grpi0_name); 461 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),540 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 462 541 &group_handle, 463 542 GROUPINFONAME, 464 &info); 543 &info, 544 &result); 465 545 break; 466 546 case 1: 467 547 g1 = (struct GROUP_INFO_1 *)r->in.buffer; 468 548 init_lsa_String(&info.description, g1->grpi1_comment); 469 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),549 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 470 550 &group_handle, 471 551 GROUPINFODESCRIPTION, 472 &info); 552 &info, 553 &result); 473 554 break; 474 555 case 2: 475 556 g2 = (struct GROUP_INFO_2 *)r->in.buffer; 476 557 init_lsa_String(&info.description, g2->grpi2_comment); 477 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),558 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 478 559 &group_handle, 479 560 GROUPINFODESCRIPTION, 480 &info); 561 &info, 562 &result); 481 563 if (!NT_STATUS_IS_OK(status)) { 482 564 werr = ntstatus_to_werror(status); 483 565 goto done; 484 566 } 567 if (!NT_STATUS_IS_OK(result)) { 568 werr = ntstatus_to_werror(result); 569 goto done; 570 } 571 485 572 info.attributes.attributes = g2->grpi2_attributes; 486 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),573 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 487 574 &group_handle, 488 575 GROUPINFOATTRIBUTES, 489 &info); 576 &info, 577 &result); 490 578 break; 491 579 case 3: 492 580 g3 = (struct GROUP_INFO_3 *)r->in.buffer; 493 581 init_lsa_String(&info.description, g3->grpi3_comment); 494 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),582 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 495 583 &group_handle, 496 584 GROUPINFODESCRIPTION, 497 &info); 585 &info, 586 &result); 498 587 if (!NT_STATUS_IS_OK(status)) { 499 588 werr = ntstatus_to_werror(status); 500 589 goto done; 501 590 } 591 if (!NT_STATUS_IS_OK(result)) { 592 werr = ntstatus_to_werror(result); 593 goto done; 594 } 595 502 596 info.attributes.attributes = g3->grpi3_attributes; 503 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),597 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 504 598 &group_handle, 505 599 GROUPINFOATTRIBUTES, 506 &info); 600 &info, 601 &result); 507 602 break; 508 603 case 1002: 509 604 g1002 = (struct GROUP_INFO_1002 *)r->in.buffer; 510 605 init_lsa_String(&info.description, g1002->grpi1002_comment); 511 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),606 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 512 607 &group_handle, 513 608 GROUPINFODESCRIPTION, 514 &info); 609 &info, 610 &result); 515 611 break; 516 612 case 1005: 517 613 g1005 = (struct GROUP_INFO_1005 *)r->in.buffer; 518 614 info.attributes.attributes = g1005->grpi1005_attributes; 519 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),615 status = dcerpc_samr_SetGroupInfo(b, talloc_tos(), 520 616 &group_handle, 521 617 GROUPINFOATTRIBUTES, 522 &info); 618 &info, 619 &result); 523 620 break; 524 621 default: … … 531 628 goto done; 532 629 } 630 if (!NT_STATUS_IS_OK(result)) { 631 werr = ntstatus_to_werror(result); 632 goto done; 633 } 533 634 534 635 werr = WERR_OK; … … 536 637 done: 537 638 if (is_valid_policy_hnd(&group_handle)) { 538 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);639 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 539 640 } 540 641 … … 603 704 info3.grpi3_comment = info->description.string; 604 705 info3.grpi3_attributes = info->attributes; 605 info3.grpi3_group_sid = (struct domsid *) sid_dup_talloc(mem_ctx, &sid);706 info3.grpi3_group_sid = (struct domsid *)dom_sid_dup(mem_ctx, &sid); 606 707 607 708 *buffer = (uint8_t *)talloc_memdup(mem_ctx, &info3, sizeof(info3)); … … 624 725 { 625 726 struct rpc_pipe_client *pipe_cli = NULL; 626 NTSTATUS status ;727 NTSTATUS status, result; 627 728 WERROR werr; 628 729 struct policy_handle connect_handle, domain_handle, group_handle; 629 730 struct lsa_String lsa_group_name; 630 731 struct dom_sid2 *domain_sid = NULL; 732 struct dcerpc_binding_handle *b = NULL; 631 733 632 734 struct samr_Ids rids; … … 649 751 goto done; 650 752 } 753 754 b = pipe_cli->binding_handle; 651 755 652 756 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 663 767 init_lsa_String(&lsa_group_name, r->in.group_name); 664 768 665 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),769 status = dcerpc_samr_LookupNames(b, talloc_tos(), 666 770 &domain_handle, 667 771 1, 668 772 &lsa_group_name, 669 773 &rids, 670 &types); 671 if (!NT_STATUS_IS_OK(status)) { 672 werr = ntstatus_to_werror(status); 774 &types, 775 &result); 776 if (!NT_STATUS_IS_OK(status)) { 777 werr = ntstatus_to_werror(status); 778 goto done; 779 } 780 if (!NT_STATUS_IS_OK(result)) { 781 werr = ntstatus_to_werror(result); 673 782 goto done; 674 783 } … … 679 788 } 680 789 681 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),790 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 682 791 &domain_handle, 683 792 SAMR_GROUP_ACCESS_LOOKUP_INFO, 684 793 rids.ids[0], 685 &group_handle); 686 if (!NT_STATUS_IS_OK(status)) { 687 werr = ntstatus_to_werror(status); 688 goto done; 689 } 690 691 status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(), 794 &group_handle, 795 &result); 796 if (!NT_STATUS_IS_OK(status)) { 797 werr = ntstatus_to_werror(status); 798 goto done; 799 } 800 if (!NT_STATUS_IS_OK(result)) { 801 werr = ntstatus_to_werror(result); 802 goto done; 803 } 804 805 status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(), 692 806 &group_handle, 693 807 GROUPINFOALL2, 694 &info); 695 if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { 696 status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(), 808 &info, 809 &result); 810 if (!NT_STATUS_IS_OK(status)) { 811 werr = ntstatus_to_werror(status); 812 goto done; 813 } 814 815 if (NT_STATUS_EQUAL(result, NT_STATUS_INVALID_INFO_CLASS)) { 816 status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(), 697 817 &group_handle, 698 818 GROUPINFOALL, 699 &info); 819 &info, 820 &result); 700 821 group_info_all = true; 701 } 702 703 if (!NT_STATUS_IS_OK(status)) { 704 werr = ntstatus_to_werror(status); 822 if (!NT_STATUS_IS_OK(status)) { 823 werr = ntstatus_to_werror(status); 824 goto done; 825 } 826 } 827 828 if (!NT_STATUS_IS_OK(result)) { 829 werr = ntstatus_to_werror(result); 705 830 goto done; 706 831 } … … 715 840 done: 716 841 if (is_valid_policy_hnd(&group_handle)) { 717 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);842 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 718 843 } 719 844 … … 742 867 { 743 868 struct rpc_pipe_client *pipe_cli = NULL; 744 NTSTATUS status ;869 NTSTATUS status, result; 745 870 WERROR werr; 746 871 struct policy_handle connect_handle, domain_handle, group_handle; 747 872 struct lsa_String lsa_group_name, lsa_user_name; 748 873 struct dom_sid2 *domain_sid = NULL; 874 struct dcerpc_binding_handle *b = NULL; 749 875 750 876 struct samr_Ids rids; … … 765 891 goto done; 766 892 } 893 894 b = pipe_cli->binding_handle; 767 895 768 896 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 779 907 init_lsa_String(&lsa_group_name, r->in.group_name); 780 908 781 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),909 status = dcerpc_samr_LookupNames(b, talloc_tos(), 782 910 &domain_handle, 783 911 1, 784 912 &lsa_group_name, 785 913 &rids, 786 &types); 787 if (!NT_STATUS_IS_OK(status)) { 914 &types, 915 &result); 916 if (!NT_STATUS_IS_OK(status)) { 917 werr = ntstatus_to_werror(status); 918 goto done; 919 } 920 if (!NT_STATUS_IS_OK(result)) { 788 921 werr = WERR_GROUPNOTFOUND; 789 922 goto done; … … 795 928 } 796 929 797 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),930 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 798 931 &domain_handle, 799 932 SAMR_GROUP_ACCESS_ADD_MEMBER, 800 933 rids.ids[0], 801 &group_handle); 802 if (!NT_STATUS_IS_OK(status)) { 803 werr = ntstatus_to_werror(status); 934 &group_handle, 935 &result); 936 if (!NT_STATUS_IS_OK(status)) { 937 werr = ntstatus_to_werror(status); 938 goto done; 939 } 940 if (!NT_STATUS_IS_OK(result)) { 941 werr = ntstatus_to_werror(result); 804 942 goto done; 805 943 } … … 807 945 init_lsa_String(&lsa_user_name, r->in.user_name); 808 946 809 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),947 status = dcerpc_samr_LookupNames(b, talloc_tos(), 810 948 &domain_handle, 811 949 1, 812 950 &lsa_user_name, 813 951 &rids, 814 &types); 815 if (!NT_STATUS_IS_OK(status)) { 952 &types, 953 &result); 954 if (!NT_STATUS_IS_OK(status)) { 955 werr = ntstatus_to_werror(status); 956 goto done; 957 } 958 if (!NT_STATUS_IS_OK(result)) { 816 959 werr = WERR_USER_NOT_FOUND; 817 960 goto done; … … 823 966 } 824 967 825 status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(),968 status = dcerpc_samr_AddGroupMember(b, talloc_tos(), 826 969 &group_handle, 827 970 rids.ids[0], 828 7); /* why ? */ 829 if (!NT_STATUS_IS_OK(status)) { 830 werr = ntstatus_to_werror(status); 971 7, /* why ? */ 972 &result); 973 if (!NT_STATUS_IS_OK(status)) { 974 werr = ntstatus_to_werror(status); 975 goto done; 976 } 977 if (!NT_STATUS_IS_OK(result)) { 978 werr = ntstatus_to_werror(result); 831 979 goto done; 832 980 } … … 836 984 done: 837 985 if (is_valid_policy_hnd(&group_handle)) { 838 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);986 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 839 987 } 840 988 … … 863 1011 { 864 1012 struct rpc_pipe_client *pipe_cli = NULL; 865 NTSTATUS status ;1013 NTSTATUS status, result; 866 1014 WERROR werr; 867 1015 struct policy_handle connect_handle, domain_handle, group_handle; 868 1016 struct lsa_String lsa_group_name, lsa_user_name; 869 1017 struct dom_sid2 *domain_sid = NULL; 1018 struct dcerpc_binding_handle *b = NULL; 870 1019 871 1020 struct samr_Ids rids; … … 886 1035 goto done; 887 1036 } 1037 1038 b = pipe_cli->binding_handle; 888 1039 889 1040 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 900 1051 init_lsa_String(&lsa_group_name, r->in.group_name); 901 1052 902 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1053 status = dcerpc_samr_LookupNames(b, talloc_tos(), 903 1054 &domain_handle, 904 1055 1, 905 1056 &lsa_group_name, 906 1057 &rids, 907 &types); 908 if (!NT_STATUS_IS_OK(status)) { 1058 &types, 1059 &result); 1060 if (!NT_STATUS_IS_OK(status)) { 1061 werr = ntstatus_to_werror(status); 1062 goto done; 1063 } 1064 if (!NT_STATUS_IS_OK(result)) { 909 1065 werr = WERR_GROUPNOTFOUND; 910 1066 goto done; … … 916 1072 } 917 1073 918 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),1074 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 919 1075 &domain_handle, 920 1076 SAMR_GROUP_ACCESS_REMOVE_MEMBER, 921 1077 rids.ids[0], 922 &group_handle); 923 if (!NT_STATUS_IS_OK(status)) { 924 werr = ntstatus_to_werror(status); 1078 &group_handle, 1079 &result); 1080 if (!NT_STATUS_IS_OK(status)) { 1081 werr = ntstatus_to_werror(status); 1082 goto done; 1083 } 1084 if (!NT_STATUS_IS_OK(result)) { 1085 werr = ntstatus_to_werror(result); 925 1086 goto done; 926 1087 } … … 928 1089 init_lsa_String(&lsa_user_name, r->in.user_name); 929 1090 930 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1091 status = dcerpc_samr_LookupNames(b, talloc_tos(), 931 1092 &domain_handle, 932 1093 1, 933 1094 &lsa_user_name, 934 1095 &rids, 935 &types); 936 if (!NT_STATUS_IS_OK(status)) { 1096 &types, 1097 &result); 1098 if (!NT_STATUS_IS_OK(status)) { 1099 werr = ntstatus_to_werror(status); 1100 goto done; 1101 } 1102 1103 if (!NT_STATUS_IS_OK(result)) { 937 1104 werr = WERR_USER_NOT_FOUND; 938 1105 goto done; … … 944 1111 } 945 1112 946 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),1113 status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(), 947 1114 &group_handle, 948 rids.ids[0]); 949 if (!NT_STATUS_IS_OK(status)) { 950 werr = ntstatus_to_werror(status); 1115 rids.ids[0], 1116 &result); 1117 if (!NT_STATUS_IS_OK(status)) { 1118 werr = ntstatus_to_werror(status); 1119 goto done; 1120 } 1121 if (!NT_STATUS_IS_OK(result)) { 1122 werr = ntstatus_to_werror(result); 951 1123 goto done; 952 1124 } … … 956 1128 done: 957 1129 if (is_valid_policy_hnd(&group_handle)) { 958 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);1130 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 959 1131 } 960 1132 … … 1086 1258 g3[i].grpi3_comment = talloc_strdup(mem_ctx, 1087 1259 groups->entries[i].description.string); 1088 g3[i].grpi3_group_sid = (struct domsid *) sid_dup_talloc(mem_ctx, &sid);1260 g3[i].grpi3_group_sid = (struct domsid *)dom_sid_dup(mem_ctx, &sid); 1089 1261 g3[i].grpi3_attributes = groups->entries[i].acct_flags; 1090 1262 W_ERROR_HAVE_NO_MEMORY(g3[i].grpi3_name); … … 1138 1310 union samr_DispInfo info; 1139 1311 union samr_DomainInfo *domain_info = NULL; 1312 struct dcerpc_binding_handle *b = NULL; 1140 1313 1141 1314 uint32_t total_size = 0; 1142 1315 uint32_t returned_size = 0; 1143 1316 1317 NTSTATUS result = NT_STATUS_OK; 1144 1318 NTSTATUS status = NT_STATUS_OK; 1145 1319 WERROR werr, tmp_werr; … … 1164 1338 goto done; 1165 1339 } 1340 1341 b = pipe_cli->binding_handle; 1166 1342 1167 1343 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 1178 1354 } 1179 1355 1180 status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),1356 status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(), 1181 1357 &domain_handle, 1182 1358 2, 1183 &domain_info); 1184 if (!NT_STATUS_IS_OK(status)) { 1185 werr = ntstatus_to_werror(status); 1359 &domain_info, 1360 &result); 1361 if (!NT_STATUS_IS_OK(status)) { 1362 werr = ntstatus_to_werror(status); 1363 goto done; 1364 } 1365 if (!NT_STATUS_IS_OK(result)) { 1366 werr = ntstatus_to_werror(result); 1186 1367 goto done; 1187 1368 } … … 1191 1372 } 1192 1373 1193 status = rpccli_samr_QueryDisplayInfo2(pipe_cli,1374 status = dcerpc_samr_QueryDisplayInfo2(b, 1194 1375 ctx, 1195 1376 &domain_handle, … … 1201 1382 &total_size, 1202 1383 &returned_size, 1203 &info); 1204 werr = ntstatus_to_werror(status); 1205 if (NT_STATUS_IS_ERR(status)) { 1384 &info, 1385 &result); 1386 if (!NT_STATUS_IS_OK(status)) { 1387 werr = ntstatus_to_werror(status); 1388 goto done; 1389 } 1390 1391 werr = ntstatus_to_werror(result); 1392 if (NT_STATUS_IS_ERR(result)) { 1206 1393 goto done; 1207 1394 } … … 1225 1412 done: 1226 1413 /* if last query */ 1227 if (NT_STATUS_IS_OK( status) ||1228 NT_STATUS_IS_ERR( status)) {1414 if (NT_STATUS_IS_OK(result) || 1415 NT_STATUS_IS_ERR(result)) { 1229 1416 1230 1417 if (ctx->disable_policy_handle_cache) { … … 1259 1446 struct dom_sid2 *domain_sid = NULL; 1260 1447 struct samr_Ids group_rids, name_types; 1261 struct samr_Rid TypeArray *rid_array = NULL;1448 struct samr_RidAttrArray *rid_array = NULL; 1262 1449 struct lsa_Strings names; 1263 1450 struct samr_Ids member_types; 1451 struct dcerpc_binding_handle *b = NULL; 1264 1452 1265 1453 int i; … … 1267 1455 1268 1456 NTSTATUS status = NT_STATUS_OK; 1457 NTSTATUS result = NT_STATUS_OK; 1269 1458 WERROR werr; 1270 1459 … … 1295 1484 goto done; 1296 1485 } 1486 1487 b = pipe_cli->binding_handle; 1297 1488 1298 1489 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 1309 1500 init_lsa_String(&lsa_account_name, r->in.group_name); 1310 1501 1311 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1502 status = dcerpc_samr_LookupNames(b, talloc_tos(), 1312 1503 &domain_handle, 1313 1504 1, 1314 1505 &lsa_account_name, 1315 1506 &group_rids, 1316 &name_types); 1317 if (!NT_STATUS_IS_OK(status)) { 1318 werr = ntstatus_to_werror(status); 1319 goto done; 1320 } 1321 1322 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(), 1507 &name_types, 1508 &result); 1509 if (!NT_STATUS_IS_OK(status)) { 1510 werr = ntstatus_to_werror(status); 1511 goto done; 1512 } 1513 if (!NT_STATUS_IS_OK(result)) { 1514 werr = ntstatus_to_werror(result); 1515 goto done; 1516 } 1517 1518 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 1323 1519 &domain_handle, 1324 1520 SAMR_GROUP_ACCESS_GET_MEMBERS, 1325 1521 group_rids.ids[0], 1326 &group_handle); 1327 if (!NT_STATUS_IS_OK(status)) { 1328 werr = ntstatus_to_werror(status); 1329 goto done; 1330 } 1331 1332 status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(), 1522 &group_handle, 1523 &result); 1524 if (!NT_STATUS_IS_OK(status)) { 1525 werr = ntstatus_to_werror(status); 1526 goto done; 1527 } 1528 if (!NT_STATUS_IS_OK(result)) { 1529 werr = ntstatus_to_werror(result); 1530 goto done; 1531 } 1532 1533 status = dcerpc_samr_QueryGroupMember(b, talloc_tos(), 1333 1534 &group_handle, 1334 &rid_array); 1335 if (!NT_STATUS_IS_OK(status)) { 1336 werr = ntstatus_to_werror(status); 1337 goto done; 1338 } 1339 1340 status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(), 1535 &rid_array, 1536 &result); 1537 if (!NT_STATUS_IS_OK(status)) { 1538 werr = ntstatus_to_werror(status); 1539 goto done; 1540 } 1541 if (!NT_STATUS_IS_OK(result)) { 1542 werr = ntstatus_to_werror(result); 1543 goto done; 1544 } 1545 1546 status = dcerpc_samr_LookupRids(b, talloc_tos(), 1341 1547 &domain_handle, 1342 1548 rid_array->count, 1343 1549 rid_array->rids, 1344 1550 &names, 1345 &member_types); 1346 if (!NT_STATUS_IS_OK(status)) { 1347 werr = ntstatus_to_werror(status); 1551 &member_types, 1552 &result); 1553 if (!NT_STATUS_IS_OK(status)) { 1554 werr = ntstatus_to_werror(status); 1555 goto done; 1556 } 1557 if (!NT_STATUS_IS_OK(result)) { 1558 werr = ntstatus_to_werror(result); 1348 1559 goto done; 1349 1560 } … … 1374 1585 done: 1375 1586 if (is_valid_policy_hnd(&group_handle)) { 1376 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);1587 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 1377 1588 } 1378 1589 … … 1407 1618 struct samr_Ids user_rids, name_types; 1408 1619 struct samr_Ids group_rids, group_types; 1409 struct samr_Rid TypeArray *rid_array = NULL;1620 struct samr_RidAttrArray *rid_array = NULL; 1410 1621 struct lsa_String *lsa_names = NULL; 1622 struct dcerpc_binding_handle *b = NULL; 1411 1623 1412 1624 uint32_t *add_rids = NULL; … … 1416 1628 1417 1629 uint32_t *member_rids = NULL; 1418 size_t num_member_rids = 0;1419 1630 1420 1631 struct GROUP_USERS_INFO_0 *i0 = NULL; … … 1424 1635 1425 1636 NTSTATUS status = NT_STATUS_OK; 1637 NTSTATUS result = NT_STATUS_OK; 1426 1638 WERROR werr; 1427 1639 … … 1447 1659 goto done; 1448 1660 } 1661 1662 b = pipe_cli->binding_handle; 1449 1663 1450 1664 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 1461 1675 init_lsa_String(&lsa_account_name, r->in.group_name); 1462 1676 1463 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1677 status = dcerpc_samr_LookupNames(b, talloc_tos(), 1464 1678 &domain_handle, 1465 1679 1, 1466 1680 &lsa_account_name, 1467 1681 &group_rids, 1468 &group_types); 1469 if (!NT_STATUS_IS_OK(status)) { 1470 werr = ntstatus_to_werror(status); 1471 goto done; 1472 } 1473 1474 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(), 1682 &group_types, 1683 &result); 1684 if (!NT_STATUS_IS_OK(status)) { 1685 werr = ntstatus_to_werror(status); 1686 goto done; 1687 } 1688 if (!NT_STATUS_IS_OK(result)) { 1689 werr = ntstatus_to_werror(result); 1690 goto done; 1691 } 1692 1693 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 1475 1694 &domain_handle, 1476 1695 SAMR_GROUP_ACCESS_GET_MEMBERS | … … 1479 1698 SAMR_GROUP_ACCESS_LOOKUP_INFO, 1480 1699 group_rids.ids[0], 1481 &group_handle); 1482 if (!NT_STATUS_IS_OK(status)) { 1483 werr = ntstatus_to_werror(status); 1484 goto done; 1485 } 1486 1487 status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(), 1700 &group_handle, 1701 &result); 1702 if (!NT_STATUS_IS_OK(status)) { 1703 werr = ntstatus_to_werror(status); 1704 goto done; 1705 } 1706 if (!NT_STATUS_IS_OK(result)) { 1707 werr = ntstatus_to_werror(result); 1708 goto done; 1709 } 1710 1711 status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(), 1488 1712 &group_handle, 1489 1713 GROUPINFOATTRIBUTES, 1490 &group_info); 1491 if (!NT_STATUS_IS_OK(status)) { 1492 werr = ntstatus_to_werror(status); 1714 &group_info, 1715 &result); 1716 if (!NT_STATUS_IS_OK(status)) { 1717 werr = ntstatus_to_werror(status); 1718 goto done; 1719 } 1720 if (!NT_STATUS_IS_OK(result)) { 1721 werr = ntstatus_to_werror(result); 1493 1722 goto done; 1494 1723 } … … 1523 1752 } 1524 1753 1525 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1754 status = dcerpc_samr_LookupNames(b, talloc_tos(), 1526 1755 &domain_handle, 1527 1756 r->in.num_entries, 1528 1757 lsa_names, 1529 1758 &user_rids, 1530 &name_types); 1531 if (!NT_STATUS_IS_OK(status)) { 1532 werr = ntstatus_to_werror(status); 1759 &name_types, 1760 &result); 1761 if (!NT_STATUS_IS_OK(status)) { 1762 werr = ntstatus_to_werror(status); 1763 goto done; 1764 } 1765 if (!NT_STATUS_IS_OK(result)) { 1766 werr = ntstatus_to_werror(result); 1533 1767 goto done; 1534 1768 } 1535 1769 1536 1770 member_rids = user_rids.ids; 1537 num_member_rids = user_rids.count; 1538 1539 status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(), 1771 1772 status = dcerpc_samr_QueryGroupMember(b, talloc_tos(), 1540 1773 &group_handle, 1541 &rid_array); 1542 if (!NT_STATUS_IS_OK(status)) { 1543 werr = ntstatus_to_werror(status); 1774 &rid_array, 1775 &result); 1776 if (!NT_STATUS_IS_OK(status)) { 1777 werr = ntstatus_to_werror(status); 1778 goto done; 1779 } 1780 if (!NT_STATUS_IS_OK(result)) { 1781 werr = ntstatus_to_werror(result); 1544 1782 goto done; 1545 1783 } … … 1588 1826 1589 1827 for (i=0; i < num_add_rids; i++) { 1590 status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(),1828 status = dcerpc_samr_AddGroupMember(b, talloc_tos(), 1591 1829 &group_handle, 1592 1830 add_rids[i], 1593 7 /* ? */); 1831 7 /* ? */, 1832 &result); 1594 1833 if (!NT_STATUS_IS_OK(status)) { 1595 1834 werr = ntstatus_to_werror(status); 1596 1835 goto done; 1597 1836 } 1837 if (!NT_STATUS_IS_OK(result)) { 1838 werr = ntstatus_to_werror(result); 1839 goto done; 1840 } 1598 1841 } 1599 1842 … … 1601 1844 1602 1845 for (i=0; i < num_del_rids; i++) { 1603 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),1846 status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(), 1604 1847 &group_handle, 1605 del_rids[i]); 1848 del_rids[i], 1849 &result); 1606 1850 if (!NT_STATUS_IS_OK(status)) { 1607 1851 werr = ntstatus_to_werror(status); 1608 1852 goto done; 1609 1853 } 1854 if (!NT_STATUS_IS_OK(result)) { 1855 werr = ntstatus_to_werror(result); 1856 goto done; 1857 } 1610 1858 } 1611 1859 … … 1614 1862 done: 1615 1863 if (is_valid_policy_hnd(&group_handle)) { 1616 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);1864 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 1617 1865 } 1618 1866 -
vendor/current/source3/lib/netapi/joindomain.c
r594 r740 19 19 20 20 #include "includes.h" 21 21 #include "ads.h" 22 22 #include "librpc/gen_ndr/libnetapi.h" 23 #include "libcli/auth/libcli_auth.h" 23 24 #include "lib/netapi/netapi.h" 24 25 #include "lib/netapi/netapi_private.h" 25 26 #include "lib/netapi/libnetapi.h" 26 #include "libnet/libnet.h" 27 #include "libcli/auth/libcli_auth.h" 28 #include "../librpc/gen_ndr/cli_wkssvc.h" 27 #include "librpc/gen_ndr/libnet_join.h" 28 #include "libnet/libnet_join.h" 29 #include "../librpc/gen_ndr/ndr_wkssvc_c.h" 30 #include "rpc_client/cli_pipe.h" 31 #include "secrets.h" 29 32 30 33 /**************************************************************** … … 35 38 { 36 39 struct libnet_JoinCtx *j = NULL; 37 WERROR werr; 40 struct libnetapi_private_ctx *priv; 41 WERROR werr; 42 43 priv = talloc_get_type_abort(mem_ctx->private_data, 44 struct libnetapi_private_ctx); 38 45 39 46 if (!r->in.domain) { … … 54 61 DS_WRITABLE_REQUIRED | 55 62 DS_RETURN_DNS_NAME; 56 status = dsgetdcname(mem_ctx, NULL, r->in.domain,63 status = dsgetdcname(mem_ctx, priv->msg_ctx, r->in.domain, 57 64 NULL, NULL, flags, &info); 58 65 if (!NT_STATUS_IS_OK(status)) { … … 106 113 WERROR werr; 107 114 unsigned int old_timeout = 0; 115 struct dcerpc_binding_handle *b; 116 DATA_BLOB session_key; 108 117 109 118 werr = libnetapi_open_pipe(ctx, r->in.server, … … 114 123 } 115 124 116 if (r->in.password) { 125 b = pipe_cli->binding_handle; 126 127 if (r->in.password) { 128 129 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 130 if (!NT_STATUS_IS_OK(status)) { 131 werr = ntstatus_to_werror(status); 132 goto done; 133 } 134 117 135 encode_wkssvc_join_password_buffer(ctx, 118 136 r->in.password, 119 & pipe_cli->auth->user_session_key,137 &session_key, 120 138 &encrypted_password); 121 139 } … … 123 141 old_timeout = rpccli_set_timeout(pipe_cli, 600000); 124 142 125 status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, talloc_tos(),143 status = dcerpc_wkssvc_NetrJoinDomain2(b, talloc_tos(), 126 144 r->in.server, 127 145 r->in.domain, … … 153 171 const char *domain = NULL; 154 172 WERROR werr; 173 struct libnetapi_private_ctx *priv; 174 175 priv = talloc_get_type_abort(mem_ctx->private_data, 176 struct libnetapi_private_ctx); 155 177 156 178 if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { … … 177 199 DS_WRITABLE_REQUIRED | 178 200 DS_RETURN_DNS_NAME; 179 status = dsgetdcname(mem_ctx, NULL, domain,201 status = dsgetdcname(mem_ctx, priv->msg_ctx, domain, 180 202 NULL, NULL, flags, &info); 181 203 if (!NT_STATUS_IS_OK(status)) { … … 232 254 WERROR werr; 233 255 unsigned int old_timeout = 0; 256 struct dcerpc_binding_handle *b; 257 DATA_BLOB session_key; 234 258 235 259 werr = libnetapi_open_pipe(ctx, r->in.server_name, … … 240 264 } 241 265 242 if (r->in.password) { 266 b = pipe_cli->binding_handle; 267 268 if (r->in.password) { 269 270 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 271 if (!NT_STATUS_IS_OK(status)) { 272 werr = ntstatus_to_werror(status); 273 goto done; 274 } 275 243 276 encode_wkssvc_join_password_buffer(ctx, 244 277 r->in.password, 245 & pipe_cli->auth->user_session_key,278 &session_key, 246 279 &encrypted_password); 247 280 } … … 249 282 old_timeout = rpccli_set_timeout(pipe_cli, 60000); 250 283 251 status = rpccli_wkssvc_NetrUnjoinDomain2(pipe_cli, talloc_tos(),284 status = dcerpc_wkssvc_NetrUnjoinDomain2(b, talloc_tos(), 252 285 r->in.server_name, 253 286 r->in.account, … … 278 311 WERROR werr; 279 312 const char *buffer = NULL; 313 struct dcerpc_binding_handle *b; 280 314 281 315 werr = libnetapi_open_pipe(ctx, r->in.server_name, … … 286 320 } 287 321 288 status = rpccli_wkssvc_NetrGetJoinInformation(pipe_cli, talloc_tos(), 322 b = pipe_cli->binding_handle; 323 324 status = dcerpc_wkssvc_NetrGetJoinInformation(b, talloc_tos(), 289 325 r->in.server_name, 290 326 &buffer, … … 293 329 if (!NT_STATUS_IS_OK(status)) { 294 330 werr = ntstatus_to_werror(status); 331 goto done; 332 } 333 334 if (!W_ERROR_IS_OK(werr)) { 295 335 goto done; 296 336 } … … 339 379 struct NetGetJoinableOUs *r) 340 380 { 341 #ifdef WITH_ADS381 #ifdef HAVE_ADS 342 382 NTSTATUS status; 343 383 ADS_STATUS ads_status; … … 347 387 uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | 348 388 DS_RETURN_DNS_NAME; 349 350 status = dsgetdcname(ctx, NULL, r->in.domain, 389 struct libnetapi_private_ctx *priv; 390 391 priv = talloc_get_type_abort(ctx->private_data, 392 struct libnetapi_private_ctx); 393 394 status = dsgetdcname(ctx, priv->msg_ctx, r->in.domain, 351 395 NULL, NULL, flags, &info); 352 396 if (!NT_STATUS_IS_OK(status)) { … … 408 452 NTSTATUS status; 409 453 WERROR werr; 454 struct dcerpc_binding_handle *b; 455 DATA_BLOB session_key; 410 456 411 457 werr = libnetapi_open_pipe(ctx, r->in.server_name, … … 416 462 } 417 463 418 if (r->in.password) { 464 b = pipe_cli->binding_handle; 465 466 if (r->in.password) { 467 468 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 469 if (!NT_STATUS_IS_OK(status)) { 470 werr = ntstatus_to_werror(status); 471 goto done; 472 } 473 419 474 encode_wkssvc_join_password_buffer(ctx, 420 475 r->in.password, 421 & pipe_cli->auth->user_session_key,476 &session_key, 422 477 &encrypted_password); 423 478 } 424 479 425 status = rpccli_wkssvc_NetrGetJoinableOus2(pipe_cli, talloc_tos(),480 status = dcerpc_wkssvc_NetrGetJoinableOus2(b, talloc_tos(), 426 481 r->in.server_name, 427 482 r->in.domain, … … 450 505 NTSTATUS status; 451 506 WERROR werr; 507 struct dcerpc_binding_handle *b; 508 DATA_BLOB session_key; 452 509 453 510 werr = libnetapi_open_pipe(ctx, r->in.server_name, … … 458 515 } 459 516 460 if (r->in.password) { 517 b = pipe_cli->binding_handle; 518 519 if (r->in.password) { 520 521 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 522 if (!NT_STATUS_IS_OK(status)) { 523 werr = ntstatus_to_werror(status); 524 goto done; 525 } 526 461 527 encode_wkssvc_join_password_buffer(ctx, 462 528 r->in.password, 463 & pipe_cli->auth->user_session_key,529 &session_key, 464 530 &encrypted_password); 465 531 } 466 532 467 status = rpccli_wkssvc_NetrRenameMachineInDomain2(pipe_cli, talloc_tos(),533 status = dcerpc_wkssvc_NetrRenameMachineInDomain2(b, talloc_tos(), 468 534 r->in.server_name, 469 535 r->in.new_machine_name, -
vendor/current/source3/lib/netapi/libnetapi.c
r594 r740 75 75 76 76 TALLOC_FREE(frame); 77 return r.out.result;77 return (NET_API_STATUS)r.out.result; 78 78 } 79 79 … … 124 124 125 125 TALLOC_FREE(frame); 126 return r.out.result;126 return (NET_API_STATUS)r.out.result; 127 127 } 128 128 … … 171 171 172 172 TALLOC_FREE(frame); 173 return r.out.result;173 return (NET_API_STATUS)r.out.result; 174 174 } 175 175 … … 224 224 225 225 TALLOC_FREE(frame); 226 return r.out.result;226 return (NET_API_STATUS)r.out.result; 227 227 } 228 228 … … 275 275 276 276 TALLOC_FREE(frame); 277 return r.out.result;277 return (NET_API_STATUS)r.out.result; 278 278 } 279 279 … … 322 322 323 323 TALLOC_FREE(frame); 324 return r.out.result;324 return (NET_API_STATUS)r.out.result; 325 325 } 326 326 … … 371 371 372 372 TALLOC_FREE(frame); 373 return r.out.result;373 return (NET_API_STATUS)r.out.result; 374 374 } 375 375 … … 418 418 419 419 TALLOC_FREE(frame); 420 return r.out.result;420 return (NET_API_STATUS)r.out.result; 421 421 } 422 422 … … 465 465 466 466 TALLOC_FREE(frame); 467 return r.out.result;467 return (NET_API_STATUS)r.out.result; 468 468 } 469 469 … … 518 518 519 519 TALLOC_FREE(frame); 520 return r.out.result;520 return (NET_API_STATUS)r.out.result; 521 521 } 522 522 … … 567 567 568 568 TALLOC_FREE(frame); 569 return r.out.result;569 return (NET_API_STATUS)r.out.result; 570 570 } 571 571 … … 612 612 613 613 TALLOC_FREE(frame); 614 return r.out.result;614 return (NET_API_STATUS)r.out.result; 615 615 } 616 616 … … 670 670 671 671 TALLOC_FREE(frame); 672 return r.out.result;672 return (NET_API_STATUS)r.out.result; 673 673 } 674 674 … … 719 719 720 720 TALLOC_FREE(frame); 721 return r.out.result;721 return (NET_API_STATUS)r.out.result; 722 722 } 723 723 … … 768 768 769 769 TALLOC_FREE(frame); 770 return r.out.result;770 return (NET_API_STATUS)r.out.result; 771 771 } 772 772 … … 819 819 820 820 TALLOC_FREE(frame); 821 return r.out.result;821 return (NET_API_STATUS)r.out.result; 822 822 } 823 823 … … 874 874 875 875 TALLOC_FREE(frame); 876 return r.out.result;876 return (NET_API_STATUS)r.out.result; 877 877 } 878 878 … … 925 925 926 926 TALLOC_FREE(frame); 927 return r.out.result;927 return (NET_API_STATUS)r.out.result; 928 928 } 929 929 … … 982 982 983 983 TALLOC_FREE(frame); 984 return r.out.result;984 return (NET_API_STATUS)r.out.result; 985 985 } 986 986 … … 1029 1029 1030 1030 TALLOC_FREE(frame); 1031 return r.out.result;1031 return (NET_API_STATUS)r.out.result; 1032 1032 } 1033 1033 … … 1078 1078 1079 1079 TALLOC_FREE(frame); 1080 return r.out.result;1080 return (NET_API_STATUS)r.out.result; 1081 1081 } 1082 1082 … … 1133 1133 1134 1134 TALLOC_FREE(frame); 1135 return r.out.result;1135 return (NET_API_STATUS)r.out.result; 1136 1136 } 1137 1137 … … 1182 1182 1183 1183 TALLOC_FREE(frame); 1184 return r.out.result;1184 return (NET_API_STATUS)r.out.result; 1185 1185 } 1186 1186 … … 1227 1227 1228 1228 TALLOC_FREE(frame); 1229 return r.out.result;1229 return (NET_API_STATUS)r.out.result; 1230 1230 } 1231 1231 … … 1283 1283 1284 1284 TALLOC_FREE(frame); 1285 return r.out.result;1285 return (NET_API_STATUS)r.out.result; 1286 1286 } 1287 1287 … … 1334 1334 1335 1335 TALLOC_FREE(frame); 1336 return r.out.result;1336 return (NET_API_STATUS)r.out.result; 1337 1337 } 1338 1338 … … 1383 1383 1384 1384 TALLOC_FREE(frame); 1385 return r.out.result;1385 return (NET_API_STATUS)r.out.result; 1386 1386 } 1387 1387 … … 1430 1430 1431 1431 TALLOC_FREE(frame); 1432 return r.out.result;1432 return (NET_API_STATUS)r.out.result; 1433 1433 } 1434 1434 … … 1477 1477 1478 1478 TALLOC_FREE(frame); 1479 return r.out.result;1479 return (NET_API_STATUS)r.out.result; 1480 1480 } 1481 1481 … … 1535 1535 1536 1536 TALLOC_FREE(frame); 1537 return r.out.result;1537 return (NET_API_STATUS)r.out.result; 1538 1538 } 1539 1539 … … 1586 1586 1587 1587 TALLOC_FREE(frame); 1588 return r.out.result;1588 return (NET_API_STATUS)r.out.result; 1589 1589 } 1590 1590 … … 1635 1635 1636 1636 TALLOC_FREE(frame); 1637 return r.out.result;1637 return (NET_API_STATUS)r.out.result; 1638 1638 } 1639 1639 … … 1680 1680 1681 1681 TALLOC_FREE(frame); 1682 return r.out.result;1682 return (NET_API_STATUS)r.out.result; 1683 1683 } 1684 1684 … … 1729 1729 1730 1730 TALLOC_FREE(frame); 1731 return r.out.result;1731 return (NET_API_STATUS)r.out.result; 1732 1732 } 1733 1733 … … 1780 1780 1781 1781 TALLOC_FREE(frame); 1782 return r.out.result;1782 return (NET_API_STATUS)r.out.result; 1783 1783 } 1784 1784 … … 1836 1836 1837 1837 TALLOC_FREE(frame); 1838 return r.out.result;1838 return (NET_API_STATUS)r.out.result; 1839 1839 } 1840 1840 … … 1887 1887 1888 1888 TALLOC_FREE(frame); 1889 return r.out.result;1889 return (NET_API_STATUS)r.out.result; 1890 1890 } 1891 1891 … … 1938 1938 1939 1939 TALLOC_FREE(frame); 1940 return r.out.result;1940 return (NET_API_STATUS)r.out.result; 1941 1941 } 1942 1942 … … 1996 1996 1997 1997 TALLOC_FREE(frame); 1998 return r.out.result;1998 return (NET_API_STATUS)r.out.result; 1999 1999 } 2000 2000 … … 2047 2047 2048 2048 TALLOC_FREE(frame); 2049 return r.out.result;2049 return (NET_API_STATUS)r.out.result; 2050 2050 } 2051 2051 … … 2092 2092 2093 2093 TALLOC_FREE(frame); 2094 return r.out.result;2094 return (NET_API_STATUS)r.out.result; 2095 2095 } 2096 2096 … … 2141 2141 2142 2142 TALLOC_FREE(frame); 2143 return r.out.result;2143 return (NET_API_STATUS)r.out.result; 2144 2144 } 2145 2145 … … 2188 2188 2189 2189 TALLOC_FREE(frame); 2190 return r.out.result;2190 return (NET_API_STATUS)r.out.result; 2191 2191 } 2192 2192 … … 2244 2244 2245 2245 TALLOC_FREE(frame); 2246 return r.out.result;2246 return (NET_API_STATUS)r.out.result; 2247 2247 } 2248 2248 … … 2293 2293 2294 2294 TALLOC_FREE(frame); 2295 return r.out.result;2295 return (NET_API_STATUS)r.out.result; 2296 2296 } 2297 2297 … … 2344 2344 2345 2345 TALLOC_FREE(frame); 2346 return r.out.result;2346 return (NET_API_STATUS)r.out.result; 2347 2347 } 2348 2348 … … 2389 2389 2390 2390 TALLOC_FREE(frame); 2391 return r.out.result;2391 return (NET_API_STATUS)r.out.result; 2392 2392 } 2393 2393 … … 2438 2438 2439 2439 TALLOC_FREE(frame); 2440 return r.out.result;2440 return (NET_API_STATUS)r.out.result; 2441 2441 } 2442 2442 … … 2498 2498 2499 2499 TALLOC_FREE(frame); 2500 return r.out.result;2500 return (NET_API_STATUS)r.out.result; 2501 2501 } 2502 2502 … … 2549 2549 2550 2550 TALLOC_FREE(frame); 2551 return r.out.result;2551 return (NET_API_STATUS)r.out.result; 2552 2552 } 2553 2553 … … 2592 2592 2593 2593 TALLOC_FREE(frame); 2594 return r.out.result;2594 return (NET_API_STATUS)r.out.result; 2595 2595 } 2596 2596 … … 2641 2641 2642 2642 TALLOC_FREE(frame); 2643 return r.out.result;2643 return (NET_API_STATUS)r.out.result; 2644 2644 } 2645 2645 … … 2692 2692 2693 2693 TALLOC_FREE(frame); 2694 return r.out.result;2695 } 2696 2694 return (NET_API_STATUS)r.out.result; 2695 } 2696 -
vendor/current/source3/lib/netapi/libnetapi.h
r414 r740 1 /* 2 * Unix SMB/CIFS implementation. 3 * NetApi Support 4 * Copyright (C) Guenther Deschner 2007-2008 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, see <http://www.gnu.org/licenses/>. 18 */ 19 1 20 #ifndef __LIBNETAPI_LIBNETAPI__ 2 21 #define __LIBNETAPI_LIBNETAPI__ -
vendor/current/source3/lib/netapi/localgroup.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/cli_samr.h" 27 #include "../librpc/gen_ndr/cli_lsa.h" 26 #include "rpc_client/rpc_client.h" 27 #include "../librpc/gen_ndr/ndr_samr_c.h" 28 #include "../librpc/gen_ndr/ndr_lsa_c.h" 29 #include "rpc_client/cli_lsarpc.h" 30 #include "rpc_client/init_lsa.h" 31 #include "../libcli/security/security.h" 28 32 29 33 static NTSTATUS libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx, … … 34 38 struct policy_handle *alias_handle) 35 39 { 36 NTSTATUS status ;40 NTSTATUS status, result; 37 41 38 42 struct lsa_String lsa_account_name; 39 43 struct samr_Ids user_rids, name_types; 44 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 40 45 41 46 init_lsa_String(&lsa_account_name, group_name); 42 47 43 status = rpccli_samr_LookupNames(pipe_cli, mem_ctx,48 status = dcerpc_samr_LookupNames(b, mem_ctx, 44 49 domain_handle, 45 50 1, 46 51 &lsa_account_name, 47 52 &user_rids, 48 &name_types); 53 &name_types, 54 &result); 49 55 if (!NT_STATUS_IS_OK(status)) { 50 56 return status; 57 } 58 if (!NT_STATUS_IS_OK(result)) { 59 return result; 51 60 } 52 61 … … 59 68 } 60 69 61 return rpccli_samr_OpenAlias(pipe_cli, mem_ctx, 62 domain_handle, 63 access_rights, 64 user_rids.ids[0], 65 alias_handle); 70 status = dcerpc_samr_OpenAlias(b, mem_ctx, 71 domain_handle, 72 access_rights, 73 user_rids.ids[0], 74 alias_handle, 75 &result); 76 if (!NT_STATUS_IS_OK(status)) { 77 return status; 78 } 79 80 return result; 66 81 } 67 82 … … 77 92 union samr_AliasInfo **alias_info) 78 93 { 79 NTSTATUS status ;94 NTSTATUS status, result; 80 95 struct policy_handle alias_handle; 81 96 union samr_AliasInfo *_alias_info = NULL; 97 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 82 98 83 99 ZERO_STRUCT(alias_handle); 84 100 85 status = rpccli_samr_OpenAlias(pipe_cli, mem_ctx,101 status = dcerpc_samr_OpenAlias(b, mem_ctx, 86 102 handle, 87 103 access_rights, 88 104 rid, 89 &alias_handle); 90 if (!NT_STATUS_IS_OK(status)) { 91 goto done; 92 } 93 94 status = rpccli_samr_QueryAliasInfo(pipe_cli, mem_ctx, 105 &alias_handle, 106 &result); 107 if (!NT_STATUS_IS_OK(status)) { 108 goto done; 109 } 110 if (!NT_STATUS_IS_OK(result)) { 111 status = result; 112 goto done; 113 } 114 115 status = dcerpc_samr_QueryAliasInfo(b, mem_ctx, 95 116 &alias_handle, 96 117 level, 97 &_alias_info); 98 if (!NT_STATUS_IS_OK(status)) { 118 &_alias_info, 119 &result); 120 if (!NT_STATUS_IS_OK(status)) { 121 goto done; 122 } 123 if (!NT_STATUS_IS_OK(result)) { 124 status = result; 99 125 goto done; 100 126 } … … 104 130 done: 105 131 if (is_valid_policy_hnd(&alias_handle)) { 106 rpccli_samr_Close(pipe_cli, mem_ctx, &alias_handle);132 dcerpc_samr_Close(b, mem_ctx, &alias_handle, &result); 107 133 } 108 134 … … 117 143 { 118 144 struct rpc_pipe_client *pipe_cli = NULL; 119 NTSTATUS status ;145 NTSTATUS status, result; 120 146 WERROR werr; 121 147 struct lsa_String lsa_account_name; … … 123 149 struct dom_sid2 *domain_sid = NULL; 124 150 uint32_t rid; 151 struct dcerpc_binding_handle *b = NULL; 125 152 126 153 struct LOCALGROUP_INFO_0 *info0 = NULL; … … 158 185 goto done; 159 186 } 187 188 b = pipe_cli->binding_handle; 160 189 161 190 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 197 226 init_lsa_String(&lsa_account_name, alias_name); 198 227 199 status = rpccli_samr_CreateDomAlias(pipe_cli, talloc_tos(),228 status = dcerpc_samr_CreateDomAlias(b, talloc_tos(), 200 229 &domain_handle, 201 230 &lsa_account_name, … … 203 232 SAMR_ALIAS_ACCESS_SET_INFO, 204 233 &alias_handle, 205 &rid); 234 &rid, 235 &result); 206 236 if (!NT_STATUS_IS_OK(status)) { 207 237 werr = ntstatus_to_werror(status); 208 238 goto done; 209 239 } 240 if (!NT_STATUS_IS_OK(result)) { 241 werr = ntstatus_to_werror(result); 242 goto done; 243 } 244 210 245 211 246 if (r->in.level == 1 && info1->lgrpi1_comment) { … … 215 250 init_lsa_String(&alias_info.description, info1->lgrpi1_comment); 216 251 217 status = rpccli_samr_SetAliasInfo(pipe_cli, talloc_tos(),252 status = dcerpc_samr_SetAliasInfo(b, talloc_tos(), 218 253 &alias_handle, 219 254 ALIASINFODESCRIPTION, 220 &alias_info); 255 &alias_info, 256 &result); 221 257 if (!NT_STATUS_IS_OK(status)) { 222 258 werr = ntstatus_to_werror(status); 223 259 goto done; 224 260 } 261 if (!NT_STATUS_IS_OK(result)) { 262 werr = ntstatus_to_werror(result); 263 goto done; 264 } 225 265 } 226 266 … … 229 269 done: 230 270 if (is_valid_policy_hnd(&alias_handle)) { 231 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);271 dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result); 232 272 } 233 273 … … 258 298 { 259 299 struct rpc_pipe_client *pipe_cli = NULL; 260 NTSTATUS status ;300 NTSTATUS status, result; 261 301 WERROR werr; 262 302 struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle; 263 303 struct dom_sid2 *domain_sid = NULL; 304 struct dcerpc_binding_handle *b = NULL; 264 305 265 306 if (!r->in.group_name) { … … 278 319 goto done; 279 320 } 321 322 b = pipe_cli->binding_handle; 280 323 281 324 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 332 375 333 376 delete_alias: 334 status = rpccli_samr_DeleteDomAlias(pipe_cli, talloc_tos(), 335 &alias_handle); 377 status = dcerpc_samr_DeleteDomAlias(b, talloc_tos(), 378 &alias_handle, 379 &result); 336 380 if (!NT_STATUS_IS_OK(status)) { 337 381 werr = ntstatus_to_werror(status); 382 goto done; 383 } 384 if (!NT_STATUS_IS_OK(result)) { 385 werr = ntstatus_to_werror(result); 338 386 goto done; 339 387 } … … 345 393 done: 346 394 if (is_valid_policy_hnd(&alias_handle)) { 347 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);395 dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result); 348 396 } 349 397 … … 419 467 { 420 468 struct rpc_pipe_client *pipe_cli = NULL; 421 NTSTATUS status ;469 NTSTATUS status, result; 422 470 WERROR werr; 423 471 struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle; … … 425 473 union samr_AliasInfo *alias_info = NULL; 426 474 uint32_t entries_read = 0; 475 struct dcerpc_binding_handle *b = NULL; 427 476 428 477 if (!r->in.group_name) { … … 450 499 goto done; 451 500 } 501 502 b = pipe_cli->binding_handle; 452 503 453 504 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 503 554 504 555 query_alias: 505 status = rpccli_samr_QueryAliasInfo(pipe_cli, talloc_tos(),556 status = dcerpc_samr_QueryAliasInfo(b, talloc_tos(), 506 557 &alias_handle, 507 558 ALIASINFOALL, 508 &alias_info); 559 &alias_info, 560 &result); 509 561 if (!NT_STATUS_IS_OK(status)) { 510 562 werr = ntstatus_to_werror(status); 563 goto done; 564 } 565 if (!NT_STATUS_IS_OK(result)) { 566 werr = ntstatus_to_werror(result); 511 567 goto done; 512 568 } … … 520 576 done: 521 577 if (is_valid_policy_hnd(&alias_handle)) { 522 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);578 dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result); 523 579 } 524 580 … … 589 645 { 590 646 struct rpc_pipe_client *pipe_cli = NULL; 591 NTSTATUS status ;647 NTSTATUS status, result; 592 648 WERROR werr; 593 649 struct lsa_String lsa_account_name; … … 596 652 enum samr_AliasInfoEnum alias_level = 0; 597 653 union samr_AliasInfo *alias_info = NULL; 654 struct dcerpc_binding_handle *b = NULL; 598 655 599 656 if (!r->in.group_name) { … … 621 678 goto done; 622 679 } 680 681 b = pipe_cli->binding_handle; 623 682 624 683 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 681 740 } 682 741 683 status = rpccli_samr_SetAliasInfo(pipe_cli, talloc_tos(),742 status = dcerpc_samr_SetAliasInfo(b, talloc_tos(), 684 743 &alias_handle, 685 744 alias_level, 686 alias_info); 745 alias_info, 746 &result); 687 747 if (!NT_STATUS_IS_OK(status)) { 688 748 werr = ntstatus_to_werror(status); 749 goto done; 750 } 751 if (!NT_STATUS_IS_OK(result)) { 752 werr = ntstatus_to_werror(result); 689 753 goto done; 690 754 } … … 694 758 done: 695 759 if (is_valid_policy_hnd(&alias_handle)) { 696 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);760 dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result); 697 761 } 698 762 … … 722 786 { 723 787 struct rpc_pipe_client *pipe_cli = NULL; 724 NTSTATUS status ;788 NTSTATUS status, result; 725 789 WERROR werr; 726 790 struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle; … … 732 796 struct samr_SamArray *builtin_sam_array = NULL; 733 797 int i; 798 struct dcerpc_binding_handle *b = NULL; 734 799 735 800 if (!r->out.buffer) { … … 763 828 goto done; 764 829 } 830 831 b = pipe_cli->binding_handle; 765 832 766 833 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 789 856 } 790 857 791 status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),858 status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(), 792 859 &builtin_handle, 793 860 2, 794 &builtin_info); 861 &builtin_info, 862 &result); 795 863 if (!NT_STATUS_IS_OK(status)) { 796 864 werr = ntstatus_to_werror(status); 865 goto done; 866 } 867 if (!NT_STATUS_IS_OK(result)) { 868 werr = ntstatus_to_werror(result); 797 869 goto done; 798 870 } … … 802 874 } 803 875 804 status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),876 status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(), 805 877 &domain_handle, 806 878 2, 807 &domain_info); 879 &domain_info, 880 &result); 808 881 if (!NT_STATUS_IS_OK(status)) { 809 882 werr = ntstatus_to_werror(status); 883 goto done; 884 } 885 if (!NT_STATUS_IS_OK(result)) { 886 werr = ntstatus_to_werror(result); 810 887 goto done; 811 888 } … … 815 892 } 816 893 817 status = rpccli_samr_EnumDomainAliases(pipe_cli, talloc_tos(),894 status = dcerpc_samr_EnumDomainAliases(b, talloc_tos(), 818 895 &builtin_handle, 819 896 r->in.resume_handle, 820 897 &builtin_sam_array, 821 898 r->in.prefmaxlen, 822 &entries_read); 899 &entries_read, 900 &result); 823 901 if (!NT_STATUS_IS_OK(status)) { 824 902 werr = ntstatus_to_werror(status); 903 goto done; 904 } 905 if (!NT_STATUS_IS_OK(result)) { 906 werr = ntstatus_to_werror(result); 825 907 goto done; 826 908 } … … 851 933 } 852 934 853 status = rpccli_samr_EnumDomainAliases(pipe_cli, talloc_tos(),935 status = dcerpc_samr_EnumDomainAliases(b, talloc_tos(), 854 936 &domain_handle, 855 937 r->in.resume_handle, 856 938 &domain_sam_array, 857 939 r->in.prefmaxlen, 858 &entries_read); 940 &entries_read, 941 &result); 859 942 if (!NT_STATUS_IS_OK(status)) { 860 943 werr = ntstatus_to_werror(status); 944 goto done; 945 } 946 if (!NT_STATUS_IS_OK(result)) { 947 werr = ntstatus_to_werror(result); 861 948 goto done; 862 949 } … … 914 1001 struct dom_sid *sid) 915 1002 { 916 NTSTATUS status ;1003 NTSTATUS status, result; 917 1004 struct policy_handle lsa_handle; 1005 struct dcerpc_binding_handle *b = lsa_pipe->binding_handle; 918 1006 919 1007 struct lsa_RefDomainList *domains = NULL; … … 934 1022 status = rpccli_lsa_open_policy2(lsa_pipe, mem_ctx, 935 1023 false, 936 S TD_RIGHT_READ_CONTROL_ACCESS|1024 SEC_STD_READ_CONTROL | 937 1025 LSA_POLICY_VIEW_LOCAL_INFORMATION | 938 1026 LSA_POLICY_LOOKUP_NAMES, … … 940 1028 NT_STATUS_NOT_OK_RETURN(status); 941 1029 942 status = rpccli_lsa_LookupNames3(lsa_pipe, mem_ctx,1030 status = dcerpc_lsa_LookupNames3(b, mem_ctx, 943 1031 &lsa_handle, 944 1032 num_names, … … 948 1036 LSA_LOOKUP_NAMES_ALL, /* sure ? */ 949 1037 &count, 950 0, 0); 1038 0, 0, 1039 &result); 951 1040 NT_STATUS_NOT_OK_RETURN(status); 1041 NT_STATUS_NOT_OK_RETURN(result); 952 1042 953 1043 if (count != 1 || sids.count != 1) { … … 972 1062 struct rpc_pipe_client *pipe_cli = NULL; 973 1063 struct rpc_pipe_client *lsa_pipe = NULL; 974 NTSTATUS status ;1064 NTSTATUS status, result; 975 1065 WERROR werr; 976 1066 struct lsa_String lsa_account_name; … … 985 1075 struct dom_sid *add_sids = NULL; 986 1076 struct dom_sid *del_sids = NULL; 987 size_t num_add_sids = 0; 988 size_t num_del_sids = 0; 1077 uint32_t num_add_sids = 0; 1078 uint32_t num_del_sids = 0; 1079 struct dcerpc_binding_handle *b = NULL; 989 1080 990 1081 if ((!add && !del && !set) || (add && del && set)) { … … 1069 1160 goto done; 1070 1161 } 1162 1163 b = pipe_cli->binding_handle; 1071 1164 1072 1165 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, … … 1157 1250 struct lsa_SidArray current_sids; 1158 1251 1159 status = rpccli_samr_GetMembersInAlias(pipe_cli, talloc_tos(),1252 status = dcerpc_samr_GetMembersInAlias(b, talloc_tos(), 1160 1253 &alias_handle, 1161 ¤t_sids); 1254 ¤t_sids, 1255 &result); 1162 1256 if (!NT_STATUS_IS_OK(status)) { 1163 1257 werr = ntstatus_to_werror(status); 1164 1258 goto done; 1165 1259 } 1260 if (!NT_STATUS_IS_OK(result)) { 1261 werr = ntstatus_to_werror(result); 1262 goto done; 1263 } 1166 1264 1167 1265 /* add list */ … … 1170 1268 bool already_member = false; 1171 1269 for (k=0; k < current_sids.num_sids; k++) { 1172 if ( sid_equal(&member_sids[i],1270 if (dom_sid_equal(&member_sids[i], 1173 1271 current_sids.sids[k].sid)) { 1174 1272 already_member = true; … … 1192 1290 bool keep_member = false; 1193 1291 for (i=0; i < r->in.total_entries; i++) { 1194 if ( sid_equal(&member_sids[i],1292 if (dom_sid_equal(&member_sids[i], 1195 1293 current_sids.sids[k].sid)) { 1196 1294 keep_member = true; … … 1213 1311 1214 1312 for (i=0; i < num_add_sids; i++) { 1215 status = rpccli_samr_AddAliasMember(pipe_cli, talloc_tos(),1313 status = dcerpc_samr_AddAliasMember(b, talloc_tos(), 1216 1314 &alias_handle, 1217 &add_sids[i]); 1315 &add_sids[i], 1316 &result); 1218 1317 if (!NT_STATUS_IS_OK(status)) { 1219 1318 werr = ntstatus_to_werror(status); 1220 1319 goto done; 1221 1320 } 1321 if (!NT_STATUS_IS_OK(result)) { 1322 werr = ntstatus_to_werror(result); 1323 goto done; 1324 } 1222 1325 } 1223 1326 … … 1225 1328 1226 1329 for (i=0; i < num_del_sids; i++) { 1227 status = rpccli_samr_DeleteAliasMember(pipe_cli, talloc_tos(),1330 status = dcerpc_samr_DeleteAliasMember(b, talloc_tos(), 1228 1331 &alias_handle, 1229 &del_sids[i]); 1332 &del_sids[i], 1333 &result); 1230 1334 if (!NT_STATUS_IS_OK(status)) { 1231 1335 werr = ntstatus_to_werror(status); 1232 1336 goto done; 1233 1337 } 1338 if (!NT_STATUS_IS_OK(result)) { 1339 werr = ntstatus_to_werror(result); 1340 goto done; 1341 } 1234 1342 } 1235 1343 … … 1237 1345 1238 1346 done: 1239 if ( is_valid_policy_hnd(&alias_handle)) {1240 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);1347 if (b && is_valid_policy_hnd(&alias_handle)) { 1348 dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result); 1241 1349 } 1242 1350 -
vendor/current/source3/lib/netapi/netapi.c
r414 r740 21 21 #include "lib/netapi/netapi.h" 22 22 #include "lib/netapi/netapi_private.h" 23 24 extern bool AllowDebugChange; 23 #include "secrets.h" 24 #include "krb5_env.h" 25 25 26 26 struct libnetapi_ctx *stat_ctx = NULL; … … 50 50 51 51 /**************************************************************** 52 Create a libnetapi context, for use in non-Samba applications. This 53 loads the smb.conf file and sets the debug level to 0, so that 54 applications are not flooded with debug logs at level 10, when they 55 were not expecting it. 52 56 ****************************************************************/ 53 57 54 58 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) 55 59 { 56 NET_API_STATUS status;57 struct libnetapi_ctx *ctx = NULL;58 char *krb5_cc_env = NULL;59 60 60 if (stat_ctx && libnetapi_initialized) { 61 61 *context = stat_ctx; … … 68 68 frame = talloc_stackframe(); 69 69 70 ctx = talloc_zero(frame, struct libnetapi_ctx); 71 if (!ctx) { 72 TALLOC_FREE(frame); 73 return W_ERROR_V(WERR_NOMEM); 74 } 75 76 if (!DEBUGLEVEL) { 77 DEBUGLEVEL = 0; 78 } 79 80 /* prevent setup_logging() from closing x_stderr... */ 81 dbf = 0; 82 setup_logging("libnetapi", true); 83 84 dbf = x_stderr; 85 x_setbuf(x_stderr, NULL); 86 AllowDebugChange = false; 87 88 load_case_tables(); 70 /* Case tables must be loaded before any string comparisons occour */ 71 load_case_tables_library(); 72 73 /* When libnetapi is invoked from an application, it does not 74 * want to be swamped with level 10 debug messages, even if 75 * this has been set for the server in smb.conf */ 76 lp_set_cmdline("log level", "0"); 77 setup_logging("libnetapi", DEBUG_STDERR); 89 78 90 79 if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, false)) { … … 94 83 } 95 84 96 AllowDebugChange = true;97 98 85 init_names(); 99 86 load_interfaces(); 100 87 reopen_logs(); 88 89 BlockSignals(True, SIGPIPE); 90 91 return libnetapi_net_init(context); 92 } 93 94 /**************************************************************** 95 Create a libnetapi context, for use inside the 'net' binary. 96 97 As we know net has already loaded the smb.conf file, and set the debug 98 level etc, this avoids doing so again (which causes trouble with -d on 99 the command line). 100 ****************************************************************/ 101 102 NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context) 103 { 104 NET_API_STATUS status; 105 struct libnetapi_ctx *ctx = NULL; 106 char *krb5_cc_env = NULL; 107 108 frame = talloc_stackframe(); 109 110 ctx = talloc_zero(frame, struct libnetapi_ctx); 111 if (!ctx) { 112 TALLOC_FREE(frame); 113 return W_ERROR_V(WERR_NOMEM); 114 } 101 115 102 116 BlockSignals(True, SIGPIPE); … … 133 147 134 148 /**************************************************************** 149 Return the static libnetapi context 135 150 ****************************************************************/ 136 151 … … 146 161 147 162 /**************************************************************** 163 Free the static libnetapi context 148 164 ****************************************************************/ 149 165 … … 182 198 183 199 /**************************************************************** 200 Override the current log level for libnetapi 184 201 ****************************************************************/ 185 202 … … 187 204 const char *debuglevel) 188 205 { 189 AllowDebugChange = true;190 206 ctx->debuglevel = talloc_strdup(ctx, debuglevel); 191 if (! debug_parse_levels(debuglevel)) {207 if (!lp_set_cmdline("log level", debuglevel)) { 192 208 return W_ERROR_V(WERR_GENERAL_FAILURE); 193 209 } -
vendor/current/source3/lib/netapi/netapi.h
r414 r740 1285 1285 }; 1286 1286 1287 #define DS_PDC_FLAG ( 0x00000001 ) 1288 #define DS_GC_FLAG ( 0x00000004 ) 1289 #define DS_LDAP_FLAG ( 0x00000008 ) 1290 #define DS_DS_FLAG ( 0x00000010 ) 1291 #define DS_KDC_FLAG ( 0x00000020 ) 1292 #define DS_TIMESERV_FLAG ( 0x00000040 ) 1293 #define DS_CLOSEST_FLAG ( 0x00000080 ) 1294 #define DS_WRITABLE_FLAG ( 0x00000100 ) 1295 #define DS_GOOD_TIMESERV_FLAG ( 0x00000200 ) 1296 #define DS_NDNC_FLAG ( 0x00000400 ) 1297 #define DS_SELECT_SECRET_DOMAIN_6_FLAG ( 0x00000800 ) 1298 #define DS_FULL_SECRET_DOMAIN_6_FLAG ( 0x00001000 ) 1299 #define DS_DNS_CONTROLLER_FLAG ( 0x20000000 ) 1300 #define DS_DNS_DOMAIN_FLAG ( 0x40000000 ) 1301 #define DS_DNS_FOREST_FLAG ( 0x80000000 ) 1302 1287 1303 #endif /* _HEADER_libnetapi */ 1288 1304 … … 1306 1322 #define NETLOGON_CONTROL_BREAKPOINT ( 0x0000FFFF ) 1307 1323 1324 #define DS_FORCE_REDISCOVERY ( 0x00000001 ) 1325 #define DS_DIRECTORY_SERVICE_REQUIRED ( 0x00000010 ) 1326 #define DS_DIRECTORY_SERVICE_PREFERRED ( 0x00000020 ) 1327 #define DS_GC_SERVER_REQUIRED ( 0x00000040 ) 1328 #define DS_PDC_REQUIRED ( 0x00000080 ) 1329 #define DS_BACKGROUND_ONLY ( 0x00000100 ) 1330 #define DS_IP_REQUIRED ( 0x00000200 ) 1331 #define DS_KDC_REQUIRED ( 0x00000400 ) 1332 #define DS_TIMESERV_REQUIRED ( 0x00000800 ) 1333 #define DS_WRITABLE_REQUIRED ( 0x00001000 ) 1334 #define DS_GOOD_TIMESERV_PREFERRED ( 0x00002000 ) 1335 #define DS_AVOID_SELF ( 0x00004000 ) 1336 #define DS_ONLY_LDAP_NEEDED ( 0x00008000 ) 1337 #define DS_IS_FLAT_NAME ( 0x00010000 ) 1338 #define DS_IS_DNS_NAME ( 0x00020000 ) 1339 #define DS_TRY_NEXTCLOSEST_SITE ( 0x00040000 ) 1340 #define DS_DIRECTORY_SERVICE_6_REQUIRED ( 0x00080000 ) 1341 #define DS_WEB_SERVICE_REQUIRED ( 0x00100000 ) 1342 #define DS_RETURN_DNS_NAME ( 0x40000000 ) 1343 #define DS_RETURN_FLAT_NAME ( 0x80000000 ) 1344 1308 1345 #endif /* _HEADER_netlogon */ 1309 1346 -
vendor/current/source3/lib/netapi/netapi_private.h
r587 r740 21 21 #define __LIB_NETAPI_PRIVATE_H__ 22 22 23 #include "lib/netapi/netapi_net.h" 24 23 25 #define LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, fn) \ 24 26 DEBUG(10,("redirecting call %s to localhost\n", #fn)); \ … … 27 29 } \ 28 30 return fn ## _r(ctx, r); 31 32 struct dcerpc_binding_handle; 29 33 30 34 struct libnetapi_private_ctx { … … 45 49 46 50 struct client_ipc_connection *ipc_connections; 51 52 struct messaging_context *msg_ctx; 47 53 }; 48 54 … … 57 63 const struct ndr_syntax_id *interface, 58 64 struct rpc_pipe_client **presult); 65 WERROR libnetapi_get_binding_handle(struct libnetapi_ctx *ctx, 66 const char *server_name, 67 const struct ndr_syntax_id *interface, 68 struct dcerpc_binding_handle **binding_handle); 59 69 WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx, 60 70 struct rpc_pipe_client *pipe_cli, -
vendor/current/source3/lib/netapi/netlogon.c
r594 r740 20 20 #include "includes.h" 21 21 22 #include "../librpc/gen_ndr/ndr_netlogon_c.h" 22 23 #include "librpc/gen_ndr/libnetapi.h" 23 24 #include "lib/netapi/netapi.h" 24 25 #include "lib/netapi/netapi_private.h" 25 26 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/cli_netlogon.h"27 27 28 28 static WERROR construct_data(enum netr_LogonControlCode function_code, … … 44 44 data_out->debug_level = atoi((const char *)data_in); 45 45 break; 46 case NETLOGON_CONTROL_FORCE_DNS_REG: 47 ZERO_STRUCTP(data_out); 48 break; 46 49 default: 47 50 return WERR_INVALID_PARAM; … … 127 130 WERROR werr; 128 131 NTSTATUS status; 129 struct rpc_pipe_client *pipe_cli = NULL;130 132 union netr_CONTROL_QUERY_INFORMATION query; 131 132 werr = libnetapi_open_pipe(ctx, r->in.server_name, 133 &ndr_table_netlogon.syntax_id, 134 &pipe_cli); 135 if (!W_ERROR_IS_OK(werr)) { 136 goto done; 137 } 138 139 status = rpccli_netr_LogonControl(pipe_cli, talloc_tos(), 133 struct dcerpc_binding_handle *b; 134 135 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 136 &ndr_table_netlogon.syntax_id, 137 &b); 138 if (!W_ERROR_IS_OK(werr)) { 139 goto done; 140 } 141 142 status = dcerpc_netr_LogonControl(b, talloc_tos(), 140 143 r->in.server_name, 141 144 r->in.function_code, … … 147 150 goto done; 148 151 } 152 if (!W_ERROR_IS_OK(werr)) { 153 goto done; 154 } 149 155 150 156 werr = construct_buffer(ctx, r->in.query_level, &query, … … 175 181 WERROR werr; 176 182 NTSTATUS status; 177 struct rpc_pipe_client *pipe_cli = NULL;178 183 union netr_CONTROL_DATA_INFORMATION data; 179 184 union netr_CONTROL_QUERY_INFORMATION query; 185 struct dcerpc_binding_handle *b; 180 186 181 187 werr = construct_data(r->in.function_code, r->in.data, &data); … … 184 190 } 185 191 186 werr = libnetapi_ open_pipe(ctx, r->in.server_name,187 &ndr_table_netlogon.syntax_id,188 &pipe_cli);192 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 193 &ndr_table_netlogon.syntax_id, 194 &b); 189 195 if (!W_ERROR_IS_OK(werr)) { 190 196 goto done; … … 194 200 case NETLOGON_CONTROL_TC_VERIFY: 195 201 case NETLOGON_CONTROL_SET_DBFLAG: 196 status = rpccli_netr_LogonControl2Ex(pipe_cli, talloc_tos(), 202 case NETLOGON_CONTROL_FORCE_DNS_REG: 203 status = dcerpc_netr_LogonControl2Ex(b, talloc_tos(), 197 204 r->in.server_name, 198 205 r->in.function_code, … … 203 210 break; 204 211 default: 205 status = rpccli_netr_LogonControl2(pipe_cli, talloc_tos(),212 status = dcerpc_netr_LogonControl2(b, talloc_tos(), 206 213 r->in.server_name, 207 214 r->in.function_code, … … 213 220 } 214 221 215 if (!W_ERROR_IS_OK(werr)) {216 goto done;217 }218 219 222 if (!NT_STATUS_IS_OK(status)) { 220 223 werr = ntstatus_to_werror(status); … … 222 225 } 223 226 227 if (!W_ERROR_IS_OK(werr)) { 228 goto done; 229 } 230 224 231 werr = construct_buffer(ctx, r->in.query_level, &query, 225 232 r->out.buffer); -
vendor/current/source3/lib/netapi/samr.c
r414 r740 21 21 #include "lib/netapi/netapi.h" 22 22 #include "lib/netapi/netapi_private.h" 23 #include "../librpc/gen_ndr/cli_samr.h" 23 #include "rpc_client/rpc_client.h" 24 #include "../librpc/gen_ndr/ndr_samr_c.h" 25 #include "rpc_client/cli_samr.h" 26 #include "rpc_client/init_lsa.h" 27 #include "../libcli/security/security.h" 24 28 25 29 /**************************************************************** … … 34 38 struct dom_sid2 **domain_sid) 35 39 { 36 NTSTATUS status ;40 NTSTATUS status, result; 37 41 WERROR werr; 38 42 struct libnetapi_private_ctx *priv; … … 44 48 bool domain_found = true; 45 49 int i; 50 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 46 51 47 52 priv = talloc_get_type_abort(mem_ctx->private_data, … … 78 83 79 84 if (!is_valid_policy_hnd(connect_handle)) { 80 status = rpccli_try_samr_connects(pipe_cli, mem_ctx, 85 status = dcerpc_try_samr_connects(pipe_cli->binding_handle, mem_ctx, 86 pipe_cli->srv_name_slash, 81 87 connect_mask, 82 connect_handle); 88 connect_handle, 89 &result); 83 90 if (!NT_STATUS_IS_OK(status)) { 84 91 werr = ntstatus_to_werror(status); 85 92 goto done; 86 93 } 87 } 88 89 status = rpccli_samr_EnumDomains(pipe_cli, mem_ctx, 94 if (!NT_STATUS_IS_OK(result)) { 95 werr = ntstatus_to_werror(result); 96 goto done; 97 } 98 } 99 100 status = dcerpc_samr_EnumDomains(b, mem_ctx, 90 101 connect_handle, 91 102 &resume_handle, 92 103 &sam, 93 104 0xffffffff, 94 &num_entries); 105 &num_entries, 106 &result); 95 107 if (!NT_STATUS_IS_OK(status)) { 96 108 werr = ntstatus_to_werror(status); 97 109 goto done; 98 110 } 111 if (!NT_STATUS_IS_OK(result)) { 112 werr = ntstatus_to_werror(result); 113 goto done; 114 } 99 115 100 116 for (i=0; i<num_entries; i++) { … … 117 133 init_lsa_String(&lsa_domain_name, domain_name); 118 134 119 status = rpccli_samr_LookupDomain(pipe_cli, mem_ctx,135 status = dcerpc_samr_LookupDomain(b, mem_ctx, 120 136 connect_handle, 121 137 &lsa_domain_name, 122 domain_sid); 138 domain_sid, 139 &result); 123 140 if (!NT_STATUS_IS_OK(status)) { 124 141 werr = ntstatus_to_werror(status); 125 142 goto done; 126 143 } 127 128 status = rpccli_samr_OpenDomain(pipe_cli, mem_ctx, 144 if (!NT_STATUS_IS_OK(result)) { 145 werr = ntstatus_to_werror(result); 146 goto done; 147 } 148 149 status = dcerpc_samr_OpenDomain(b, mem_ctx, 129 150 connect_handle, 130 151 domain_mask, 131 152 *domain_sid, 132 domain_handle); 153 domain_handle, 154 &result); 133 155 if (!NT_STATUS_IS_OK(status)) { 134 156 werr = ntstatus_to_werror(status); 157 goto done; 158 } 159 if (!NT_STATUS_IS_OK(result)) { 160 werr = ntstatus_to_werror(result); 135 161 goto done; 136 162 } … … 163 189 struct policy_handle *builtin_handle) 164 190 { 165 NTSTATUS status ;191 NTSTATUS status, result; 166 192 WERROR werr; 167 193 struct libnetapi_private_ctx *priv; 194 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 168 195 169 196 priv = talloc_get_type_abort(mem_ctx->private_data, … … 196 223 197 224 if (!is_valid_policy_hnd(connect_handle)) { 198 status = rpccli_try_samr_connects(pipe_cli, mem_ctx, 225 status = dcerpc_try_samr_connects(pipe_cli->binding_handle, mem_ctx, 226 pipe_cli->srv_name_slash, 199 227 connect_mask, 200 connect_handle); 228 connect_handle, 229 &result); 201 230 if (!NT_STATUS_IS_OK(status)) { 202 231 werr = ntstatus_to_werror(status); 203 232 goto done; 204 233 } 205 } 206 207 status = rpccli_samr_OpenDomain(pipe_cli, mem_ctx, 234 if (!NT_STATUS_IS_OK(result)) { 235 werr = ntstatus_to_werror(result); 236 goto done; 237 } 238 } 239 240 status = dcerpc_samr_OpenDomain(b, mem_ctx, 208 241 connect_handle, 209 242 builtin_mask, 210 CONST_DISCARD(DOM_SID *, &global_sid_Builtin), 211 builtin_handle); 243 CONST_DISCARD(struct dom_sid *, &global_sid_Builtin), 244 builtin_handle, 245 &result); 212 246 if (!NT_STATUS_IS_OK(status)) { 213 247 werr = ntstatus_to_werror(status); 214 248 goto done; 215 249 } 250 if (!NT_STATUS_IS_OK(result)) { 251 werr = ntstatus_to_werror(result); 252 goto done; 253 } 216 254 217 255 priv->samr.cli = pipe_cli; … … 236 274 { 237 275 struct libnetapi_private_ctx *priv; 276 struct dcerpc_binding_handle *b; 277 NTSTATUS result; 238 278 239 279 if (!is_valid_policy_hnd(handle)) { … … 244 284 struct libnetapi_private_ctx); 245 285 246 if (!policy_hnd_equal(handle, &priv->samr.domain_handle)) { 247 return; 248 } 249 250 rpccli_samr_Close(priv->samr.cli, ctx, handle); 286 if (!policy_handle_equal(handle, &priv->samr.domain_handle)) { 287 return; 288 } 289 290 b = priv->samr.cli->binding_handle; 291 292 dcerpc_samr_Close(b, ctx, handle, &result); 251 293 252 294 ZERO_STRUCT(priv->samr.domain_handle); … … 260 302 { 261 303 struct libnetapi_private_ctx *priv; 304 struct dcerpc_binding_handle *b; 305 NTSTATUS result; 262 306 263 307 if (!is_valid_policy_hnd(handle)) { … … 268 312 struct libnetapi_private_ctx); 269 313 270 if (!policy_hnd_equal(handle, &priv->samr.builtin_handle)) { 271 return; 272 } 273 274 rpccli_samr_Close(priv->samr.cli, ctx, handle); 314 if (!policy_handle_equal(handle, &priv->samr.builtin_handle)) { 315 return; 316 } 317 318 b = priv->samr.cli->binding_handle; 319 320 dcerpc_samr_Close(b, ctx, handle, &result); 275 321 276 322 ZERO_STRUCT(priv->samr.builtin_handle); … … 284 330 { 285 331 struct libnetapi_private_ctx *priv; 332 struct dcerpc_binding_handle *b; 333 NTSTATUS result; 286 334 287 335 if (!is_valid_policy_hnd(handle)) { … … 292 340 struct libnetapi_private_ctx); 293 341 294 if (!policy_hnd_equal(handle, &priv->samr.connect_handle)) { 295 return; 296 } 297 298 rpccli_samr_Close(priv->samr.cli, ctx, handle); 342 if (!policy_handle_equal(handle, &priv->samr.connect_handle)) { 343 return; 344 } 345 346 b = priv->samr.cli->binding_handle; 347 348 dcerpc_samr_Close(b, ctx, handle, &result); 299 349 300 350 ZERO_STRUCT(priv->samr.connect_handle); -
vendor/current/source3/lib/netapi/serverinfo.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "libnet/libnet.h" 27 #include "../librpc/gen_ndr/cli_srvsvc.h" 26 #include "../librpc/gen_ndr/ndr_srvsvc_c.h" 27 #include "lib/smbconf/smbconf.h" 28 #include "lib/smbconf/smbconf_reg.h" 28 29 29 30 /**************************************************************** … … 480 481 struct NetServerGetInfo *r) 481 482 { 482 struct rpc_pipe_client *pipe_cli = NULL;483 483 NTSTATUS status; 484 484 WERROR werr; 485 485 union srvsvc_NetSrvInfo info; 486 struct dcerpc_binding_handle *b; 486 487 487 488 if (!r->out.buffer) { … … 502 503 } 503 504 504 werr = libnetapi_ open_pipe(ctx, r->in.server_name,505 &ndr_table_srvsvc.syntax_id,506 &pipe_cli);505 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 506 &ndr_table_srvsvc.syntax_id, 507 &b); 507 508 if (!W_ERROR_IS_OK(werr)) { 508 509 goto done; 509 510 } 510 511 511 status = rpccli_srvsvc_NetSrvGetInfo(pipe_cli, talloc_tos(),512 status = dcerpc_srvsvc_NetSrvGetInfo(b, talloc_tos(), 512 513 r->in.server_name, 513 514 r->in.level, … … 519 520 } 520 521 522 if (!W_ERROR_IS_OK(werr)) { 523 goto done; 524 } 525 521 526 status = map_server_info_to_SERVER_INFO_buffer(ctx, r->in.level, &info, 522 527 r->out.buffer); … … 536 541 struct NetServerSetInfo *r) 537 542 { 538 WERROR werr; 543 WERROR werr = WERR_OK; 544 sbcErr err; 539 545 struct smbconf_ctx *conf_ctx; 540 546 struct srvsvc_NetSrvInfo1005 *info1005; … … 559 565 } 560 566 561 werr = smbconf_init_reg(ctx, &conf_ctx, NULL); 562 if (!W_ERROR_IS_OK(werr)) { 563 goto done; 564 } 565 566 werr = smbconf_set_global_parameter(conf_ctx, "server string", 567 err = smbconf_init_reg(ctx, &conf_ctx, NULL); 568 if (!SBC_ERROR_IS_OK(err)) { 569 libnetapi_set_error_string(ctx, 570 "Could not initialize backend: %s", 571 sbcErrorString(err)); 572 werr = WERR_NO_SUCH_SERVICE; 573 goto done; 574 } 575 576 err = smbconf_set_global_parameter(conf_ctx, "server string", 567 577 info1005->comment); 578 if (!SBC_ERROR_IS_OK(err)) { 579 libnetapi_set_error_string(ctx, 580 "Could not set global parameter: %s", 581 sbcErrorString(err)); 582 werr = WERR_NO_SUCH_SERVICE; 583 goto done; 584 } 568 585 569 586 done: … … 594 611 struct NetServerSetInfo *r) 595 612 { 596 struct rpc_pipe_client *pipe_cli = NULL;597 613 NTSTATUS status; 598 614 WERROR werr; 599 615 union srvsvc_NetSrvInfo info; 600 601 werr = libnetapi_open_pipe(ctx, r->in.server_name, 602 &ndr_table_srvsvc.syntax_id, 603 &pipe_cli); 616 struct dcerpc_binding_handle *b; 617 618 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 619 &ndr_table_srvsvc.syntax_id, 620 &b); 604 621 if (!W_ERROR_IS_OK(werr)) { 605 622 goto done; … … 615 632 } 616 633 617 status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, talloc_tos(),634 status = dcerpc_srvsvc_NetSrvSetInfo(b, talloc_tos(), 618 635 r->in.server_name, 619 636 r->in.level, … … 636 653 struct NetRemoteTOD *r) 637 654 { 638 struct rpc_pipe_client *pipe_cli = NULL;639 655 NTSTATUS status; 640 656 WERROR werr; 641 657 struct srvsvc_NetRemoteTODInfo *info = NULL; 642 643 werr = libnetapi_open_pipe(ctx, r->in.server_name, 644 &ndr_table_srvsvc.syntax_id, 645 &pipe_cli); 658 struct dcerpc_binding_handle *b; 659 660 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 661 &ndr_table_srvsvc.syntax_id, 662 &b); 646 663 if (!W_ERROR_IS_OK(werr)) { 647 664 goto done; 648 665 } 649 666 650 status = rpccli_srvsvc_NetRemoteTOD(pipe_cli, talloc_tos(),667 status = dcerpc_srvsvc_NetRemoteTOD(b, talloc_tos(), 651 668 r->in.server_name, 652 669 &info, … … 657 674 } 658 675 676 if (!W_ERROR_IS_OK(werr)) { 677 goto done; 678 } 679 659 680 *r->out.buffer = (uint8_t *)talloc_memdup(ctx, info, 660 681 sizeof(struct srvsvc_NetRemoteTODInfo)); -
vendor/current/source3/lib/netapi/share.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/ cli_srvsvc.h"26 #include "../librpc/gen_ndr/ndr_srvsvc_c.h" 27 27 28 28 /**************************************************************** … … 183 183 WERROR werr; 184 184 NTSTATUS status; 185 struct rpc_pipe_client *pipe_cli = NULL;186 185 union srvsvc_NetShareInfo info; 186 struct dcerpc_binding_handle *b; 187 187 188 188 if (!r->in.buffer) { … … 200 200 } 201 201 202 werr = libnetapi_ open_pipe(ctx, r->in.server_name,203 &ndr_table_srvsvc.syntax_id,204 &pipe_cli);202 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 203 &ndr_table_srvsvc.syntax_id, 204 &b); 205 205 if (!W_ERROR_IS_OK(werr)) { 206 206 goto done; … … 216 216 } 217 217 218 status = rpccli_srvsvc_NetShareAdd(pipe_cli, talloc_tos(),218 status = dcerpc_srvsvc_NetShareAdd(b, talloc_tos(), 219 219 r->in.server_name, 220 220 r->in.level, … … 222 222 r->out.parm_err, 223 223 &werr); 224 if (!NT_STATUS_IS_OK(status)) { 225 werr = ntstatus_to_werror(status); 226 goto done; 227 } 228 224 229 if (!W_ERROR_IS_OK(werr)) { 225 230 goto done; … … 247 252 WERROR werr; 248 253 NTSTATUS status; 249 struct rpc_pipe_client *pipe_cli = NULL;254 struct dcerpc_binding_handle *b; 250 255 251 256 if (!r->in.net_name) { … … 253 258 } 254 259 255 werr = libnetapi_ open_pipe(ctx, r->in.server_name,256 &ndr_table_srvsvc.syntax_id,257 &pipe_cli);258 if (!W_ERROR_IS_OK(werr)) { 259 goto done; 260 } 261 262 status = rpccli_srvsvc_NetShareDel(pipe_cli, talloc_tos(),260 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 261 &ndr_table_srvsvc.syntax_id, 262 &b); 263 if (!W_ERROR_IS_OK(werr)) { 264 goto done; 265 } 266 267 status = dcerpc_srvsvc_NetShareDel(b, talloc_tos(), 263 268 r->in.server_name, 264 269 r->in.net_name, … … 291 296 WERROR werr; 292 297 NTSTATUS status; 293 struct rpc_pipe_client *pipe_cli = NULL;294 298 struct srvsvc_NetShareInfoCtr info_ctr; 295 299 struct srvsvc_NetShareCtr0 ctr0; … … 297 301 struct srvsvc_NetShareCtr2 ctr2; 298 302 uint32_t i; 303 struct dcerpc_binding_handle *b; 299 304 300 305 if (!r->out.buffer) { … … 316 321 ZERO_STRUCT(info_ctr); 317 322 318 werr = libnetapi_ open_pipe(ctx, r->in.server_name,319 &ndr_table_srvsvc.syntax_id,320 &pipe_cli);323 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 324 &ndr_table_srvsvc.syntax_id, 325 &b); 321 326 if (!W_ERROR_IS_OK(werr)) { 322 327 goto done; … … 339 344 } 340 345 341 status = rpccli_srvsvc_NetShareEnumAll(pipe_cli, talloc_tos(),346 status = dcerpc_srvsvc_NetShareEnumAll(b, talloc_tos(), 342 347 r->in.server_name, 343 348 &info_ctr, … … 346 351 r->out.resume_handle, 347 352 &werr); 348 if (NT_STATUS_IS_ERR(status)) { 353 if (!NT_STATUS_IS_OK(status)) { 354 werr = ntstatus_to_werror(status); 355 goto done; 356 } 357 358 if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) { 349 359 goto done; 350 360 } … … 371 381 if (!NT_STATUS_IS_OK(status)) { 372 382 werr = ntstatus_to_werror(status); 383 goto done; 373 384 } 374 385 } … … 395 406 WERROR werr; 396 407 NTSTATUS status; 397 struct rpc_pipe_client *pipe_cli = NULL;398 408 union srvsvc_NetShareInfo info; 399 409 uint32_t num_entries = 0; 410 struct dcerpc_binding_handle *b; 400 411 401 412 if (!r->in.net_name || !r->out.buffer) { … … 417 428 } 418 429 419 werr = libnetapi_ open_pipe(ctx, r->in.server_name,420 &ndr_table_srvsvc.syntax_id,421 &pipe_cli);422 if (!W_ERROR_IS_OK(werr)) { 423 goto done; 424 } 425 426 status = rpccli_srvsvc_NetShareGetInfo(pipe_cli, talloc_tos(),430 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 431 &ndr_table_srvsvc.syntax_id, 432 &b); 433 if (!W_ERROR_IS_OK(werr)) { 434 goto done; 435 } 436 437 status = dcerpc_srvsvc_NetShareGetInfo(b, talloc_tos(), 427 438 r->in.server_name, 428 439 r->in.net_name, … … 430 441 &info, 431 442 &werr); 443 if (!NT_STATUS_IS_OK(status)) { 444 werr = ntstatus_to_werror(status); 445 goto done; 446 } 432 447 433 448 if (!W_ERROR_IS_OK(werr)) { … … 465 480 WERROR werr; 466 481 NTSTATUS status; 467 struct rpc_pipe_client *pipe_cli = NULL;468 482 union srvsvc_NetShareInfo info; 483 struct dcerpc_binding_handle *b; 469 484 470 485 if (!r->in.buffer) { … … 487 502 } 488 503 489 werr = libnetapi_ open_pipe(ctx, r->in.server_name,490 &ndr_table_srvsvc.syntax_id,491 &pipe_cli);504 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 505 &ndr_table_srvsvc.syntax_id, 506 &b); 492 507 if (!W_ERROR_IS_OK(werr)) { 493 508 goto done; … … 503 518 } 504 519 505 status = rpccli_srvsvc_NetShareSetInfo(pipe_cli, talloc_tos(),520 status = dcerpc_srvsvc_NetShareSetInfo(b, talloc_tos(), 506 521 r->in.server_name, 507 522 r->in.net_name, … … 510 525 r->out.parm_err, 511 526 &werr); 527 if (!NT_STATUS_IS_OK(status)) { 528 werr = ntstatus_to_werror(status); 529 goto done; 530 } 531 512 532 if (!W_ERROR_IS_OK(werr)) { 513 533 goto done; -
vendor/current/source3/lib/netapi/shutdown.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/cli_initshutdown.h" 26 #include "../librpc/gen_ndr/ndr_initshutdown_c.h" 27 #include "rpc_client/init_lsa.h" 27 28 28 29 /**************************************************************** … … 34 35 WERROR werr; 35 36 NTSTATUS status; 36 struct rpc_pipe_client *pipe_cli = NULL;37 37 struct lsa_StringLarge message; 38 struct dcerpc_binding_handle *b; 38 39 39 werr = libnetapi_ open_pipe(ctx, r->in.server_name,40 &ndr_table_initshutdown.syntax_id,41 &pipe_cli);40 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 41 &ndr_table_initshutdown.syntax_id, 42 &b); 42 43 if (!W_ERROR_IS_OK(werr)) { 43 44 goto done; … … 46 47 init_lsa_StringLarge(&message, r->in.message); 47 48 48 status = rpccli_initshutdown_Init(pipe_cli, talloc_tos(),49 status = dcerpc_initshutdown_Init(b, talloc_tos(), 49 50 NULL, 50 51 &message, … … 79 80 WERROR werr; 80 81 NTSTATUS status; 81 struct rpc_pipe_client *pipe_cli = NULL;82 struct dcerpc_binding_handle *b; 82 83 83 werr = libnetapi_ open_pipe(ctx, r->in.server_name,84 &ndr_table_initshutdown.syntax_id,85 &pipe_cli);84 werr = libnetapi_get_binding_handle(ctx, r->in.server_name, 85 &ndr_table_initshutdown.syntax_id, 86 &b); 86 87 if (!W_ERROR_IS_OK(werr)) { 87 88 goto done; 88 89 } 89 90 90 status = rpccli_initshutdown_Abort(pipe_cli, talloc_tos(),91 status = dcerpc_initshutdown_Abort(b, talloc_tos(), 91 92 NULL, 92 93 &werr); -
vendor/current/source3/lib/netapi/sid.c
r414 r740 21 21 22 22 #include "lib/netapi/netapi.h" 23 #include "../libcli/security/security.h" 23 24 24 25 /**************************************************************** -
vendor/current/source3/lib/netapi/user.c
r594 r740 24 24 #include "lib/netapi/netapi_private.h" 25 25 #include "lib/netapi/libnetapi.h" 26 #include "../librpc/gen_ndr/cli_samr.h" 26 #include "../librpc/gen_ndr/ndr_samr_c.h" 27 #include "rpc_client/init_samr.h" 28 #include "../libds/common/flags.h" 29 #include "rpc_client/init_lsa.h" 30 #include "../libcli/security/security.h" 31 #include "../libds/common/flag_mapping.h" 32 #include "rpc_client/cli_pipe.h" 27 33 28 34 /**************************************************************** … … 109 115 info21->lm_owf_password = zero_parameters; 110 116 info21->nt_owf_password = zero_parameters; 111 info21-> unknown3.string= NULL;117 info21->private_data.string = NULL; 112 118 info21->buf_count = 0; 113 119 info21->buffer = NULL; … … 124 130 info21->nt_password_set = 0; 125 131 info21->password_expired = infoX->usriX_password_expired; 126 info21-> unknown4= 0;132 info21->private_data_sensitive = 0; 127 133 } 128 134 … … 293 299 union samr_UserInfo user_info; 294 300 struct samr_UserInfo21 info21; 295 NTSTATUS status; 301 NTSTATUS status, result; 302 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 296 303 297 304 if (!uX) { … … 311 318 &user_info.info25.password); 312 319 313 status = rpccli_samr_SetUserInfo2(pipe_cli, talloc_tos(),320 status = dcerpc_samr_SetUserInfo2(b, talloc_tos(), 314 321 user_handle, 315 322 25, 316 &user_info );317 318 if (NT_STATUS_EQUAL(status, NT_STATUS (DCERPC_FAULT_INVALID_TAG))) {323 &user_info, 324 &result); 325 if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) { 319 326 320 327 user_info.info23.info = info21; … … 324 331 &user_info.info23.password); 325 332 326 status = rpccli_samr_SetUserInfo2(pipe_cli, talloc_tos(),333 status = dcerpc_samr_SetUserInfo2(b, talloc_tos(), 327 334 user_handle, 328 335 23, 329 &user_info); 336 &user_info, 337 &result); 338 if (!NT_STATUS_IS_OK(status)) { 339 return status; 340 } 341 } 342 343 if (!NT_STATUS_IS_OK(status)) { 344 return status; 330 345 } 331 346 } else { … … 333 348 user_info.info21 = info21; 334 349 335 status = rpccli_samr_SetUserInfo(pipe_cli, talloc_tos(),350 status = dcerpc_samr_SetUserInfo(b, talloc_tos(), 336 351 user_handle, 337 352 21, 338 &user_info); 339 } 340 341 return status; 353 &user_info, 354 &result); 355 if (!NT_STATUS_IS_OK(status)) { 356 return status; 357 } 358 } 359 360 return result; 342 361 } 343 362 … … 349 368 { 350 369 struct rpc_pipe_client *pipe_cli = NULL; 351 NTSTATUS status ;370 NTSTATUS status, result; 352 371 WERROR werr; 353 372 struct policy_handle connect_handle, domain_handle, user_handle; … … 359 378 uint32_t rid = 0; 360 379 struct USER_INFO_X uX; 380 struct dcerpc_binding_handle *b = NULL; 381 DATA_BLOB session_key; 361 382 362 383 ZERO_STRUCT(connect_handle); … … 385 406 goto done; 386 407 } 408 409 b = pipe_cli->binding_handle; 387 410 388 411 status = construct_USER_INFO_X(r->in.level, r->in.buffer, &uX); … … 407 430 init_lsa_String(&lsa_account_name, uX.usriX_name); 408 431 409 status = rpccli_samr_CreateUser2(pipe_cli, talloc_tos(),432 status = dcerpc_samr_CreateUser2(b, talloc_tos(), 410 433 &domain_handle, 411 434 &lsa_account_name, … … 418 441 &user_handle, 419 442 &access_granted, 420 &rid); 443 &rid, 444 &result); 421 445 if (!NT_STATUS_IS_OK(status)) { 422 446 werr = ntstatus_to_werror(status); 423 447 goto done; 424 448 } 425 426 status = rpccli_samr_QueryUserInfo(pipe_cli, talloc_tos(), 449 if (!NT_STATUS_IS_OK(result)) { 450 werr = ntstatus_to_werror(result); 451 goto done; 452 } 453 454 status = dcerpc_samr_QueryUserInfo(b, talloc_tos(), 427 455 &user_handle, 428 456 16, 429 &user_info); 457 &user_info, 458 &result); 430 459 if (!NT_STATUS_IS_OK(status)) { 431 460 werr = ntstatus_to_werror(status); 461 goto done; 462 } 463 if (!NT_STATUS_IS_OK(result)) { 464 werr = ntstatus_to_werror(result); 432 465 goto done; 433 466 } … … 438 471 } 439 472 440 status = rpccli_samr_GetUserPwInfo(pipe_cli, talloc_tos(),473 status = dcerpc_samr_GetUserPwInfo(b, talloc_tos(), 441 474 &user_handle, 442 &pw_info); 475 &pw_info, 476 &result); 443 477 if (!NT_STATUS_IS_OK(status)) { 444 478 werr = ntstatus_to_werror(status); 445 479 goto done; 446 480 } 481 if (!NT_STATUS_IS_OK(result)) { 482 werr = ntstatus_to_werror(result); 483 goto done; 484 } 485 486 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 487 if (!NT_STATUS_IS_OK(status)) { 488 werr = ntstatus_to_werror(status); 489 goto done; 490 } 447 491 448 492 uX.usriX_flags |= ACB_NORMAL; 449 493 450 494 status = set_user_info_USER_INFO_X(ctx, pipe_cli, 451 & pipe_cli->auth->user_session_key,495 &session_key, 452 496 &user_handle, 453 497 &uX); … … 461 505 462 506 failed: 463 rpccli_samr_DeleteUser(pipe_cli, talloc_tos(), 464 &user_handle); 507 dcerpc_samr_DeleteUser(b, talloc_tos(), 508 &user_handle, 509 &result); 465 510 466 511 done: 467 if (is_valid_policy_hnd(&user_handle) && pipe_cli) {468 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);512 if (is_valid_policy_hnd(&user_handle) && b) { 513 dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result); 469 514 } 470 515 … … 493 538 { 494 539 struct rpc_pipe_client *pipe_cli = NULL; 495 NTSTATUS status ;540 NTSTATUS status, result; 496 541 WERROR werr; 497 542 struct policy_handle connect_handle, builtin_handle, domain_handle, user_handle; … … 500 545 struct dom_sid2 *domain_sid = NULL; 501 546 struct dom_sid2 user_sid; 547 struct dcerpc_binding_handle *b = NULL; 502 548 503 549 ZERO_STRUCT(connect_handle); … … 513 559 goto done; 514 560 } 561 562 b = pipe_cli->binding_handle; 515 563 516 564 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 525 573 } 526 574 527 status = rpccli_samr_OpenDomain(pipe_cli, talloc_tos(),575 status = dcerpc_samr_OpenDomain(b, talloc_tos(), 528 576 &connect_handle, 529 577 SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, 530 CONST_DISCARD(DOM_SID *, &global_sid_Builtin), 531 &builtin_handle); 578 CONST_DISCARD(struct dom_sid *, &global_sid_Builtin), 579 &builtin_handle, 580 &result); 532 581 if (!NT_STATUS_IS_OK(status)) { 533 582 werr = ntstatus_to_werror(status); 534 583 goto done; 535 584 } 585 if (!NT_STATUS_IS_OK(result)) { 586 werr = ntstatus_to_werror(result); 587 goto done; 588 } 536 589 537 590 init_lsa_String(&lsa_account_name, r->in.user_name); 538 591 539 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),592 status = dcerpc_samr_LookupNames(b, talloc_tos(), 540 593 &domain_handle, 541 594 1, 542 595 &lsa_account_name, 543 596 &user_rids, 544 &name_types); 597 &name_types, 598 &result); 545 599 if (!NT_STATUS_IS_OK(status)) { 546 600 werr = ntstatus_to_werror(status); 547 601 goto done; 548 602 } 549 550 status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(), 603 if (!NT_STATUS_IS_OK(result)) { 604 werr = ntstatus_to_werror(result); 605 goto done; 606 } 607 608 status = dcerpc_samr_OpenUser(b, talloc_tos(), 551 609 &domain_handle, 552 610 SEC_STD_DELETE, 553 611 user_rids.ids[0], 554 &user_handle); 612 &user_handle, 613 &result); 555 614 if (!NT_STATUS_IS_OK(status)) { 556 615 werr = ntstatus_to_werror(status); 557 616 goto done; 558 617 } 618 if (!NT_STATUS_IS_OK(result)) { 619 werr = ntstatus_to_werror(result); 620 goto done; 621 } 559 622 560 623 sid_compose(&user_sid, domain_sid, user_rids.ids[0]); 561 624 562 status = rpccli_samr_RemoveMemberFromForeignDomain(pipe_cli, talloc_tos(),625 status = dcerpc_samr_RemoveMemberFromForeignDomain(b, talloc_tos(), 563 626 &builtin_handle, 564 &user_sid); 627 &user_sid, 628 &result); 565 629 if (!NT_STATUS_IS_OK(status)) { 566 630 werr = ntstatus_to_werror(status); 567 631 goto done; 568 632 } 569 570 status = rpccli_samr_DeleteUser(pipe_cli, talloc_tos(), 571 &user_handle); 633 if (!NT_STATUS_IS_OK(result)) { 634 werr = ntstatus_to_werror(result); 635 goto done; 636 } 637 638 status = dcerpc_samr_DeleteUser(b, talloc_tos(), 639 &user_handle, 640 &result); 572 641 if (!NT_STATUS_IS_OK(status)) { 573 642 werr = ntstatus_to_werror(status); 643 goto done; 644 } 645 if (!NT_STATUS_IS_OK(result)) { 646 werr = ntstatus_to_werror(result); 574 647 goto done; 575 648 } … … 579 652 done: 580 653 if (is_valid_policy_hnd(&user_handle)) { 581 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);654 dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result); 582 655 } 583 656 … … 615 688 uint32_t *auth_flag_p) 616 689 { 617 NTSTATUS status ;690 NTSTATUS status, result; 618 691 619 692 struct policy_handle user_handle; … … 623 696 SAMR_USER_ACCESS_GET_ATTRIBUTES | 624 697 SAMR_USER_ACCESS_GET_NAME_ETC; 698 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 625 699 626 700 ZERO_STRUCT(user_handle); … … 653 727 } 654 728 655 status = rpccli_samr_OpenUser(pipe_cli, mem_ctx,729 status = dcerpc_samr_OpenUser(b, mem_ctx, 656 730 domain_handle, 657 731 access_mask, 658 732 rid, 659 &user_handle); 660 if (!NT_STATUS_IS_OK(status)) { 661 goto done; 662 } 663 664 status = rpccli_samr_QueryUserInfo(pipe_cli, mem_ctx, 733 &user_handle, 734 &result); 735 if (!NT_STATUS_IS_OK(status)) { 736 goto done; 737 } 738 if (!NT_STATUS_IS_OK(result)) { 739 status = result; 740 goto done; 741 } 742 743 status = dcerpc_samr_QueryUserInfo(b, mem_ctx, 665 744 &user_handle, 666 745 21, 667 &user_info); 668 if (!NT_STATUS_IS_OK(status)) { 669 goto done; 670 } 671 672 status = rpccli_samr_QuerySecurity(pipe_cli, mem_ctx, 746 &user_info, 747 &result); 748 if (!NT_STATUS_IS_OK(status)) { 749 goto done; 750 } 751 if (!NT_STATUS_IS_OK(result)) { 752 status = result; 753 goto done; 754 } 755 756 status = dcerpc_samr_QuerySecurity(b, mem_ctx, 673 757 &user_handle, 674 758 SECINFO_DACL, 675 sec_desc); 676 if (!NT_STATUS_IS_OK(status)) { 759 sec_desc, 760 &result); 761 if (!NT_STATUS_IS_OK(status)) { 762 goto done; 763 } 764 if (!NT_STATUS_IS_OK(result)) { 765 status = result; 677 766 goto done; 678 767 } … … 686 775 struct dom_sid sid; 687 776 688 status = rpccli_samr_GetGroupsForUser(pipe_cli, mem_ctx,777 status = dcerpc_samr_GetGroupsForUser(b, mem_ctx, 689 778 &user_handle, 690 &rid_array); 779 &rid_array, 780 &result); 691 781 if (!NT_STATUS_IS_OK(status)) { 782 goto done; 783 } 784 if (!NT_STATUS_IS_OK(result)) { 785 status = result; 692 786 goto done; 693 787 } … … 700 794 for (i=0; i<rid_array->count; i++) { 701 795 sid_compose(&sid, domain_sid, rid_array->rids[i].rid); 702 sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sid);796 sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sid); 703 797 NT_STATUS_HAVE_NO_MEMORY(sid_array.sids[i].sid); 704 798 } 705 799 706 800 sid_compose(&sid, domain_sid, rid); 707 sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sid);801 sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sid); 708 802 NT_STATUS_HAVE_NO_MEMORY(sid_array.sids[i].sid); 709 803 710 status = rpccli_samr_GetAliasMembership(pipe_cli, mem_ctx,804 status = dcerpc_samr_GetAliasMembership(b, mem_ctx, 711 805 builtin_handle, 712 806 &sid_array, 713 &alias_rids); 807 &alias_rids, 808 &result); 714 809 if (!NT_STATUS_IS_OK(status)) { 810 goto done; 811 } 812 if (!NT_STATUS_IS_OK(result)) { 813 status = result; 715 814 goto done; 716 815 } … … 741 840 done: 742 841 if (is_valid_policy_hnd(&user_handle)) { 743 rpccli_samr_Close(pipe_cli, mem_ctx, &user_handle);842 dcerpc_samr_Close(b, mem_ctx, &user_handle, &result); 744 843 } 745 844 … … 918 1017 return NT_STATUS_NO_MEMORY; 919 1018 } 920 i->usri4_user_sid = (struct domsid *) sid_dup_talloc(mem_ctx, &sid);1019 i->usri4_user_sid = (struct domsid *)dom_sid_dup(mem_ctx, &sid); 921 1020 i->usri4_primary_group_id = i21->primary_gid; 922 1021 i->usri4_profile = talloc_strdup(mem_ctx, i21->profile_path.string); … … 1019 1118 return NT_STATUS_NO_MEMORY; 1020 1119 } 1021 i->usri23_user_sid = (struct domsid *) sid_dup_talloc(mem_ctx, &sid);1120 i->usri23_user_sid = (struct domsid *)dom_sid_dup(mem_ctx, &sid); 1022 1121 1023 1122 return NT_STATUS_OK; … … 1185 1284 1186 1285 NTSTATUS status = NT_STATUS_OK; 1286 NTSTATUS result = NT_STATUS_OK; 1187 1287 WERROR werr; 1288 struct dcerpc_binding_handle *b = NULL; 1188 1289 1189 1290 ZERO_STRUCT(connect_handle); … … 1220 1321 } 1221 1322 1323 b = pipe_cli->binding_handle; 1324 1222 1325 werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli, 1223 1326 SAMR_ACCESS_ENUM_DOMAINS | … … 1264 1367 } 1265 1368 1266 status = rpccli_samr_EnumDomainUsers(pipe_cli,1369 status = dcerpc_samr_EnumDomainUsers(b, 1267 1370 ctx, 1268 1371 &domain_handle, … … 1271 1374 &sam, 1272 1375 r->in.prefmaxlen, 1273 &entries_read); 1274 werr = ntstatus_to_werror(status); 1275 if (NT_STATUS_IS_ERR(status)) { 1376 &entries_read, 1377 &result); 1378 if (!NT_STATUS_IS_OK(status)) { 1379 werr = ntstatus_to_werror(status); 1380 goto done; 1381 } 1382 werr = ntstatus_to_werror(result); 1383 if (NT_STATUS_IS_ERR(result)) { 1276 1384 goto done; 1277 1385 } … … 1296 1404 done: 1297 1405 /* if last query */ 1298 if (NT_STATUS_IS_OK( status) ||1299 NT_STATUS_IS_ERR( status)) {1406 if (NT_STATUS_IS_OK(result) || 1407 NT_STATUS_IS_ERR(result)) { 1300 1408 1301 1409 if (ctx->disable_policy_handle_cache) { … … 1490 1598 struct policy_handle domain_handle; 1491 1599 union samr_DispInfo info; 1600 struct dcerpc_binding_handle *b = NULL; 1492 1601 1493 1602 uint32_t total_size = 0; … … 1495 1604 1496 1605 NTSTATUS status = NT_STATUS_OK; 1606 NTSTATUS result = NT_STATUS_OK; 1497 1607 WERROR werr; 1498 1608 WERROR werr_tmp; … … 1518 1628 goto done; 1519 1629 } 1630 1631 b = pipe_cli->binding_handle; 1520 1632 1521 1633 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 1532 1644 } 1533 1645 1534 status = rpccli_samr_QueryDisplayInfo2(pipe_cli,1646 status = dcerpc_samr_QueryDisplayInfo2(b, 1535 1647 ctx, 1536 1648 &domain_handle, … … 1541 1653 &total_size, 1542 1654 &returned_size, 1543 &info); 1544 werr = ntstatus_to_werror(status); 1545 if (NT_STATUS_IS_ERR(status)) { 1655 &info, 1656 &result); 1657 if (!NT_STATUS_IS_OK(status)) { 1658 werr = ntstatus_to_werror(status); 1659 goto done; 1660 } 1661 werr = ntstatus_to_werror(result); 1662 if (NT_STATUS_IS_ERR(result)) { 1546 1663 goto done; 1547 1664 } … … 1556 1673 done: 1557 1674 /* if last query */ 1558 if (NT_STATUS_IS_OK( status) ||1559 NT_STATUS_IS_ERR( status)) {1675 if (NT_STATUS_IS_OK(result) || 1676 NT_STATUS_IS_ERR(result)) { 1560 1677 1561 1678 if (ctx->disable_policy_handle_cache) { … … 1604 1721 { 1605 1722 struct rpc_pipe_client *pipe_cli = NULL; 1606 NTSTATUS status ;1723 NTSTATUS status, result; 1607 1724 WERROR werr; 1608 1725 … … 1612 1729 struct samr_Ids user_rids, name_types; 1613 1730 uint32_t num_entries = 0; 1731 struct dcerpc_binding_handle *b = NULL; 1614 1732 1615 1733 ZERO_STRUCT(connect_handle); … … 1645 1763 } 1646 1764 1765 b = pipe_cli->binding_handle; 1766 1647 1767 werr = libnetapi_samr_open_domain(ctx, pipe_cli, 1648 1768 SAMR_ACCESS_ENUM_DOMAINS | … … 1669 1789 init_lsa_String(&lsa_account_name, r->in.user_name); 1670 1790 1671 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1791 status = dcerpc_samr_LookupNames(b, talloc_tos(), 1672 1792 &domain_handle, 1673 1793 1, 1674 1794 &lsa_account_name, 1675 1795 &user_rids, 1676 &name_types); 1796 &name_types, 1797 &result); 1677 1798 if (!NT_STATUS_IS_OK(status)) { 1678 1799 werr = ntstatus_to_werror(status); 1800 goto done; 1801 } 1802 if (!NT_STATUS_IS_OK(result)) { 1803 werr = ntstatus_to_werror(result); 1679 1804 goto done; 1680 1805 } … … 1695 1820 1696 1821 done: 1697 if (is_valid_policy_hnd(&user_handle) && pipe_cli) {1698 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);1822 if (is_valid_policy_hnd(&user_handle) && b) { 1823 dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result); 1699 1824 } 1700 1825 … … 1723 1848 { 1724 1849 struct rpc_pipe_client *pipe_cli = NULL; 1725 NTSTATUS status ;1850 NTSTATUS status, result; 1726 1851 WERROR werr; 1727 1852 … … 1733 1858 1734 1859 struct USER_INFO_X uX; 1860 struct dcerpc_binding_handle *b = NULL; 1861 DATA_BLOB session_key; 1735 1862 1736 1863 ZERO_STRUCT(connect_handle); … … 1767 1894 break; 1768 1895 case 3: 1769 user_mask = S TD_RIGHT_READ_CONTROL_ACCESS|1770 S TD_RIGHT_WRITE_DAC_ACCESS|1896 user_mask = SEC_STD_READ_CONTROL | 1897 SEC_STD_WRITE_DAC | 1771 1898 SAMR_USER_ACCESS_GET_GROUPS | 1772 1899 SAMR_USER_ACCESS_SET_PASSWORD | … … 1799 1926 } 1800 1927 1928 b = pipe_cli->binding_handle; 1929 1801 1930 werr = libnetapi_samr_open_domain(ctx, pipe_cli, 1802 1931 SAMR_ACCESS_ENUM_DOMAINS | … … 1824 1953 init_lsa_String(&lsa_account_name, r->in.user_name); 1825 1954 1826 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),1955 status = dcerpc_samr_LookupNames(b, talloc_tos(), 1827 1956 &domain_handle, 1828 1957 1, 1829 1958 &lsa_account_name, 1830 1959 &user_rids, 1831 &name_types); 1960 &name_types, 1961 &result); 1832 1962 if (!NT_STATUS_IS_OK(status)) { 1833 1963 werr = ntstatus_to_werror(status); 1834 1964 goto done; 1835 1965 } 1836 1837 status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(), 1966 if (!NT_STATUS_IS_OK(result)) { 1967 werr = ntstatus_to_werror(result); 1968 goto done; 1969 } 1970 1971 status = dcerpc_samr_OpenUser(b, talloc_tos(), 1838 1972 &domain_handle, 1839 1973 user_mask, 1840 1974 user_rids.ids[0], 1841 &user_handle); 1975 &user_handle, 1976 &result); 1842 1977 if (!NT_STATUS_IS_OK(status)) { 1843 1978 werr = ntstatus_to_werror(status); 1844 1979 goto done; 1845 1980 } 1981 if (!NT_STATUS_IS_OK(result)) { 1982 werr = ntstatus_to_werror(result); 1983 goto done; 1984 } 1846 1985 1847 1986 status = construct_USER_INFO_X(r->in.level, r->in.buffer, &uX); … … 1851 1990 } 1852 1991 1992 status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key); 1993 if (!NT_STATUS_IS_OK(status)) { 1994 werr = ntstatus_to_werror(status); 1995 goto done; 1996 } 1997 1853 1998 status = set_user_info_USER_INFO_X(ctx, pipe_cli, 1854 & pipe_cli->auth->user_session_key,1999 &session_key, 1855 2000 &user_handle, 1856 2001 &uX); … … 1863 2008 1864 2009 done: 1865 if (is_valid_policy_hnd(&user_handle) && pipe_cli) {1866 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);2010 if (is_valid_policy_hnd(&user_handle) && b) { 2011 dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result); 1867 2012 } 1868 2013 … … 1898 2043 struct samr_DomInfo12 *info12) 1899 2044 { 1900 NTSTATUS status ;2045 NTSTATUS status, result; 1901 2046 union samr_DomainInfo *dom_info = NULL; 2047 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 1902 2048 1903 2049 if (info1) { 1904 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,2050 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1905 2051 domain_handle, 1906 2052 1, 1907 &dom_info); 2053 &dom_info, 2054 &result); 1908 2055 NT_STATUS_NOT_OK_RETURN(status); 2056 NT_STATUS_NOT_OK_RETURN(result); 1909 2057 1910 2058 *info1 = dom_info->info1; … … 1912 2060 1913 2061 if (info3) { 1914 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,2062 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1915 2063 domain_handle, 1916 2064 3, 1917 &dom_info); 2065 &dom_info, 2066 &result); 1918 2067 NT_STATUS_NOT_OK_RETURN(status); 2068 NT_STATUS_NOT_OK_RETURN(result); 1919 2069 1920 2070 *info3 = dom_info->info3; … … 1922 2072 1923 2073 if (info5) { 1924 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,2074 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1925 2075 domain_handle, 1926 2076 5, 1927 &dom_info); 2077 &dom_info, 2078 &result); 1928 2079 NT_STATUS_NOT_OK_RETURN(status); 2080 NT_STATUS_NOT_OK_RETURN(result); 1929 2081 1930 2082 *info5 = dom_info->info5; … … 1932 2084 1933 2085 if (info6) { 1934 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,2086 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1935 2087 domain_handle, 1936 2088 6, 1937 &dom_info); 2089 &dom_info, 2090 &result); 1938 2091 NT_STATUS_NOT_OK_RETURN(status); 2092 NT_STATUS_NOT_OK_RETURN(result); 1939 2093 1940 2094 *info6 = dom_info->info6; … … 1942 2096 1943 2097 if (info7) { 1944 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,2098 status = dcerpc_samr_QueryDomainInfo(b, mem_ctx, 1945 2099 domain_handle, 1946 2100 7, 1947 &dom_info); 2101 &dom_info, 2102 &result); 1948 2103 NT_STATUS_NOT_OK_RETURN(status); 2104 NT_STATUS_NOT_OK_RETURN(result); 1949 2105 1950 2106 *info7 = dom_info->info7; … … 1952 2108 1953 2109 if (info12) { 1954 status = rpccli_samr_QueryDomainInfo2(pipe_cli, mem_ctx,2110 status = dcerpc_samr_QueryDomainInfo2(b, mem_ctx, 1955 2111 domain_handle, 1956 2112 12, 1957 &dom_info); 2113 &dom_info, 2114 &result); 1958 2115 NT_STATUS_NOT_OK_RETURN(status); 2116 NT_STATUS_NOT_OK_RETURN(result); 1959 2117 1960 2118 *info12 = dom_info->info12; … … 2061 2219 talloc_strdup(mem_ctx, dom_info5.domain_name.string); 2062 2220 info2->usrmod2_domain_id = 2063 (struct domsid *) sid_dup_talloc(mem_ctx, domain_sid);2221 (struct domsid *)dom_sid_dup(mem_ctx, domain_sid); 2064 2222 2065 2223 NT_STATUS_HAVE_NO_MEMORY(info2->usrmod2_domain_name); … … 2274 2432 struct samr_DomInfo12 *info12) 2275 2433 { 2276 NTSTATUS status ;2434 NTSTATUS status, result; 2277 2435 union samr_DomainInfo dom_info; 2436 struct dcerpc_binding_handle *b = pipe_cli->binding_handle; 2278 2437 2279 2438 if (info1) { … … 2283 2442 dom_info.info1 = *info1; 2284 2443 2285 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,2444 status = dcerpc_samr_SetDomainInfo(b, mem_ctx, 2286 2445 domain_handle, 2287 2446 1, 2288 &dom_info); 2447 &dom_info, 2448 &result); 2289 2449 NT_STATUS_NOT_OK_RETURN(status); 2450 NT_STATUS_NOT_OK_RETURN(result); 2290 2451 } 2291 2452 … … 2296 2457 dom_info.info3 = *info3; 2297 2458 2298 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,2459 status = dcerpc_samr_SetDomainInfo(b, mem_ctx, 2299 2460 domain_handle, 2300 2461 3, 2301 &dom_info); 2462 &dom_info, 2463 &result); 2302 2464 2303 2465 NT_STATUS_NOT_OK_RETURN(status); 2466 NT_STATUS_NOT_OK_RETURN(result); 2304 2467 } 2305 2468 … … 2310 2473 dom_info.info12 = *info12; 2311 2474 2312 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,2475 status = dcerpc_samr_SetDomainInfo(b, mem_ctx, 2313 2476 domain_handle, 2314 2477 12, 2315 &dom_info); 2478 &dom_info, 2479 &result); 2316 2480 2317 2481 NT_STATUS_NOT_OK_RETURN(status); 2482 NT_STATUS_NOT_OK_RETURN(result); 2318 2483 } 2319 2484 … … 2802 2967 2803 2968 NTSTATUS status = NT_STATUS_OK; 2969 NTSTATUS result = NT_STATUS_OK; 2804 2970 WERROR werr; 2971 struct dcerpc_binding_handle *b = NULL; 2805 2972 2806 2973 ZERO_STRUCT(connect_handle); … … 2829 2996 goto done; 2830 2997 } 2998 2999 b = pipe_cli->binding_handle; 2831 3000 2832 3001 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 2843 3012 init_lsa_String(&lsa_account_name, r->in.user_name); 2844 3013 2845 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),3014 status = dcerpc_samr_LookupNames(b, talloc_tos(), 2846 3015 &domain_handle, 2847 3016 1, 2848 3017 &lsa_account_name, 2849 3018 &user_rids, 2850 &name_types); 3019 &name_types, 3020 &result); 2851 3021 if (!NT_STATUS_IS_OK(status)) { 2852 3022 werr = ntstatus_to_werror(status); 2853 3023 goto done; 2854 3024 } 2855 2856 status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(), 3025 if (!NT_STATUS_IS_OK(result)) { 3026 werr = ntstatus_to_werror(result); 3027 goto done; 3028 } 3029 3030 status = dcerpc_samr_OpenUser(b, talloc_tos(), 2857 3031 &domain_handle, 2858 3032 SAMR_USER_ACCESS_GET_GROUPS, 2859 3033 user_rids.ids[0], 2860 &user_handle); 3034 &user_handle, 3035 &result); 2861 3036 if (!NT_STATUS_IS_OK(status)) { 2862 3037 werr = ntstatus_to_werror(status); 2863 3038 goto done; 2864 3039 } 2865 2866 status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(), 3040 if (!NT_STATUS_IS_OK(result)) { 3041 werr = ntstatus_to_werror(result); 3042 goto done; 3043 } 3044 3045 status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(), 2867 3046 &user_handle, 2868 &rid_array); 3047 &rid_array, 3048 &result); 2869 3049 if (!NT_STATUS_IS_OK(status)) { 2870 3050 werr = ntstatus_to_werror(status); 3051 goto done; 3052 } 3053 if (!NT_STATUS_IS_OK(result)) { 3054 werr = ntstatus_to_werror(result); 2871 3055 goto done; 2872 3056 } … … 2882 3066 } 2883 3067 2884 status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),3068 status = dcerpc_samr_LookupRids(b, talloc_tos(), 2885 3069 &domain_handle, 2886 3070 rid_array->count, 2887 3071 rids, 2888 3072 &names, 2889 &types );2890 if (!NT_STATUS_IS_OK(status) &&2891 !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {3073 &types, 3074 &result); 3075 if (!NT_STATUS_IS_OK(status)) { 2892 3076 werr = ntstatus_to_werror(status); 3077 goto done; 3078 } 3079 if (!NT_STATUS_IS_OK(result) && 3080 !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) { 3081 werr = ntstatus_to_werror(result); 2893 3082 goto done; 2894 3083 } … … 2957 3146 2958 3147 NTSTATUS status = NT_STATUS_OK; 3148 NTSTATUS result = NT_STATUS_OK; 2959 3149 WERROR werr; 3150 struct dcerpc_binding_handle *b = NULL; 2960 3151 2961 3152 ZERO_STRUCT(connect_handle); … … 2980 3171 goto done; 2981 3172 } 3173 3174 b = pipe_cli->binding_handle; 2982 3175 2983 3176 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 2994 3187 init_lsa_String(&lsa_account_name, r->in.user_name); 2995 3188 2996 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),3189 status = dcerpc_samr_LookupNames(b, talloc_tos(), 2997 3190 &domain_handle, 2998 3191 1, 2999 3192 &lsa_account_name, 3000 3193 &user_rids, 3001 &name_types); 3194 &name_types, 3195 &result); 3002 3196 if (!NT_STATUS_IS_OK(status)) { 3003 3197 werr = ntstatus_to_werror(status); 3004 3198 goto done; 3005 3199 } 3006 3007 status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(), 3200 if (!NT_STATUS_IS_OK(result)) { 3201 werr = ntstatus_to_werror(result); 3202 goto done; 3203 } 3204 3205 status = dcerpc_samr_OpenUser(b, talloc_tos(), 3008 3206 &domain_handle, 3009 3207 SAMR_USER_ACCESS_GET_GROUPS, 3010 3208 user_rids.ids[0], 3011 &user_handle); 3209 &user_handle, 3210 &result); 3012 3211 if (!NT_STATUS_IS_OK(status)) { 3013 3212 werr = ntstatus_to_werror(status); 3213 goto done; 3214 } 3215 if (!NT_STATUS_IS_OK(result)) { 3216 werr = ntstatus_to_werror(result); 3014 3217 goto done; 3015 3218 } … … 3044 3247 } 3045 3248 3046 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),3249 status = dcerpc_samr_LookupNames(b, talloc_tos(), 3047 3250 &domain_handle, 3048 3251 r->in.num_entries, 3049 3252 lsa_names, 3050 3253 &group_rids, 3051 &name_types); 3254 &name_types, 3255 &result); 3052 3256 if (!NT_STATUS_IS_OK(status)) { 3053 3257 werr = ntstatus_to_werror(status); 3258 goto done; 3259 } 3260 if (!NT_STATUS_IS_OK(result)) { 3261 werr = ntstatus_to_werror(result); 3054 3262 goto done; 3055 3263 } … … 3058 3266 num_member_rids = group_rids.count; 3059 3267 3060 status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(),3268 status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(), 3061 3269 &user_handle, 3062 &rid_array); 3270 &rid_array, 3271 &result); 3063 3272 if (!NT_STATUS_IS_OK(status)) { 3064 3273 werr = ntstatus_to_werror(status); 3274 goto done; 3275 } 3276 if (!NT_STATUS_IS_OK(result)) { 3277 werr = ntstatus_to_werror(result); 3065 3278 goto done; 3066 3279 } … … 3109 3322 3110 3323 for (i=0; i < num_add_rids; i++) { 3111 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),3324 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 3112 3325 &domain_handle, 3113 3326 SAMR_GROUP_ACCESS_ADD_MEMBER, 3114 3327 add_rids[i], 3115 &group_handle); 3328 &group_handle, 3329 &result); 3116 3330 if (!NT_STATUS_IS_OK(status)) { 3117 3331 werr = ntstatus_to_werror(status); 3118 3332 goto done; 3119 3333 } 3120 3121 status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(), 3334 if (!NT_STATUS_IS_OK(result)) { 3335 werr = ntstatus_to_werror(result); 3336 goto done; 3337 } 3338 3339 status = dcerpc_samr_AddGroupMember(b, talloc_tos(), 3122 3340 &group_handle, 3123 3341 user_rids.ids[0], 3124 7 /* ? */); 3342 7 /* ? */, 3343 &result); 3125 3344 if (!NT_STATUS_IS_OK(status)) { 3126 3345 werr = ntstatus_to_werror(status); 3127 3346 goto done; 3128 3347 } 3348 if (!NT_STATUS_IS_OK(result)) { 3349 werr = ntstatus_to_werror(result); 3350 goto done; 3351 } 3129 3352 3130 3353 if (is_valid_policy_hnd(&group_handle)) { 3131 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);3354 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 3132 3355 } 3133 3356 } … … 3136 3359 3137 3360 for (i=0; i < num_del_rids; i++) { 3138 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),3361 status = dcerpc_samr_OpenGroup(b, talloc_tos(), 3139 3362 &domain_handle, 3140 3363 SAMR_GROUP_ACCESS_REMOVE_MEMBER, 3141 3364 del_rids[i], 3142 &group_handle); 3365 &group_handle, 3366 &result); 3143 3367 if (!NT_STATUS_IS_OK(status)) { 3144 3368 werr = ntstatus_to_werror(status); 3145 3369 goto done; 3146 3370 } 3147 3148 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(), 3371 if (!NT_STATUS_IS_OK(result)) { 3372 werr = ntstatus_to_werror(result); 3373 goto done; 3374 } 3375 3376 status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(), 3149 3377 &group_handle, 3150 user_rids.ids[0]); 3378 user_rids.ids[0], 3379 &result); 3151 3380 if (!NT_STATUS_IS_OK(status)) { 3152 3381 werr = ntstatus_to_werror(status); 3153 3382 goto done; 3154 3383 } 3384 if (!NT_STATUS_IS_OK(result)) { 3385 werr = ntstatus_to_werror(result); 3386 goto done; 3387 } 3155 3388 3156 3389 if (is_valid_policy_hnd(&group_handle)) { 3157 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);3390 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 3158 3391 } 3159 3392 } … … 3163 3396 done: 3164 3397 if (is_valid_policy_hnd(&group_handle)) { 3165 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);3398 dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result); 3166 3399 } 3167 3400 … … 3235 3468 3236 3469 NTSTATUS status = NT_STATUS_OK; 3470 NTSTATUS result = NT_STATUS_OK; 3237 3471 WERROR werr; 3472 struct dcerpc_binding_handle *b = NULL; 3238 3473 3239 3474 ZERO_STRUCT(connect_handle); … … 3262 3497 goto done; 3263 3498 } 3499 3500 b = pipe_cli->binding_handle; 3264 3501 3265 3502 werr = libnetapi_samr_open_domain(ctx, pipe_cli, … … 3288 3525 init_lsa_String(&lsa_account_name, r->in.user_name); 3289 3526 3290 status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),3527 status = dcerpc_samr_LookupNames(b, talloc_tos(), 3291 3528 &domain_handle, 3292 3529 1, 3293 3530 &lsa_account_name, 3294 3531 &user_rids, 3295 &name_types); 3532 &name_types, 3533 &result); 3296 3534 if (!NT_STATUS_IS_OK(status)) { 3297 3535 werr = ntstatus_to_werror(status); 3298 3536 goto done; 3299 3537 } 3300 3301 status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(), 3538 if (!NT_STATUS_IS_OK(result)) { 3539 werr = ntstatus_to_werror(result); 3540 goto done; 3541 } 3542 3543 status = dcerpc_samr_OpenUser(b, talloc_tos(), 3302 3544 &domain_handle, 3303 3545 SAMR_USER_ACCESS_GET_GROUPS, 3304 3546 user_rids.ids[0], 3305 &user_handle); 3547 &user_handle, 3548 &result); 3306 3549 if (!NT_STATUS_IS_OK(status)) { 3307 3550 werr = ntstatus_to_werror(status); 3308 3551 goto done; 3309 3552 } 3310 3311 status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(), 3553 if (!NT_STATUS_IS_OK(result)) { 3554 werr = ntstatus_to_werror(result); 3555 goto done; 3556 } 3557 3558 status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(), 3312 3559 &user_handle, 3313 &rid_array); 3560 &rid_array, 3561 &result); 3314 3562 if (!NT_STATUS_IS_OK(status)) { 3315 3563 werr = ntstatus_to_werror(status); 3564 goto done; 3565 } 3566 if (!NT_STATUS_IS_OK(result)) { 3567 werr = ntstatus_to_werror(result); 3316 3568 goto done; 3317 3569 } … … 3329 3581 } 3330 3582 3331 sid_array.sids[0].sid = sid_dup_talloc(ctx, &user_sid);3583 sid_array.sids[0].sid = dom_sid_dup(ctx, &user_sid); 3332 3584 if (!sid_array.sids[0].sid) { 3333 3585 werr = WERR_NOMEM; … … 3343 3595 } 3344 3596 3345 sid_array.sids[i+1].sid = sid_dup_talloc(ctx, &sid);3597 sid_array.sids[i+1].sid = dom_sid_dup(ctx, &sid); 3346 3598 if (!sid_array.sids[i+1].sid) { 3347 3599 werr = WERR_NOMEM; … … 3350 3602 } 3351 3603 3352 status = rpccli_samr_GetAliasMembership(pipe_cli, talloc_tos(),3604 status = dcerpc_samr_GetAliasMembership(b, talloc_tos(), 3353 3605 &domain_handle, 3354 3606 &sid_array, 3355 &domain_rids); 3607 &domain_rids, 3608 &result); 3356 3609 if (!NT_STATUS_IS_OK(status)) { 3357 3610 werr = ntstatus_to_werror(status); 3611 goto done; 3612 } 3613 if (!NT_STATUS_IS_OK(result)) { 3614 werr = ntstatus_to_werror(result); 3358 3615 goto done; 3359 3616 } … … 3367 3624 } 3368 3625 3369 status = rpccli_samr_GetAliasMembership(pipe_cli, talloc_tos(),3626 status = dcerpc_samr_GetAliasMembership(b, talloc_tos(), 3370 3627 &builtin_handle, 3371 3628 &sid_array, 3372 &builtin_rids); 3629 &builtin_rids, 3630 &result); 3373 3631 if (!NT_STATUS_IS_OK(status)) { 3374 3632 werr = ntstatus_to_werror(status); 3633 goto done; 3634 } 3635 if (!NT_STATUS_IS_OK(result)) { 3636 werr = ntstatus_to_werror(result); 3375 3637 goto done; 3376 3638 } … … 3384 3646 } 3385 3647 3386 status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),3648 status = dcerpc_samr_LookupRids(b, talloc_tos(), 3387 3649 &builtin_handle, 3388 3650 num_rids, 3389 3651 rids, 3390 3652 &names, 3391 &types); 3653 &types, 3654 &result); 3392 3655 if (!NT_STATUS_IS_OK(status)) { 3393 3656 werr = ntstatus_to_werror(status); 3657 goto done; 3658 } 3659 if (!NT_STATUS_IS_OK(result)) { 3660 werr = ntstatus_to_werror(result); 3394 3661 goto done; 3395 3662 }
Note:
See TracChangeset
for help on using the changeset viewer.