Changeset 124 for branches/samba-3.0/source/rpc_client
- Timestamp:
- Mar 12, 2008, 9:08:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/rpc_client/cli_pipe.c
r1 r124 1807 1807 if (!NT_STATUS_IS_OK(nt_status)) { 1808 1808 DEBUG(0,("rpc_finish_auth3_bind: NTLMSSP update using server blob failed.\n")); 1809 data_blob_free(&server_response); 1809 1810 return nt_status; 1810 1811 } … … 2364 2365 } 2365 2366 2366 DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to machine %s and"2367 " bound NTLMSSP as user %s\\%s.\n",2367 DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to " 2368 "machine %s and bound NTLMSSP as user %s\\%s.\n", 2368 2369 result->pipe_name, cli->desthost, 2369 2370 domain, username )); … … 2424 2425 2425 2426 /**************************************************************************** 2426 Open a netlogon pipe and get the schannel session key. 2427 Now exposed to external callers. 2427 Get a the schannel session key out of an already opened netlogon pipe. 2428 2428 ****************************************************************************/ 2429 2430 struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli, 2431 const char *domain, 2432 uint32 *pneg_flags, 2433 NTSTATUS *perr) 2434 { 2435 struct rpc_pipe_client *netlogon_pipe = NULL; 2429 static BOOL get_schannel_session_key_common(struct rpc_pipe_client *netlogon_pipe, 2430 struct cli_state *cli, 2431 const char *domain, 2432 uint32 *pneg_flags, 2433 NTSTATUS *perr) 2434 { 2436 2435 uint32 sec_chan_type = 0; 2437 2436 unsigned char machine_pwd[16]; 2438 fstring machine_account; 2439 2440 netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, perr); 2441 if (!netlogon_pipe) { 2442 return NULL; 2443 } 2437 const char *machine_account; 2444 2438 2445 2439 /* Get the machine account credentials from secrets.tdb. */ 2446 if (!get_trust_pw(domain, machine_pwd, &sec_chan_type)) { 2440 if (!get_trust_pw_hash(domain, machine_pwd, &machine_account, 2441 &sec_chan_type)) 2442 { 2447 2443 DEBUG(0, ("get_schannel_session_key: could not fetch " 2448 2444 "trust account password for domain '%s'\n", 2449 2445 domain)); 2450 cli_rpc_pipe_close(netlogon_pipe);2451 2446 *perr = NT_STATUS_CANT_ACCESS_DOMAIN_INFO; 2452 return NULL; 2453 } 2454 2455 /* A DC should use DOMAIN$ as its account name. 2456 A member server can only use it's machine name since it 2457 does not have an account in a trusted domain. 2458 2459 We don't check the domain against lp_workgroup() here since 2460 'net ads join' has to continue to work with only the realm 2461 specified in smb.conf. -- jerry */ 2462 2463 if ( IS_DC && !strequal(domain, lp_workgroup()) && lp_allow_trusted_domains()) { 2464 fstrcpy( machine_account, lp_workgroup() ); 2465 } else { 2466 fstrcpy(machine_account, global_myname()); 2467 } 2447 return False; 2448 } 2468 2449 2469 2450 *perr = rpccli_netlogon_setup_creds(netlogon_pipe, … … 2477 2458 2478 2459 if (!NT_STATUS_IS_OK(*perr)) { 2479 DEBUG(3,("get_schannel_session_key : rpccli_netlogon_setup_creds "2460 DEBUG(3,("get_schannel_session_key_common: rpccli_netlogon_setup_creds " 2480 2461 "failed with result %s to server %s, domain %s, machine account %s.\n", 2481 2462 nt_errstr(*perr), cli->desthost, domain, machine_account )); 2482 cli_rpc_pipe_close(netlogon_pipe); 2483 return NULL; 2463 return False; 2484 2464 } 2485 2465 … … 2487 2467 DEBUG(3, ("get_schannel_session_key: Server %s did not offer schannel\n", 2488 2468 cli->desthost)); 2469 *perr = NT_STATUS_INVALID_NETWORK_RESPONSE; 2470 return False; 2471 } 2472 2473 return True; 2474 } 2475 2476 /**************************************************************************** 2477 Open a netlogon pipe and get the schannel session key. 2478 Now exposed to external callers. 2479 ****************************************************************************/ 2480 2481 2482 struct rpc_pipe_client *get_schannel_session_key(struct cli_state *cli, 2483 const char *domain, 2484 uint32 *pneg_flags, 2485 NTSTATUS *perr) 2486 { 2487 struct rpc_pipe_client *netlogon_pipe = NULL; 2488 2489 netlogon_pipe = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, perr); 2490 if (!netlogon_pipe) { 2491 return NULL; 2492 } 2493 2494 if (!get_schannel_session_key_common(netlogon_pipe, cli, domain, 2495 pneg_flags, perr)) 2496 { 2489 2497 cli_rpc_pipe_close(netlogon_pipe); 2490 *perr = NT_STATUS_INVALID_NETWORK_RESPONSE;2491 2498 return NULL; 2492 2499 } … … 2560 2567 { 2561 2568 struct rpc_pipe_client *netlogon_pipe = NULL; 2562 uint32 sec_chan_type = 0;2563 unsigned char machine_pwd[16];2564 fstring machine_account;2565 2569 2566 2570 netlogon_pipe = cli_rpc_pipe_open_spnego_ntlmssp(cli, PI_NETLOGON, PIPE_AUTH_LEVEL_PRIVACY, domain, username, password, perr); … … 2569 2573 } 2570 2574 2571 /* Get the machine account credentials from secrets.tdb. */ 2572 if (!get_trust_pw(domain, machine_pwd, &sec_chan_type)) { 2573 DEBUG(0, ("get_schannel_session_key_auth_ntlmssp: could not fetch " 2574 "trust account password for domain '%s'\n", 2575 domain)); 2575 if (!get_schannel_session_key_common(netlogon_pipe, cli, domain, 2576 pneg_flags, perr)) 2577 { 2576 2578 cli_rpc_pipe_close(netlogon_pipe); 2577 *perr = NT_STATUS_CANT_ACCESS_DOMAIN_INFO;2578 return NULL;2579 }2580 2581 /* if we are a DC and this is a trusted domain, then we need to use our2582 domain name in the net_req_auth2() request */2583 2584 if ( IS_DC && !strequal(domain, lp_workgroup()) && lp_allow_trusted_domains()) {2585 fstrcpy( machine_account, lp_workgroup() );2586 } else {2587 /* Hmmm. Is this correct for trusted domains when we're a member server ? JRA. */2588 if (strequal(domain, lp_workgroup())) {2589 fstrcpy(machine_account, global_myname());2590 } else {2591 fstrcpy(machine_account, domain);2592 }2593 }2594 2595 *perr = rpccli_netlogon_setup_creds(netlogon_pipe,2596 cli->desthost, /* server name */2597 domain, /* domain */2598 global_myname(), /* client name */2599 machine_account, /* machine account name */2600 machine_pwd,2601 sec_chan_type,2602 pneg_flags);2603 2604 if (!NT_STATUS_IS_OK(*perr)) {2605 DEBUG(3,("get_schannel_session_key_auth_ntlmssp: rpccli_netlogon_setup_creds "2606 "failed with result %s\n",2607 nt_errstr(*perr) ));2608 cli_rpc_pipe_close(netlogon_pipe);2609 return NULL;2610 }2611 2612 if (((*pneg_flags) & NETLOGON_NEG_SCHANNEL) == 0) {2613 DEBUG(3, ("get_schannel_session_key_auth_ntlmssp: Server %s did not offer schannel\n",2614 cli->desthost));2615 cli_rpc_pipe_close(netlogon_pipe);2616 *perr = NT_STATUS_INVALID_NETWORK_RESPONSE;2617 2579 return NULL; 2618 2580 } … … 2635 2597 NTSTATUS *perr) 2636 2598 { 2637 uint32 neg_flags = NETLOGON_NEG_ AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;2599 uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; 2638 2600 struct rpc_pipe_client *netlogon_pipe = NULL; 2639 2601 struct rpc_pipe_client *result = NULL; … … 2669 2631 NTSTATUS *perr) 2670 2632 { 2671 uint32 neg_flags = NETLOGON_NEG_ AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;2633 uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; 2672 2634 struct rpc_pipe_client *netlogon_pipe = NULL; 2673 2635 struct rpc_pipe_client *result = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.