sync'ing up for 3.0alpha20 release
[Samba/gbeck.git] / source3 / rpc_client / cli_netlogon.c
blobeaee3c26e7c829fb00ac789c6ef3ff034e3a7d03
1 /*
2 Unix SMB/CIFS implementation.
3 NT Domain Authentication SMB / MSRPC client
4 Copyright (C) Andrew Tridgell 1992-2000
5 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
6 Copyright (C) Tim Potter 2001
7 Copyright (C) Paul Ashton 1997.
8 Copyright (C) Jeremy Allison 1998.
9 Copyright (C) Andrew Bartlett 2001.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "includes.h"
28 /* LSA Request Challenge. Sends our challenge to server, then gets
29 server response. These are used to generate the credentials. */
31 NTSTATUS cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal,
32 DOM_CHAL *srv_chal)
34 prs_struct qbuf, rbuf;
35 NET_Q_REQ_CHAL q;
36 NET_R_REQ_CHAL r;
37 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
38 extern pstring global_myname;
40 prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
41 prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
43 /* create and send a MSRPC command with api NET_REQCHAL */
45 DEBUG(4,("cli_net_req_chal: LSA Request Challenge from %s to %s: %s\n",
46 global_myname, cli->desthost, credstr(clnt_chal->data)));
48 /* store the parameters */
49 init_q_req_chal(&q, cli->srv_name_slash, global_myname, clnt_chal);
51 /* Marshall data and send request */
53 if (!net_io_q_req_chal("", &q, &qbuf, 0) ||
54 !rpc_api_pipe_req(cli, NET_REQCHAL, &qbuf, &rbuf)) {
55 goto done;
58 /* Unmarhall response */
60 if (!net_io_r_req_chal("", &r, &rbuf, 0)) {
61 goto done;
64 result = r.status;
66 /* Return result */
68 if (NT_STATUS_IS_OK(result)) {
69 memcpy(srv_chal, r.srv_chal.data, sizeof(srv_chal->data));
72 done:
73 prs_mem_free(&qbuf);
74 prs_mem_free(&rbuf);
76 return result;
79 /****************************************************************************
80 LSA Authenticate 2
82 Send the client credential, receive back a server credential.
83 Ensure that the server credential returned matches the session key
84 encrypt of the server challenge originally received. JRA.
85 ****************************************************************************/
87 NTSTATUS cli_net_auth2(struct cli_state *cli,
88 uint16 sec_chan,
89 uint32 neg_flags, DOM_CHAL *srv_chal)
91 prs_struct qbuf, rbuf;
92 NET_Q_AUTH_2 q;
93 NET_R_AUTH_2 r;
94 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
95 extern pstring global_myname;
97 prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
98 prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
100 /* create and send a MSRPC command with api NET_AUTH2 */
102 DEBUG(4,("cli_net_auth2: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
103 cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
104 credstr(cli->clnt_cred.challenge.data), neg_flags));
106 /* store the parameters */
107 init_q_auth_2(&q, cli->srv_name_slash, cli->mach_acct,
108 sec_chan, global_myname, &cli->clnt_cred.challenge,
109 neg_flags);
111 /* turn parameters into data stream */
113 if (!net_io_q_auth_2("", &q, &qbuf, 0) ||
114 !rpc_api_pipe_req(cli, NET_AUTH2, &qbuf, &rbuf)) {
115 goto done;
118 /* Unmarshall response */
120 if (!net_io_r_auth_2("", &r, &rbuf, 0)) {
121 goto done;
124 result = r.status;
126 if (NT_STATUS_IS_OK(result)) {
127 UTIME zerotime;
130 * Check the returned value using the initial
131 * server received challenge.
134 zerotime.time = 0;
135 if (cred_assert( &r.srv_chal, cli->sess_key, srv_chal,
136 zerotime) == 0) {
139 * Server replied with bad credential. Fail.
141 DEBUG(0,("cli_net_auth2: server %s replied with bad credential (bad machine \
142 password ?).\n", cli->desthost ));
143 result = NT_STATUS_ACCESS_DENIED;
144 goto done;
148 done:
149 prs_mem_free(&qbuf);
150 prs_mem_free(&rbuf);
152 return result;
155 /****************************************************************************
156 LSA Authenticate 3
158 Send the client credential, receive back a server credential.
159 Ensure that the server credential returned matches the session key
160 encrypt of the server challenge originally received. JRA.
161 ****************************************************************************/
163 NTSTATUS cli_net_auth3(struct cli_state *cli,
164 uint16 sec_chan,
165 uint32 *neg_flags, DOM_CHAL *srv_chal)
167 prs_struct qbuf, rbuf;
168 NET_Q_AUTH_3 q;
169 NET_R_AUTH_3 r;
170 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
171 extern pstring global_myname;
173 prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
174 prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
176 /* create and send a MSRPC command with api NET_AUTH2 */
178 DEBUG(4,("cli_net_auth3: srv:%s acct:%s sc:%x mc: %s chal %s neg: %x\n",
179 cli->srv_name_slash, cli->mach_acct, sec_chan, global_myname,
180 credstr(cli->clnt_cred.challenge.data), *neg_flags));
182 /* store the parameters */
183 init_q_auth_3(&q, cli->srv_name_slash, cli->mach_acct,
184 sec_chan, global_myname, &cli->clnt_cred.challenge,
185 *neg_flags);
187 /* turn parameters into data stream */
189 if (!net_io_q_auth_3("", &q, &qbuf, 0) ||
190 !rpc_api_pipe_req(cli, NET_AUTH3, &qbuf, &rbuf)) {
191 goto done;
194 /* Unmarshall response */
196 if (!net_io_r_auth_3("", &r, &rbuf, 0)) {
197 goto done;
200 result = r.status;
201 *neg_flags = r.srv_flgs.neg_flags;
203 if (NT_STATUS_IS_OK(result)) {
204 UTIME zerotime;
207 * Check the returned value using the initial
208 * server received challenge.
211 zerotime.time = 0;
212 if (cred_assert( &r.srv_chal, cli->sess_key, srv_chal,
213 zerotime) == 0) {
216 * Server replied with bad credential. Fail.
218 DEBUG(0,("cli_net_auth3: server %s replied with bad credential (bad machine \
219 password ?).\n", cli->desthost ));
220 result = NT_STATUS_ACCESS_DENIED;
221 goto done;
225 done:
226 prs_mem_free(&qbuf);
227 prs_mem_free(&rbuf);
229 return result;
232 /* Return the secure channel type depending on the server role. */
234 uint16 get_sec_chan(void)
236 uint16 sec_chan = SEC_CHAN_WKSTA;
238 switch (lp_server_role()) {
239 case ROLE_DOMAIN_PDC:
240 sec_chan = SEC_CHAN_DOMAIN;
241 break;
242 case ROLE_DOMAIN_BDC:
243 sec_chan = SEC_CHAN_BDC;
244 break;
247 return sec_chan;
250 /* Initialize domain session credentials */
252 NTSTATUS cli_nt_setup_creds(struct cli_state *cli,
253 uint16 sec_chan,
254 const unsigned char mach_pwd[16], uint32 *neg_flags, int level)
256 DOM_CHAL clnt_chal;
257 DOM_CHAL srv_chal;
258 UTIME zerotime;
259 NTSTATUS result;
261 /******************* Request Challenge ********************/
263 generate_random_buffer(clnt_chal.data, 8, False);
265 /* send a client challenge; receive a server challenge */
266 result = cli_net_req_chal(cli, &clnt_chal, &srv_chal);
268 if (!NT_STATUS_IS_OK(result)) {
269 DEBUG(0,("cli_nt_setup_creds: request challenge failed\n"));
270 return result;
273 /**************** Long-term Session key **************/
275 /* calculate the session key */
276 cred_session_key(&clnt_chal, &srv_chal, mach_pwd,
277 cli->sess_key);
278 memset((char *)cli->sess_key+8, '\0', 8);
280 /******************* Authenticate 2/3 ********************/
282 /* calculate auth-2/3 credentials */
283 zerotime.time = 0;
284 cred_create(cli->sess_key, &clnt_chal, zerotime, &cli->clnt_cred.challenge);
287 * Send client auth-2/3 challenge.
288 * Receive an auth-2/3 challenge response and check it.
290 switch (level) {
291 case 2:
292 result = cli_net_auth2(cli, sec_chan, *neg_flags, &srv_chal);
293 break;
294 case 3:
295 result = cli_net_auth3(cli, sec_chan, neg_flags, &srv_chal);
296 break;
297 default:
298 DEBUG(1,("cli_nt_setup_creds: unsupported auth level: %d\n", level));
299 break;
302 if (!NT_STATUS_IS_OK(result))
303 DEBUG(1,("cli_nt_setup_creds: auth%d challenge failed %s\n", level, nt_errstr(result)));
305 return result;
308 /* Logon Control 2 */
310 NTSTATUS cli_netlogon_logon_ctrl2(struct cli_state *cli, TALLOC_CTX *mem_ctx,
311 uint32 query_level)
313 prs_struct qbuf, rbuf;
314 NET_Q_LOGON_CTRL2 q;
315 NET_R_LOGON_CTRL2 r;
316 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
318 ZERO_STRUCT(q);
319 ZERO_STRUCT(r);
321 /* Initialise parse structures */
323 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
324 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
326 /* Initialise input parameters */
328 init_net_q_logon_ctrl2(&q, cli->srv_name_slash, query_level);
330 /* Marshall data and send request */
332 if (!net_io_q_logon_ctrl2("", &q, &qbuf, 0) ||
333 !rpc_api_pipe_req(cli, NET_LOGON_CTRL2, &qbuf, &rbuf)) {
334 result = NT_STATUS_UNSUCCESSFUL;
335 goto done;
338 /* Unmarshall response */
340 if (!net_io_r_logon_ctrl2("", &r, &rbuf, 0)) {
341 result = NT_STATUS_UNSUCCESSFUL;
342 goto done;
345 result = r.status;
347 done:
348 prs_mem_free(&qbuf);
349 prs_mem_free(&rbuf);
351 return result;
354 /****************************************************************************
355 Generate the next creds to use. Yuck - this is a cut&paste from another
356 file. They should be combined at some stage. )-:
357 ****************************************************************************/
359 static void gen_next_creds( struct cli_state *cli, DOM_CRED *new_clnt_cred)
362 * Create the new client credentials.
365 cli->clnt_cred.timestamp.time = time(NULL);
367 memcpy(new_clnt_cred, &cli->clnt_cred, sizeof(*new_clnt_cred));
369 /* Calculate the new credentials. */
370 cred_create(cli->sess_key, &(cli->clnt_cred.challenge),
371 new_clnt_cred->timestamp, &(new_clnt_cred->challenge));
374 /* Sam synchronisation */
376 NTSTATUS cli_netlogon_sam_sync(struct cli_state *cli, TALLOC_CTX *mem_ctx, DOM_CRED *ret_creds,
377 uint32 database_id, uint32 next_rid, uint32 *num_deltas,
378 SAM_DELTA_HDR **hdr_deltas,
379 SAM_DELTA_CTR **deltas)
381 prs_struct qbuf, rbuf;
382 NET_Q_SAM_SYNC q;
383 NET_R_SAM_SYNC r;
384 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
385 DOM_CRED clnt_creds;
387 ZERO_STRUCT(q);
388 ZERO_STRUCT(r);
390 /* Initialise parse structures */
392 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
393 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
395 /* Initialise input parameters */
397 gen_next_creds(cli, &clnt_creds);
399 init_net_q_sam_sync(&q, cli->srv_name_slash, cli->clnt_name_slash + 2,
400 &clnt_creds, ret_creds, database_id, next_rid);
402 /* Marshall data and send request */
404 if (!net_io_q_sam_sync("", &q, &qbuf, 0) ||
405 !rpc_api_pipe_req(cli, NET_SAM_SYNC, &qbuf, &rbuf)) {
406 result = NT_STATUS_UNSUCCESSFUL;
407 goto done;
410 /* Unmarshall response */
412 if (!net_io_r_sam_sync("", cli->sess_key, &r, &rbuf, 0)) {
413 result = NT_STATUS_UNSUCCESSFUL;
414 goto done;
417 /* Return results */
419 result = r.status;
420 *num_deltas = r.num_deltas2;
421 *hdr_deltas = r.hdr_deltas;
422 *deltas = r.deltas;
424 memcpy(ret_creds, &r.srv_creds, sizeof(*ret_creds));
426 done:
427 prs_mem_free(&qbuf);
428 prs_mem_free(&rbuf);
430 return result;
433 /* Sam synchronisation */
435 NTSTATUS cli_netlogon_sam_deltas(struct cli_state *cli, TALLOC_CTX *mem_ctx,
436 uint32 database_id, UINT64_S seqnum,
437 uint32 *num_deltas,
438 SAM_DELTA_HDR **hdr_deltas,
439 SAM_DELTA_CTR **deltas)
441 prs_struct qbuf, rbuf;
442 NET_Q_SAM_DELTAS q;
443 NET_R_SAM_DELTAS r;
444 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
445 DOM_CRED clnt_creds;
447 ZERO_STRUCT(q);
448 ZERO_STRUCT(r);
450 /* Initialise parse structures */
452 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
453 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
455 /* Initialise input parameters */
457 gen_next_creds(cli, &clnt_creds);
459 init_net_q_sam_deltas(&q, cli->srv_name_slash,
460 cli->clnt_name_slash + 2, &clnt_creds,
461 database_id, seqnum);
463 /* Marshall data and send request */
465 if (!net_io_q_sam_deltas("", &q, &qbuf, 0) ||
466 !rpc_api_pipe_req(cli, NET_SAM_DELTAS, &qbuf, &rbuf)) {
467 result = NT_STATUS_UNSUCCESSFUL;
468 goto done;
471 /* Unmarshall response */
473 if (!net_io_r_sam_deltas("", cli->sess_key, &r, &rbuf, 0)) {
474 result = NT_STATUS_UNSUCCESSFUL;
475 goto done;
478 /* Return results */
480 result = r.status;
481 *num_deltas = r.num_deltas2;
482 *hdr_deltas = r.hdr_deltas;
483 *deltas = r.deltas;
485 done:
486 prs_mem_free(&qbuf);
487 prs_mem_free(&rbuf);
489 return result;
492 /* Logon domain user */
494 NTSTATUS cli_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx,
495 char *username, char *password,
496 int logon_type)
498 prs_struct qbuf, rbuf;
499 NET_Q_SAM_LOGON q;
500 NET_R_SAM_LOGON r;
501 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
502 DOM_CRED clnt_creds, dummy_rtn_creds;
503 extern pstring global_myname;
504 NET_ID_INFO_CTR ctr;
505 NET_USER_INFO_3 user;
506 int validation_level = 3;
508 ZERO_STRUCT(q);
509 ZERO_STRUCT(r);
511 /* Initialise parse structures */
513 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
514 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
516 /* Initialise input parameters */
518 gen_next_creds(cli, &clnt_creds);
520 q.validation_level = validation_level;
522 memset(&dummy_rtn_creds, '\0', sizeof(dummy_rtn_creds));
523 dummy_rtn_creds.timestamp.time = time(NULL);
525 ctr.switch_value = logon_type;
527 switch (logon_type) {
528 case INTERACTIVE_LOGON_TYPE: {
529 unsigned char lm_owf_user_pwd[16], nt_owf_user_pwd[16];
531 nt_lm_owf_gen(password, nt_owf_user_pwd, lm_owf_user_pwd);
533 init_id_info1(&ctr.auth.id1, lp_workgroup(),
534 0, /* param_ctrl */
535 0xdead, 0xbeef, /* LUID? */
536 username, cli->clnt_name_slash,
537 cli->sess_key, lm_owf_user_pwd,
538 nt_owf_user_pwd);
540 break;
542 case NET_LOGON_TYPE: {
543 uint8 chal[8];
544 unsigned char local_lm_response[24];
545 unsigned char local_nt_response[24];
547 generate_random_buffer(chal, 8, False);
549 SMBencrypt(password, chal, local_lm_response);
550 SMBNTencrypt(password, chal, local_nt_response);
552 init_id_info2(&ctr.auth.id2, lp_workgroup(),
553 0, /* param_ctrl */
554 0xdead, 0xbeef, /* LUID? */
555 username, cli->clnt_name_slash, chal,
556 local_lm_response, 24, local_nt_response, 24);
557 break;
559 default:
560 DEBUG(0, ("switch value %d not supported\n",
561 ctr.switch_value));
562 goto done;
565 init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname,
566 &clnt_creds, &dummy_rtn_creds, logon_type,
567 &ctr);
569 /* Marshall data and send request */
571 if (!net_io_q_sam_logon("", &q, &qbuf, 0) ||
572 !rpc_api_pipe_req(cli, NET_SAMLOGON, &qbuf, &rbuf)) {
573 goto done;
576 /* Unmarshall response */
578 r.user = &user;
580 if (!net_io_r_sam_logon("", &r, &rbuf, 0)) {
581 goto done;
584 /* Return results */
586 result = r.status;
588 done:
589 prs_mem_free(&qbuf);
590 prs_mem_free(&rbuf);
592 return result;
596 /**
597 * Logon domain user with an 'network' SAM logon
599 * @param info3 Pointer to a NET_USER_INFO_3 already allocated by the caller.
602 NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx,
603 const char *username, const char *domain, const char *workstation,
604 const uint8 chal[8],
605 DATA_BLOB lm_response, DATA_BLOB nt_response,
606 NET_USER_INFO_3 *info3)
609 prs_struct qbuf, rbuf;
610 NET_Q_SAM_LOGON q;
611 NET_R_SAM_LOGON r;
612 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
613 DOM_CRED clnt_creds, dummy_rtn_creds;
614 NET_ID_INFO_CTR ctr;
615 extern pstring global_myname;
616 int validation_level = 3;
617 char *workstation_name_slash;
619 ZERO_STRUCT(q);
620 ZERO_STRUCT(r);
622 workstation_name_slash = talloc_asprintf(mem_ctx, "\\\\%s", workstation);
624 if (!workstation_name_slash) {
625 DEBUG(0, ("talloc_asprintf failed!\n"));
626 return NT_STATUS_NO_MEMORY;
629 /* Initialise parse structures */
631 prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
632 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
634 /* Initialise input parameters */
636 gen_next_creds(cli, &clnt_creds);
638 q.validation_level = validation_level;
640 memset(&dummy_rtn_creds, '\0', sizeof(dummy_rtn_creds));
641 dummy_rtn_creds.timestamp.time = time(NULL);
643 ctr.switch_value = NET_LOGON_TYPE;
645 init_id_info2(&ctr.auth.id2, domain,
646 0, /* param_ctrl */
647 0xdead, 0xbeef, /* LUID? */
648 username, workstation_name_slash, (const uchar*)chal,
649 lm_response.data, lm_response.length, nt_response.data, nt_response.length);
651 init_sam_info(&q.sam_id, cli->srv_name_slash, global_myname,
652 &clnt_creds, &dummy_rtn_creds, NET_LOGON_TYPE,
653 &ctr);
655 /* Marshall data and send request */
657 if (!net_io_q_sam_logon("", &q, &qbuf, 0) ||
658 !rpc_api_pipe_req(cli, NET_SAMLOGON, &qbuf, &rbuf)) {
659 goto done;
662 /* Unmarshall response */
664 r.user = info3;
666 if (!net_io_r_sam_logon("", &r, &rbuf, 0)) {
667 goto done;
670 /* Return results */
672 result = r.status;
674 done:
675 prs_mem_free(&qbuf);
676 prs_mem_free(&rbuf);
678 return result;
681 /***************************************************************************
682 LSA Server Password Set.
683 ****************************************************************************/
685 NTSTATUS cli_net_srv_pwset(struct cli_state *cli, TALLOC_CTX *mem_ctx,
686 char* machine_name, uint8 hashed_mach_pwd[16])
688 prs_struct rbuf;
689 prs_struct qbuf;
690 DOM_CRED new_clnt_cred;
691 NET_Q_SRV_PWSET q_s;
692 uint16 sec_chan_type = 2;
693 NTSTATUS nt_status;
694 char *mach_acct;
696 gen_next_creds( cli, &new_clnt_cred);
698 prs_init(&qbuf , 1024, mem_ctx, MARSHALL);
699 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
701 /* create and send a MSRPC command with api NET_SRV_PWSET */
703 mach_acct = talloc_asprintf(mem_ctx, "%s$", machine_name);
705 if (!mach_acct) {
706 DEBUG(0,("talloc_asprintf failed!\n"));
707 nt_status = NT_STATUS_NO_MEMORY;
708 goto done;
711 DEBUG(4,("cli_net_srv_pwset: srv:%s acct:%s sc: %d mc: %s clnt %s %x\n",
712 cli->srv_name_slash, mach_acct, sec_chan_type, machine_name,
713 credstr(new_clnt_cred.challenge.data), new_clnt_cred.timestamp.time));
715 /* store the parameters */
716 init_q_srv_pwset(&q_s, cli->srv_name_slash, cli->sess_key,
717 mach_acct, sec_chan_type, machine_name,
718 &new_clnt_cred, (char *)hashed_mach_pwd);
720 /* turn parameters into data stream */
721 if(!net_io_q_srv_pwset("", &q_s, &qbuf, 0)) {
722 DEBUG(0,("cli_net_srv_pwset: Error : failed to marshall NET_Q_SRV_PWSET struct.\n"));
723 nt_status = NT_STATUS_UNSUCCESSFUL;
724 goto done;
727 /* send the data on \PIPE\ */
728 if (rpc_api_pipe_req(cli, NET_SRVPWSET, &qbuf, &rbuf))
730 NET_R_SRV_PWSET r_s;
732 if (!net_io_r_srv_pwset("", &r_s, &rbuf, 0)) {
733 nt_status = NT_STATUS_UNSUCCESSFUL;
734 goto done;
737 nt_status = r_s.status;
739 if (!NT_STATUS_IS_OK(r_s.status))
741 /* report error code */
742 DEBUG(0,("cli_net_srv_pwset: %s\n", nt_errstr(nt_status)));
743 goto done;
746 /* Update the credentials. */
747 if (!clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &(r_s.srv_cred)))
750 * Server replied with bad credential. Fail.
752 DEBUG(0,("cli_net_srv_pwset: server %s replied with bad credential (bad machine \
753 password ?).\n", cli->desthost ));
754 nt_status = NT_STATUS_UNSUCCESSFUL;
758 done:
759 prs_mem_free(&qbuf);
760 prs_mem_free(&rbuf);
762 return nt_status;