Add my copyright.
[metze/samba/wip.git] / source3 / rpc_server / srv_netlog_nt.c
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  RPC Pipe client / server routines
4  *  Copyright (C) Andrew Tridgell              1992-1997,
5  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6  *  Copyright (C) Paul Ashton                       1997.
7  *  Copyright (C) Jeremy Allison               1998-2001.
8  *  Copyright (C) Andrew Bartlett                   2001.
9  *  Copyright (C) Guenther Deschner                 2008.
10  *
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 3 of the License, or
14  *  (at your option) any later version.
15  *
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.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 /* This is the implementation of the netlogon pipe. */
26
27 #include "includes.h"
28
29 extern userdom_struct current_user_info;
30
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
33
34 /*************************************************************************
35  init_net_r_req_chal:
36  *************************************************************************/
37
38 static void init_net_r_req_chal(struct netr_Credential *r,
39                                 struct netr_Credential *srv_chal)
40 {
41         DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__));
42
43         memcpy(r->data, srv_chal->data, sizeof(r->data));
44 }
45
46 /*******************************************************************
47  Inits a netr_NETLOGON_INFO_1 structure.
48 ********************************************************************/
49
50 static void init_netlogon_info1(struct netr_NETLOGON_INFO_1 *r,
51                                 uint32_t flags,
52                                 uint32_t pdc_connection_status)
53 {
54         r->flags = flags;
55         r->pdc_connection_status = pdc_connection_status;
56 }
57
58 /*******************************************************************
59  Inits a netr_NETLOGON_INFO_2 structure.
60 ********************************************************************/
61
62 static void init_netlogon_info2(struct netr_NETLOGON_INFO_2 *r,
63                                 uint32_t flags,
64                                 uint32_t pdc_connection_status,
65                                 const char *trusted_dc_name,
66                                 uint32_t tc_connection_status)
67 {
68         r->flags = flags;
69         r->pdc_connection_status = pdc_connection_status;
70         r->trusted_dc_name = trusted_dc_name;
71         r->tc_connection_status = tc_connection_status;
72 }
73
74 /*******************************************************************
75  Inits a netr_NETLOGON_INFO_3 structure.
76 ********************************************************************/
77
78 static void init_netlogon_info3(struct netr_NETLOGON_INFO_3 *r,
79                                 uint32_t flags,
80                                 uint32_t logon_attempts)
81 {
82         r->flags = flags;
83         r->logon_attempts = logon_attempts;
84 }
85
86 /*************************************************************************
87  _netr_LogonControl
88  *************************************************************************/
89
90 WERROR _netr_LogonControl(pipes_struct *p,
91                           struct netr_LogonControl *r)
92 {
93         struct netr_NETLOGON_INFO_1 *info1;
94         uint32_t flags = 0x0;
95         uint32_t pdc_connection_status = W_ERROR_V(WERR_OK);
96
97         /* Setup the Logon Control response */
98
99         switch (r->in.level) {
100                 case 1:
101                         info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
102                         if (!info1) {
103                                 return WERR_NOMEM;
104                         }
105                         init_netlogon_info1(info1,
106                                             flags,
107                                             pdc_connection_status);
108                         r->out.info->info1 = info1;
109                         break;
110                 default:
111                         return WERR_UNKNOWN_LEVEL;
112         }
113
114         return WERR_OK;
115 }
116
117 /****************************************************************************
118 Send a message to smbd to do a sam synchronisation
119 **************************************************************************/
120
121 static void send_sync_message(void)
122 {
123         DEBUG(3, ("sending sam synchronisation message\n"));
124         message_send_all(smbd_messaging_context(), MSG_SMB_SAM_SYNC, NULL, 0,
125                          NULL);
126 }
127
128 /*************************************************************************
129  _netr_LogonControl2
130  *************************************************************************/
131
132 WERROR _netr_LogonControl2(pipes_struct *p,
133                            struct netr_LogonControl2 *r)
134 {
135         uint32 flags = 0x0;
136         uint32 pdc_connection_status = 0x0;
137         uint32 logon_attempts = 0x0;
138         uint32 tc_status;
139         fstring dc_name, dc_name2;
140         struct sockaddr_storage dc_ss;
141         const char *domain = NULL;
142         struct netr_NETLOGON_INFO_1 *info1;
143         struct netr_NETLOGON_INFO_2 *info2;
144         struct netr_NETLOGON_INFO_3 *info3;
145
146         tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN);
147         fstrcpy( dc_name, "" );
148
149         switch (r->in.function_code) {
150                 case NETLOGON_CONTROL_TC_QUERY:
151                         domain = r->in.data->domain;
152
153                         if ( !is_trusted_domain( domain ) )
154                                 break;
155
156                         if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
157                                 tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS);
158                                 break;
159                         }
160
161                         fstr_sprintf( dc_name, "\\\\%s", dc_name2 );
162
163                         tc_status = W_ERROR_V(WERR_OK);
164
165                         break;
166
167                 case NETLOGON_CONTROL_REDISCOVER:
168                         domain = r->in.data->domain;
169
170                         if ( !is_trusted_domain( domain ) )
171                                 break;
172
173                         if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) {
174                                 tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS);
175                                 break;
176                         }
177
178                         fstr_sprintf( dc_name, "\\\\%s", dc_name2 );
179
180                         tc_status = W_ERROR_V(WERR_OK);
181
182                         break;
183
184                 default:
185                         /* no idea what this should be */
186                         DEBUG(0,("_netr_LogonControl2: unimplemented function level [%d]\n",
187                                 r->in.function_code));
188                         return WERR_UNKNOWN_LEVEL;
189         }
190
191         /* prepare the response */
192
193         switch (r->in.level) {
194                 case 1:
195                         info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1);
196                         W_ERROR_HAVE_NO_MEMORY(info1);
197
198                         init_netlogon_info1(info1,
199                                             flags,
200                                             pdc_connection_status);
201                         r->out.query->info1 = info1;
202                         break;
203                 case 2:
204                         info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2);
205                         W_ERROR_HAVE_NO_MEMORY(info2);
206
207                         init_netlogon_info2(info2,
208                                             flags,
209                                             pdc_connection_status,
210                                             dc_name,
211                                             tc_status);
212                         r->out.query->info2 = info2;
213                         break;
214                 case 3:
215                         info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3);
216                         W_ERROR_HAVE_NO_MEMORY(info3);
217
218                         init_netlogon_info3(info3,
219                                             flags,
220                                             logon_attempts);
221                         r->out.query->info3 = info3;
222                         break;
223                 default:
224                         return WERR_UNKNOWN_LEVEL;
225         }
226
227         if (lp_server_role() == ROLE_DOMAIN_BDC) {
228                 send_sync_message();
229         }
230
231         return WERR_OK;
232 }
233
234 /*************************************************************************
235  _netr_NetrEnumerateTrustedDomains
236  *************************************************************************/
237
238 WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p,
239                                          struct netr_NetrEnumerateTrustedDomains *r)
240 {
241         struct netr_Blob trusted_domains_blob;
242         DATA_BLOB blob;
243
244         DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
245
246         /* set up the Trusted Domain List response */
247
248         blob = data_blob_talloc_zero(p->mem_ctx, 2);
249         trusted_domains_blob.data = blob.data;
250         trusted_domains_blob.length = blob.length;
251
252         DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__));
253
254         *r->out.trusted_domains_blob = trusted_domains_blob;
255
256         return WERR_OK;
257 }
258
259 /******************************************************************
260  gets a machine password entry.  checks access rights of the host.
261  ******************************************************************/
262
263 static NTSTATUS get_md4pw(char *md4pw, const char *mach_acct, uint16 sec_chan_type)
264 {
265         struct samu *sampass = NULL;
266         const uint8 *pass;
267         bool ret;
268         uint32 acct_ctrl;
269
270 #if 0
271         char addr[INET6_ADDRSTRLEN];
272
273     /*
274      * Currently this code is redundent as we already have a filter
275      * by hostname list. What this code really needs to do is to
276      * get a hosts allowed/hosts denied list from the SAM database
277      * on a per user basis, and make the access decision there.
278      * I will leave this code here for now as a reminder to implement
279      * this at a later date. JRA.
280      */
281
282         if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(),
283                         client_name(get_client_fd()),
284                         client_addr(get_client_fd(),addr,sizeof(addr)))) {
285                 DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct));
286                 return False;
287         }
288 #endif /* 0 */
289
290         if ( !(sampass = samu_new( NULL )) ) {
291                 return NT_STATUS_NO_MEMORY;
292         }
293
294         /* JRA. This is ok as it is only used for generating the challenge. */
295         become_root();
296         ret = pdb_getsampwnam(sampass, mach_acct);
297         unbecome_root();
298
299         if (!ret) {
300                 DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
301                 TALLOC_FREE(sampass);
302                 return NT_STATUS_ACCESS_DENIED;
303         }
304
305         acct_ctrl = pdb_get_acct_ctrl(sampass);
306         if (acct_ctrl & ACB_DISABLED) {
307                 DEBUG(0,("get_md4pw: Workstation %s: account is disabled\n", mach_acct));
308                 TALLOC_FREE(sampass);
309                 return NT_STATUS_ACCOUNT_DISABLED;
310         }
311
312         if (!(acct_ctrl & ACB_SVRTRUST) &&
313             !(acct_ctrl & ACB_WSTRUST) &&
314             !(acct_ctrl & ACB_DOMTRUST))
315         {
316                 DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct));
317                 TALLOC_FREE(sampass);
318                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
319         }
320
321         switch (sec_chan_type) {
322                 case SEC_CHAN_BDC:
323                         if (!(acct_ctrl & ACB_SVRTRUST)) {
324                                 DEBUG(0,("get_md4pw: Workstation %s: BDC secure channel requested "
325                                          "but not a server trust account\n", mach_acct));
326                                 TALLOC_FREE(sampass);
327                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
328                         }
329                         break;
330                 case SEC_CHAN_WKSTA:
331                         if (!(acct_ctrl & ACB_WSTRUST)) {
332                                 DEBUG(0,("get_md4pw: Workstation %s: WORKSTATION secure channel requested "
333                                          "but not a workstation trust account\n", mach_acct));
334                                 TALLOC_FREE(sampass);
335                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
336                         }
337                         break;
338                 case SEC_CHAN_DOMAIN:
339                         if (!(acct_ctrl & ACB_DOMTRUST)) {
340                                 DEBUG(0,("get_md4pw: Workstation %s: DOMAIN secure channel requested "
341                                          "but not a interdomain trust account\n", mach_acct));
342                                 TALLOC_FREE(sampass);
343                                 return NT_STATUS_NO_TRUST_SAM_ACCOUNT;
344                         }
345                         break;
346                 default:
347                         break;
348         }
349
350         if ((pass = pdb_get_nt_passwd(sampass)) == NULL) {
351                 DEBUG(0,("get_md4pw: Workstation %s: account does not have a password\n", mach_acct));
352                 TALLOC_FREE(sampass);
353                 return NT_STATUS_LOGON_FAILURE;
354         }
355
356         memcpy(md4pw, pass, 16);
357         dump_data(5, (uint8 *)md4pw, 16);
358
359         TALLOC_FREE(sampass);
360
361         return NT_STATUS_OK;
362
363
364 }
365
366 /*************************************************************************
367  _netr_ServerReqChallenge
368  *************************************************************************/
369
370 NTSTATUS _netr_ServerReqChallenge(pipes_struct *p,
371                                   struct netr_ServerReqChallenge *r)
372 {
373         if (!p->dc) {
374                 p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo);
375                 if (!p->dc) {
376                         return NT_STATUS_NO_MEMORY;
377                 }
378         } else {
379                 DEBUG(10,("_netr_ServerReqChallenge: new challenge requested. Clearing old state.\n"));
380                 ZERO_STRUCTP(p->dc);
381         }
382
383         fstrcpy(p->dc->remote_machine, r->in.computer_name);
384
385         /* Save the client challenge to the server. */
386         memcpy(p->dc->clnt_chal.data, r->in.credentials->data,
387                 sizeof(r->in.credentials->data));
388
389         /* Create a server challenge for the client */
390         /* Set this to a random value. */
391         generate_random_buffer(p->dc->srv_chal.data, 8);
392
393         /* set up the LSA REQUEST CHALLENGE response */
394         init_net_r_req_chal(r->out.return_credentials, &p->dc->srv_chal);
395
396         p->dc->challenge_sent = True;
397
398         return NT_STATUS_OK;
399 }
400
401 /*************************************************************************
402  _netr_ServerAuthenticate
403  Create the initial credentials.
404  *************************************************************************/
405
406 NTSTATUS _netr_ServerAuthenticate(pipes_struct *p,
407                                   struct netr_ServerAuthenticate *r)
408 {
409         NTSTATUS status;
410         struct netr_Credential srv_chal_out;
411
412         if (!p->dc || !p->dc->challenge_sent) {
413                 return NT_STATUS_ACCESS_DENIED;
414         }
415
416         status = get_md4pw((char *)p->dc->mach_pw,
417                            r->in.account_name,
418                            r->in.secure_channel_type);
419         if (!NT_STATUS_IS_OK(status)) {
420                 DEBUG(0,("_netr_ServerAuthenticate: get_md4pw failed. Failed to "
421                         "get password for machine account %s "
422                         "from client %s: %s\n",
423                         r->in.account_name,
424                         r->in.computer_name,
425                         nt_errstr(status) ));
426                 /* always return NT_STATUS_ACCESS_DENIED */
427                 return NT_STATUS_ACCESS_DENIED;
428         }
429
430         /* From the client / server challenges and md4 password, generate sess key */
431         creds_server_init(0,                    /* No neg flags. */
432                         p->dc,
433                         &p->dc->clnt_chal,      /* Stored client chal. */
434                         &p->dc->srv_chal,       /* Stored server chal. */
435                         p->dc->mach_pw,
436                         &srv_chal_out);
437
438         /* Check client credentials are valid. */
439         if (!netlogon_creds_server_check(p->dc, r->in.credentials)) {
440                 DEBUG(0,("_netr_ServerAuthenticate: netlogon_creds_server_check failed. Rejecting auth "
441                         "request from client %s machine account %s\n",
442                         r->in.computer_name,
443                         r->in.account_name));
444                 return NT_STATUS_ACCESS_DENIED;
445         }
446
447         fstrcpy(p->dc->mach_acct, r->in.account_name);
448         fstrcpy(p->dc->remote_machine, r->in.computer_name);
449         p->dc->authenticated = True;
450
451         /* set up the LSA AUTH response */
452         /* Return the server credentials. */
453
454         memcpy(r->out.return_credentials->data, &srv_chal_out.data,
455                sizeof(r->out.return_credentials->data));
456
457         return NT_STATUS_OK;
458 }
459
460 /*************************************************************************
461  _netr_ServerAuthenticate2
462  *************************************************************************/
463
464 NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p,
465                                    struct netr_ServerAuthenticate2 *r)
466 {
467         NTSTATUS status;
468         uint32_t srv_flgs;
469         struct netr_Credential srv_chal_out;
470
471         /* We use this as the key to store the creds: */
472         /* r->in.computer_name */
473
474         if (!p->dc || !p->dc->challenge_sent) {
475                 DEBUG(0,("_netr_ServerAuthenticate2: no challenge sent to client %s\n",
476                         r->in.computer_name));
477                 return NT_STATUS_ACCESS_DENIED;
478         }
479
480         if ( (lp_server_schannel() == true) &&
481              ((*r->in.negotiate_flags & NETLOGON_NEG_SCHANNEL) == 0) ) {
482
483                 /* schannel must be used, but client did not offer it. */
484                 DEBUG(0,("_netr_ServerAuthenticate2: schannel required but client failed "
485                         "to offer it. Client was %s\n",
486                         r->in.account_name));
487                 return NT_STATUS_ACCESS_DENIED;
488         }
489
490         status = get_md4pw((char *)p->dc->mach_pw,
491                            r->in.account_name,
492                            r->in.secure_channel_type);
493         if (!NT_STATUS_IS_OK(status)) {
494                 DEBUG(0,("_netr_ServerAuthenticate2: failed to get machine password for "
495                         "account %s: %s\n",
496                         r->in.account_name, nt_errstr(status) ));
497                 /* always return NT_STATUS_ACCESS_DENIED */
498                 return NT_STATUS_ACCESS_DENIED;
499         }
500
501         /* From the client / server challenges and md4 password, generate sess key */
502         creds_server_init(*r->in.negotiate_flags,
503                         p->dc,
504                         &p->dc->clnt_chal,      /* Stored client chal. */
505                         &p->dc->srv_chal,       /* Stored server chal. */
506                         p->dc->mach_pw,
507                         &srv_chal_out);
508
509         /* Check client credentials are valid. */
510         if (!netlogon_creds_server_check(p->dc, r->in.credentials)) {
511                 DEBUG(0,("_netr_ServerAuthenticate2: netlogon_creds_server_check failed. Rejecting auth "
512                         "request from client %s machine account %s\n",
513                         r->in.computer_name,
514                         r->in.account_name));
515                 return NT_STATUS_ACCESS_DENIED;
516         }
517
518         srv_flgs = 0x000001ff;
519
520         if (lp_server_schannel() != false) {
521                 srv_flgs |= NETLOGON_NEG_SCHANNEL;
522         }
523
524         /* set up the LSA AUTH 2 response */
525         memcpy(r->out.return_credentials->data, &srv_chal_out.data,
526                sizeof(r->out.return_credentials->data));
527         *r->out.negotiate_flags = srv_flgs;
528
529         fstrcpy(p->dc->mach_acct, r->in.account_name);
530         fstrcpy(p->dc->remote_machine, r->in.computer_name);
531         fstrcpy(p->dc->domain, lp_workgroup() );
532
533         p->dc->authenticated = True;
534
535         /* Store off the state so we can continue after client disconnect. */
536         become_root();
537         secrets_store_schannel_session_info(p->mem_ctx,
538                                             r->in.computer_name,
539                                             p->dc);
540         unbecome_root();
541
542         return NT_STATUS_OK;
543 }
544
545 /*************************************************************************
546  _netr_ServerPasswordSet
547  *************************************************************************/
548
549 NTSTATUS _netr_ServerPasswordSet(pipes_struct *p,
550                                  struct netr_ServerPasswordSet *r)
551 {
552         NTSTATUS status = NT_STATUS_OK;
553         fstring remote_machine;
554         struct samu *sampass=NULL;
555         bool ret = False;
556         unsigned char pwd[16];
557         int i;
558         uint32 acct_ctrl;
559         struct netr_Authenticator cred_out;
560         const uchar *old_pw;
561
562         DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__));
563
564         /* We need the remote machine name for the creds lookup. */
565         fstrcpy(remote_machine, r->in.computer_name);
566
567         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
568                 /* 'server schannel = yes' should enforce use of
569                    schannel, the client did offer it in auth2, but
570                    obviously did not use it. */
571                 DEBUG(0,("_netr_ServerPasswordSet: client %s not using schannel for netlogon\n",
572                         remote_machine ));
573                 return NT_STATUS_ACCESS_DENIED;
574         }
575
576         if (!p->dc) {
577                 /* Restore the saved state of the netlogon creds. */
578                 become_root();
579                 ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx,
580                                                         remote_machine,
581                                                         &p->dc);
582                 unbecome_root();
583                 if (!ret) {
584                         return NT_STATUS_INVALID_HANDLE;
585                 }
586         }
587
588         if (!p->dc || !p->dc->authenticated) {
589                 return NT_STATUS_INVALID_HANDLE;
590         }
591
592         DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n",
593                         remote_machine, p->dc->mach_acct));
594
595         /* Step the creds chain forward. */
596         if (!netlogon_creds_server_step(p->dc, r->in.credential, &cred_out)) {
597                 DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth "
598                         "request from client %s machine account %s\n",
599                         remote_machine, p->dc->mach_acct ));
600                 return NT_STATUS_INVALID_PARAMETER;
601         }
602
603         /* We must store the creds state after an update. */
604         sampass = samu_new( NULL );
605         if (!sampass) {
606                 return NT_STATUS_NO_MEMORY;
607         }
608
609         become_root();
610         secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
611                                                 remote_machine,
612                                                 p->dc);
613         ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
614         unbecome_root();
615
616         if (!ret) {
617                 TALLOC_FREE(sampass);
618                 return NT_STATUS_ACCESS_DENIED;
619         }
620
621         /* Ensure the account exists and is a machine account. */
622
623         acct_ctrl = pdb_get_acct_ctrl(sampass);
624
625         if (!(acct_ctrl & ACB_WSTRUST ||
626                       acct_ctrl & ACB_SVRTRUST ||
627                       acct_ctrl & ACB_DOMTRUST)) {
628                 TALLOC_FREE(sampass);
629                 return NT_STATUS_NO_SUCH_USER;
630         }
631
632         if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
633                 TALLOC_FREE(sampass);
634                 return NT_STATUS_ACCOUNT_DISABLED;
635         }
636
637         /* Woah - what does this to to the credential chain ? JRA */
638         cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0);
639
640         DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n"));
641         for(i = 0; i < sizeof(pwd); i++)
642                 DEBUG(100,("%02X ", pwd[i]));
643         DEBUG(100,("\n"));
644
645         old_pw = pdb_get_nt_passwd(sampass);
646
647         if (old_pw && memcmp(pwd, old_pw, 16) == 0) {
648                 /* Avoid backend modificiations and other fun if the
649                    client changed the password to the *same thing* */
650
651                 ret = True;
652         } else {
653
654                 /* LM password should be NULL for machines */
655                 if (!pdb_set_lanman_passwd(sampass, NULL, PDB_CHANGED)) {
656                         TALLOC_FREE(sampass);
657                         return NT_STATUS_NO_MEMORY;
658                 }
659
660                 if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) {
661                         TALLOC_FREE(sampass);
662                         return NT_STATUS_NO_MEMORY;
663                 }
664
665                 if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) {
666                         TALLOC_FREE(sampass);
667                         /* Not quite sure what this one qualifies as, but this will do */
668                         return NT_STATUS_UNSUCCESSFUL;
669                 }
670
671                 become_root();
672                 status = pdb_update_sam_account(sampass);
673                 unbecome_root();
674         }
675
676         /* set up the LSA Server Password Set response */
677
678         memcpy(r->out.return_authenticator, &cred_out,
679                sizeof(r->out.return_authenticator));
680
681         TALLOC_FREE(sampass);
682         return status;
683 }
684
685 /*************************************************************************
686  _netr_LogonSamLogoff
687  *************************************************************************/
688
689 NTSTATUS _netr_LogonSamLogoff(pipes_struct *p,
690                               struct netr_LogonSamLogoff *r)
691 {
692         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
693                 /* 'server schannel = yes' should enforce use of
694                    schannel, the client did offer it in auth2, but
695                    obviously did not use it. */
696                 DEBUG(0,("_netr_LogonSamLogoff: client %s not using schannel for netlogon\n",
697                         get_remote_machine_name() ));
698                 return NT_STATUS_ACCESS_DENIED;
699         }
700
701
702         if (!get_valid_user_struct(p->vuid))
703                 return NT_STATUS_NO_SUCH_USER;
704
705         /* Using the remote machine name for the creds store: */
706         /* r->in.computer_name */
707
708         if (!p->dc) {
709                 /* Restore the saved state of the netlogon creds. */
710                 bool ret;
711
712                 become_root();
713                 ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx,
714                                                             r->in.computer_name,
715                                                             &p->dc);
716                 unbecome_root();
717                 if (!ret) {
718                         return NT_STATUS_INVALID_HANDLE;
719                 }
720         }
721
722         if (!p->dc || !p->dc->authenticated) {
723                 return NT_STATUS_INVALID_HANDLE;
724         }
725
726         /* checks and updates credentials.  creates reply credentials */
727         if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) {
728                 DEBUG(2,("_netr_LogonSamLogoff: netlogon_creds_server_step failed. Rejecting auth "
729                         "request from client %s machine account %s\n",
730                         r->in.computer_name, p->dc->mach_acct ));
731                 return NT_STATUS_INVALID_PARAMETER;
732         }
733
734         /* We must store the creds state after an update. */
735         become_root();
736         secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
737                                             r->in.computer_name,
738                                             p->dc);
739         unbecome_root();
740
741         return NT_STATUS_OK;
742 }
743
744 /*******************************************************************
745  gets a domain user's groups from their already-calculated NT_USER_TOKEN
746  ********************************************************************/
747
748 static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx,
749                                        const DOM_SID *domain_sid,
750                                        size_t num_sids,
751                                        const DOM_SID *sids,
752                                        int *numgroups, DOM_GID **pgids)
753 {
754         int i;
755
756         *numgroups=0;
757         *pgids = NULL;
758
759         for (i=0; i<num_sids; i++) {
760                 DOM_GID gid;
761                 if (!sid_peek_check_rid(domain_sid, &sids[i], &gid.g_rid)) {
762                         continue;
763                 }
764                 gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|
765                             SE_GROUP_ENABLED);
766                 ADD_TO_ARRAY(mem_ctx, DOM_GID, gid, pgids, numgroups);
767                 if (*pgids == NULL) {
768                         return NT_STATUS_NO_MEMORY;
769                 }
770         }
771         return NT_STATUS_OK;
772 }
773
774 /*************************************************************************
775  _netr_LogonSamLogon
776  *************************************************************************/
777
778 NTSTATUS _netr_LogonSamLogon(pipes_struct *p,
779                              struct netr_LogonSamLogon *r)
780 {
781         NTSTATUS status = NT_STATUS_OK;
782         struct netr_SamInfo3 *sam3 = NULL;
783         union netr_LogonLevel *logon = r->in.logon;
784         fstring nt_username, nt_domain, nt_workstation;
785         auth_usersupplied_info *user_info = NULL;
786         auth_serversupplied_info *server_info = NULL;
787         struct samu *sampw;
788         struct auth_context *auth_context = NULL;
789         bool process_creds = true;
790
791         switch (p->hdr_req.opnum) {
792                 case NDR_NETR_LOGONSAMLOGON:
793                         process_creds = true;
794                         break;
795                 case NDR_NETR_LOGONSAMLOGONEX:
796                 default:
797                         process_creds = false;
798         }
799
800         if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) {
801                 /* 'server schannel = yes' should enforce use of
802                    schannel, the client did offer it in auth2, but
803                    obviously did not use it. */
804                 DEBUG(0,("_netr_LogonSamLogon: client %s not using schannel for netlogon\n",
805                         get_remote_machine_name() ));
806                 return NT_STATUS_ACCESS_DENIED;
807         }
808
809         sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3);
810         if (!sam3) {
811                 return NT_STATUS_NO_MEMORY;
812         }
813
814         /* store the user information, if there is any. */
815         r->out.validation->sam3 = sam3;
816         *r->out.authoritative = true; /* authoritative response */
817         if (r->in.validation_level != 2 && r->in.validation_level != 3) {
818                 DEBUG(0,("_netr_LogonSamLogon: bad validation_level value %d.\n",
819                         (int)r->in.validation_level));
820                 return NT_STATUS_ACCESS_DENIED;
821         }
822
823         if (!get_valid_user_struct(p->vuid))
824                 return NT_STATUS_NO_SUCH_USER;
825
826         if (process_creds) {
827                 fstring remote_machine;
828
829                 /* Get the remote machine name for the creds store. */
830                 /* Note this is the remote machine this request is coming from (member server),
831                    not neccessarily the workstation name the user is logging onto.
832                 */
833
834                 fstrcpy(remote_machine, r->in.computer_name);
835
836                 if (!p->dc) {
837                         /* Restore the saved state of the netlogon creds. */
838                         bool ret;
839
840                         become_root();
841                         ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx,
842                                         remote_machine,
843                                         &p->dc);
844                         unbecome_root();
845                         if (!ret) {
846                                 return NT_STATUS_INVALID_HANDLE;
847                         }
848                 }
849
850                 if (!p->dc || !p->dc->authenticated) {
851                         return NT_STATUS_INVALID_HANDLE;
852                 }
853
854                 /* checks and updates credentials.  creates reply credentials */
855                 if (!netlogon_creds_server_step(p->dc, r->in.credential,  r->out.return_authenticator)) {
856                         DEBUG(2,("_netr_LogonSamLogon: creds_server_step failed. Rejecting auth "
857                                 "request from client %s machine account %s\n",
858                                 remote_machine, p->dc->mach_acct ));
859                         return NT_STATUS_INVALID_PARAMETER;
860                 }
861
862                 /* We must store the creds state after an update. */
863                 become_root();
864                 secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
865                                         remote_machine,
866                                         p->dc);
867                 unbecome_root();
868         }
869
870         switch (r->in.logon_level) {
871         case INTERACTIVE_LOGON_TYPE:
872                 fstrcpy(nt_username,
873                         logon->password->identity_info.account_name.string);
874                 fstrcpy(nt_domain,
875                         logon->password->identity_info.domain_name.string);
876                 fstrcpy(nt_workstation,
877                         logon->password->identity_info.workstation.string);
878
879                 DEBUG(3,("SAM Logon (Interactive). Domain:[%s].  ", lp_workgroup()));
880                 break;
881         case NET_LOGON_TYPE:
882                 fstrcpy(nt_username,
883                         logon->network->identity_info.account_name.string);
884                 fstrcpy(nt_domain,
885                         logon->network->identity_info.domain_name.string);
886                 fstrcpy(nt_workstation,
887                         logon->network->identity_info.workstation.string);
888
889                 DEBUG(3,("SAM Logon (Network). Domain:[%s].  ", lp_workgroup()));
890                 break;
891         default:
892                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
893                 return NT_STATUS_INVALID_INFO_CLASS;
894         } /* end switch */
895
896         DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain));
897         fstrcpy(current_user_info.smb_name, nt_username);
898         sub_set_smb_name(nt_username);
899
900         DEBUG(5,("Attempting validation level %d for unmapped username %s.\n",
901                 r->in.validation_level, nt_username));
902
903         status = NT_STATUS_OK;
904
905         switch (r->in.logon_level) {
906         case NET_LOGON_TYPE:
907         {
908                 const char *wksname = nt_workstation;
909
910                 status = make_auth_context_fixed(&auth_context,
911                                                  logon->network->challenge);
912                 if (!NT_STATUS_IS_OK(status)) {
913                         return status;
914                 }
915
916                 /* For a network logon, the workstation name comes in with two
917                  * backslashes in the front. Strip them if they are there. */
918
919                 if (*wksname == '\\') wksname++;
920                 if (*wksname == '\\') wksname++;
921
922                 /* Standard challenge/response authenticaion */
923                 if (!make_user_info_netlogon_network(&user_info,
924                                                      nt_username, nt_domain,
925                                                      wksname,
926                                                      logon->network->identity_info.parameter_control,
927                                                      logon->network->lm.data,
928                                                      logon->network->lm.length,
929                                                      logon->network->nt.data,
930                                                      logon->network->nt.length)) {
931                         status = NT_STATUS_NO_MEMORY;
932                 }
933                 break;
934         }
935         case INTERACTIVE_LOGON_TYPE:
936                 /* 'Interactive' authentication, supplies the password in its
937                    MD4 form, encrypted with the session key.  We will convert
938                    this to challenge/response for the auth subsystem to chew
939                    on */
940         {
941                 const uint8 *chal;
942
943                 if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) {
944                         return status;
945                 }
946
947                 chal = auth_context->get_ntlm_challenge(auth_context);
948
949                 if (!make_user_info_netlogon_interactive(&user_info,
950                                                          nt_username, nt_domain,
951                                                          nt_workstation,
952                                                          logon->password->identity_info.parameter_control,
953                                                          chal,
954                                                          logon->password->lmpassword.hash,
955                                                          logon->password->ntpassword.hash,
956                                                          p->dc->sess_key)) {
957                         status = NT_STATUS_NO_MEMORY;
958                 }
959                 break;
960         }
961         default:
962                 DEBUG(2,("SAM Logon: unsupported switch value\n"));
963                 return NT_STATUS_INVALID_INFO_CLASS;
964         } /* end switch */
965
966         if ( NT_STATUS_IS_OK(status) ) {
967                 status = auth_context->check_ntlm_password(auth_context,
968                         user_info, &server_info);
969         }
970
971         (auth_context->free)(&auth_context);
972         free_user_info(&user_info);
973
974         DEBUG(5,("_netr_LogonSamLogon: check_password returned status %s\n",
975                   nt_errstr(status)));
976
977         /* Check account and password */
978
979         if (!NT_STATUS_IS_OK(status)) {
980                 /* If we don't know what this domain is, we need to
981                    indicate that we are not authoritative.  This
982                    allows the client to decide if it needs to try
983                    a local user.  Fix by jpjanosi@us.ibm.com, #2976 */
984                 if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER)
985                      && !strequal(nt_domain, get_global_sam_name())
986                      && !is_trusted_domain(nt_domain) )
987                         *r->out.authoritative = false; /* We are not authoritative */
988
989                 TALLOC_FREE(server_info);
990                 return status;
991         }
992
993         if (server_info->guest) {
994                 /* We don't like guest domain logons... */
995                 DEBUG(5,("_netr_LogonSamLogon: Attempted domain logon as GUEST "
996                          "denied.\n"));
997                 TALLOC_FREE(server_info);
998                 return NT_STATUS_LOGON_FAILURE;
999         }
1000
1001         /* This is the point at which, if the login was successful, that
1002            the SAM Local Security Authority should record that the user is
1003            logged in to the domain.  */
1004
1005         {
1006                 DOM_GID *gids = NULL;
1007                 const DOM_SID *user_sid = NULL;
1008                 const DOM_SID *group_sid = NULL;
1009                 DOM_SID domain_sid;
1010                 uint32 user_rid, group_rid;
1011
1012                 int num_gids = 0;
1013                 const char *my_name;
1014
1015                 struct netr_UserSessionKey user_session_key;
1016                 struct netr_LMSessionKey lm_session_key;
1017                 unsigned char pipe_session_key[16];
1018
1019                 NTTIME last_logon, last_logoff, acct_expiry, last_password_change;
1020                 NTTIME allow_password_change, force_password_change;
1021                 struct samr_RidWithAttributeArray groups;
1022                 int i;
1023                 struct dom_sid2 *sid = NULL;
1024
1025                 ZERO_STRUCT(user_session_key);
1026                 ZERO_STRUCT(lm_session_key);
1027
1028                 sampw = server_info->sam_account;
1029
1030                 user_sid = pdb_get_user_sid(sampw);
1031                 group_sid = pdb_get_group_sid(sampw);
1032
1033                 if ((user_sid == NULL) || (group_sid == NULL)) {
1034                         DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n"));
1035                         return NT_STATUS_UNSUCCESSFUL;
1036                 }
1037
1038                 sid_copy(&domain_sid, user_sid);
1039                 sid_split_rid(&domain_sid, &user_rid);
1040
1041                 sid = sid_dup_talloc(p->mem_ctx, &domain_sid);
1042                 if (!sid) {
1043                         return NT_STATUS_NO_MEMORY;
1044                 }
1045
1046                 if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) {
1047                         DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid "
1048                                   "%s\n but group sid %s.\n"
1049                                   "The conflicting domain portions are not "
1050                                   "supported for NETLOGON calls\n",
1051                                   pdb_get_domain(sampw),
1052                                   pdb_get_username(sampw),
1053                                   sid_string_dbg(user_sid),
1054                                   sid_string_dbg(group_sid)));
1055                         return NT_STATUS_UNSUCCESSFUL;
1056                 }
1057
1058                 if(server_info->login_server) {
1059                         my_name = server_info->login_server;
1060                 } else {
1061                         my_name = global_myname();
1062                 }
1063
1064                 status = nt_token_to_group_list(p->mem_ctx, &domain_sid,
1065                                                 server_info->num_sids,
1066                                                 server_info->sids,
1067                                                 &num_gids, &gids);
1068
1069                 if (!NT_STATUS_IS_OK(status)) {
1070                         return status;
1071                 }
1072
1073                 if (server_info->user_session_key.length) {
1074                         memcpy(user_session_key.key,
1075                                server_info->user_session_key.data,
1076                                MIN(sizeof(user_session_key.key),
1077                                    server_info->user_session_key.length));
1078                         if (process_creds) {
1079                                 /* Get the pipe session key from the creds. */
1080                                 memcpy(pipe_session_key, p->dc->sess_key, 16);
1081                         } else {
1082                                 /* Get the pipe session key from the schannel. */
1083                                 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) {
1084                                         return NT_STATUS_INVALID_HANDLE;
1085                                 }
1086                                 memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
1087                         }
1088                         SamOEMhash(user_session_key.key, pipe_session_key, 16);
1089                         memset(pipe_session_key, '\0', 16);
1090                 }
1091                 if (server_info->lm_session_key.length) {
1092                         memcpy(lm_session_key.key,
1093                                server_info->lm_session_key.data,
1094                                MIN(sizeof(lm_session_key.key),
1095                                    server_info->lm_session_key.length));
1096                         if (process_creds) {
1097                                 /* Get the pipe session key from the creds. */
1098                                 memcpy(pipe_session_key, p->dc->sess_key, 16);
1099                         } else {
1100                                 /* Get the pipe session key from the schannel. */
1101                                 if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) {
1102                                         return NT_STATUS_INVALID_HANDLE;
1103                                 }
1104                                 memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
1105                         }
1106                         SamOEMhash(lm_session_key.key, pipe_session_key, 16);
1107                         memset(pipe_session_key, '\0', 16);
1108                 }
1109
1110                 groups.count = num_gids;
1111                 groups.rids = TALLOC_ARRAY(p->mem_ctx, struct samr_RidWithAttribute,
1112                                            groups.count);
1113                 if (!groups.rids) {
1114                         return NT_STATUS_NO_MEMORY;
1115                 }
1116
1117                 for (i=0; i < groups.count; i++) {
1118                         groups.rids[i].rid = gids[i].g_rid;
1119                         groups.rids[i].attributes = gids[i].attr;
1120                 }
1121
1122                 unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw));
1123                 unix_to_nt_time(&last_logoff, get_time_t_max());
1124                 unix_to_nt_time(&acct_expiry, get_time_t_max());
1125                 unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw));
1126                 unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw));
1127                 unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw));
1128
1129                 init_netr_SamInfo3(sam3,
1130                                    last_logon,
1131                                    last_logoff,
1132                                    acct_expiry,
1133                                    last_password_change,
1134                                    allow_password_change,
1135                                    force_password_change,
1136                                    talloc_strdup(p->mem_ctx, pdb_get_username(sampw)),
1137                                    talloc_strdup(p->mem_ctx, pdb_get_fullname(sampw)),
1138                                    talloc_strdup(p->mem_ctx, pdb_get_logon_script(sampw)),
1139                                    talloc_strdup(p->mem_ctx, pdb_get_profile_path(sampw)),
1140                                    talloc_strdup(p->mem_ctx, pdb_get_homedir(sampw)),
1141                                    talloc_strdup(p->mem_ctx, pdb_get_dir_drive(sampw)),
1142                                    0, /* logon_count */
1143                                    0, /* bad_password_count */
1144                                    user_rid,
1145                                    group_rid,
1146                                    groups,
1147                                    NETLOGON_EXTRA_SIDS,
1148                                    user_session_key,
1149                                    my_name,
1150                                    talloc_strdup(p->mem_ctx, pdb_get_domain(sampw)),
1151                                    sid,
1152                                    lm_session_key,
1153                                    pdb_get_acct_ctrl(sampw),
1154                                    0, /* sidcount */
1155                                    NULL); /* struct netr_SidAttr *sids */
1156                 ZERO_STRUCT(user_session_key);
1157                 ZERO_STRUCT(lm_session_key);
1158         }
1159         TALLOC_FREE(server_info);
1160         return status;
1161 }
1162
1163 /*************************************************************************
1164  _netr_LogonSamLogonEx
1165  - no credential chaining. Map into net sam logon.
1166  *************************************************************************/
1167
1168 NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p,
1169                                struct netr_LogonSamLogonEx *r)
1170 {
1171         struct netr_LogonSamLogon q;
1172
1173         /* Only allow this if the pipe is protected. */
1174         if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) {
1175                 DEBUG(0,("_net_sam_logon_ex: client %s not using schannel for netlogon\n",
1176                         get_remote_machine_name() ));
1177                 return NT_STATUS_INVALID_PARAMETER;
1178         }
1179
1180         q.in.server_name        = r->in.server_name;
1181         q.in.computer_name      = r->in.computer_name;
1182         q.in.logon_level        = r->in.logon_level;
1183         q.in.logon              = r->in.logon;
1184         q.in.validation_level   = r->in.validation_level;
1185         /* we do not handle the flags */
1186         /*                      = r->in.flags; */
1187
1188         q.out.validation        = r->out.validation;
1189         q.out.authoritative     = r->out.authoritative;
1190         /* we do not handle the flags */
1191         /*                      = r->out.flags; */
1192
1193         return _netr_LogonSamLogon(p, &q);
1194 }
1195
1196 /*************************************************************************
1197  _ds_enum_dom_trusts
1198  *************************************************************************/
1199 #if 0   /* JERRY -- not correct */
1200  NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u,
1201                              DS_R_ENUM_DOM_TRUSTS *r_u)
1202 {
1203         NTSTATUS status = NT_STATUS_OK;
1204
1205         /* TODO: According to MSDN, the can only be executed against a
1206            DC or domain member running Windows 2000 or later.  Need
1207            to test against a standalone 2k server and see what it
1208            does.  A windows 2000 DC includes its own domain in the
1209            list.  --jerry */
1210
1211         return status;
1212 }
1213 #endif  /* JERRY */
1214
1215
1216 /****************************************************************
1217 ****************************************************************/
1218
1219 WERROR _netr_LogonUasLogon(pipes_struct *p,
1220                            struct netr_LogonUasLogon *r)
1221 {
1222         p->rng_fault_state = true;
1223         return WERR_NOT_SUPPORTED;
1224 }
1225
1226 /****************************************************************
1227 ****************************************************************/
1228
1229 WERROR _netr_LogonUasLogoff(pipes_struct *p,
1230                             struct netr_LogonUasLogoff *r)
1231 {
1232         p->rng_fault_state = true;
1233         return WERR_NOT_SUPPORTED;
1234 }
1235
1236 /****************************************************************
1237 ****************************************************************/
1238
1239 NTSTATUS _netr_DatabaseDeltas(pipes_struct *p,
1240                               struct netr_DatabaseDeltas *r)
1241 {
1242         p->rng_fault_state = true;
1243         return NT_STATUS_NOT_IMPLEMENTED;
1244 }
1245
1246 /****************************************************************
1247 ****************************************************************/
1248
1249 NTSTATUS _netr_DatabaseSync(pipes_struct *p,
1250                             struct netr_DatabaseSync *r)
1251 {
1252         p->rng_fault_state = true;
1253         return NT_STATUS_NOT_IMPLEMENTED;
1254 }
1255
1256 /****************************************************************
1257 ****************************************************************/
1258
1259 NTSTATUS _netr_AccountDeltas(pipes_struct *p,
1260                              struct netr_AccountDeltas *r)
1261 {
1262         p->rng_fault_state = true;
1263         return NT_STATUS_NOT_IMPLEMENTED;
1264 }
1265
1266 /****************************************************************
1267 ****************************************************************/
1268
1269 NTSTATUS _netr_AccountSync(pipes_struct *p,
1270                            struct netr_AccountSync *r)
1271 {
1272         p->rng_fault_state = true;
1273         return NT_STATUS_NOT_IMPLEMENTED;
1274 }
1275
1276 /****************************************************************
1277 ****************************************************************/
1278
1279 WERROR _netr_GetDcName(pipes_struct *p,
1280                        struct netr_GetDcName *r)
1281 {
1282         p->rng_fault_state = true;
1283         return WERR_NOT_SUPPORTED;
1284 }
1285
1286 /****************************************************************
1287 ****************************************************************/
1288
1289 WERROR _netr_GetAnyDCName(pipes_struct *p,
1290                           struct netr_GetAnyDCName *r)
1291 {
1292         p->rng_fault_state = true;
1293         return WERR_NOT_SUPPORTED;
1294 }
1295
1296 /****************************************************************
1297 ****************************************************************/
1298
1299 NTSTATUS _netr_DatabaseSync2(pipes_struct *p,
1300                              struct netr_DatabaseSync2 *r)
1301 {
1302         p->rng_fault_state = true;
1303         return NT_STATUS_NOT_IMPLEMENTED;
1304 }
1305
1306 /****************************************************************
1307 ****************************************************************/
1308
1309 NTSTATUS _netr_DatabaseRedo(pipes_struct *p,
1310                             struct netr_DatabaseRedo *r)
1311 {
1312         p->rng_fault_state = true;
1313         return NT_STATUS_NOT_IMPLEMENTED;
1314 }
1315
1316 /****************************************************************
1317 ****************************************************************/
1318
1319 WERROR _netr_LogonControl2Ex(pipes_struct *p,
1320                              struct netr_LogonControl2Ex *r)
1321 {
1322         p->rng_fault_state = true;
1323         return WERR_NOT_SUPPORTED;
1324 }
1325
1326 /****************************************************************
1327 ****************************************************************/
1328
1329 WERROR _netr_DsRGetDCName(pipes_struct *p,
1330                           struct netr_DsRGetDCName *r)
1331 {
1332         p->rng_fault_state = true;
1333         return WERR_NOT_SUPPORTED;
1334 }
1335
1336 /****************************************************************
1337 ****************************************************************/
1338
1339 WERROR _netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p,
1340                                     struct netr_NETRLOGONDUMMYROUTINE1 *r)
1341 {
1342         p->rng_fault_state = true;
1343         return WERR_NOT_SUPPORTED;
1344 }
1345
1346 /****************************************************************
1347 ****************************************************************/
1348
1349 WERROR _netr_NETRLOGONSETSERVICEBITS(pipes_struct *p,
1350                                      struct netr_NETRLOGONSETSERVICEBITS *r)
1351 {
1352         p->rng_fault_state = true;
1353         return WERR_NOT_SUPPORTED;
1354 }
1355
1356 /****************************************************************
1357 ****************************************************************/
1358
1359 WERROR _netr_LogonGetTrustRid(pipes_struct *p,
1360                               struct netr_LogonGetTrustRid *r)
1361 {
1362         p->rng_fault_state = true;
1363         return WERR_NOT_SUPPORTED;
1364 }
1365
1366 /****************************************************************
1367 ****************************************************************/
1368
1369 WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p,
1370                                           struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
1371 {
1372         p->rng_fault_state = true;
1373         return WERR_NOT_SUPPORTED;
1374 }
1375
1376 /****************************************************************
1377 ****************************************************************/
1378
1379 WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p,
1380                                           struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
1381 {
1382         p->rng_fault_state = true;
1383         return WERR_NOT_SUPPORTED;
1384 }
1385
1386 /****************************************************************
1387 ****************************************************************/
1388
1389 NTSTATUS _netr_ServerAuthenticate3(pipes_struct *p,
1390                                    struct netr_ServerAuthenticate3 *r)
1391 {
1392         p->rng_fault_state = true;
1393         return NT_STATUS_NOT_IMPLEMENTED;
1394 }
1395
1396 /****************************************************************
1397 ****************************************************************/
1398
1399 WERROR _netr_DsRGetDCNameEx(pipes_struct *p,
1400                             struct netr_DsRGetDCNameEx *r)
1401 {
1402         p->rng_fault_state = true;
1403         return WERR_NOT_SUPPORTED;
1404 }
1405
1406 /****************************************************************
1407 ****************************************************************/
1408
1409 WERROR _netr_DsRGetSiteName(pipes_struct *p,
1410                             struct netr_DsRGetSiteName *r)
1411 {
1412         p->rng_fault_state = true;
1413         return WERR_NOT_SUPPORTED;
1414 }
1415
1416 /****************************************************************
1417 ****************************************************************/
1418
1419 NTSTATUS _netr_LogonGetDomainInfo(pipes_struct *p,
1420                                   struct netr_LogonGetDomainInfo *r)
1421 {
1422         p->rng_fault_state = true;
1423         return NT_STATUS_NOT_IMPLEMENTED;
1424 }
1425
1426 /****************************************************************
1427 ****************************************************************/
1428
1429 NTSTATUS _netr_ServerPasswordSet2(pipes_struct *p,
1430                                   struct netr_ServerPasswordSet2 *r)
1431 {
1432         p->rng_fault_state = true;
1433         return NT_STATUS_NOT_IMPLEMENTED;
1434 }
1435
1436 /****************************************************************
1437 ****************************************************************/
1438
1439 WERROR _netr_ServerPasswordGet(pipes_struct *p,
1440                                struct netr_ServerPasswordGet *r)
1441 {
1442         p->rng_fault_state = true;
1443         return WERR_NOT_SUPPORTED;
1444 }
1445
1446 /****************************************************************
1447 ****************************************************************/
1448
1449 WERROR _netr_NETRLOGONSENDTOSAM(pipes_struct *p,
1450                                 struct netr_NETRLOGONSENDTOSAM *r)
1451 {
1452         p->rng_fault_state = true;
1453         return WERR_NOT_SUPPORTED;
1454 }
1455
1456 /****************************************************************
1457 ****************************************************************/
1458
1459 WERROR _netr_DsRAddressToSitenamesW(pipes_struct *p,
1460                                     struct netr_DsRAddressToSitenamesW *r)
1461 {
1462         p->rng_fault_state = true;
1463         return WERR_NOT_SUPPORTED;
1464 }
1465
1466 /****************************************************************
1467 ****************************************************************/
1468
1469 WERROR _netr_DsRGetDCNameEx2(pipes_struct *p,
1470                              struct netr_DsRGetDCNameEx2 *r)
1471 {
1472         p->rng_fault_state = true;
1473         return WERR_NOT_SUPPORTED;
1474 }
1475
1476 /****************************************************************
1477 ****************************************************************/
1478
1479 WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p,
1480                                                  struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1481 {
1482         p->rng_fault_state = true;
1483         return WERR_NOT_SUPPORTED;
1484 }
1485
1486 /****************************************************************
1487 ****************************************************************/
1488
1489 WERROR _netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p,
1490                                            struct netr_NetrEnumerateTrustedDomainsEx *r)
1491 {
1492         p->rng_fault_state = true;
1493         return WERR_NOT_SUPPORTED;
1494 }
1495
1496 /****************************************************************
1497 ****************************************************************/
1498
1499 WERROR _netr_DsRAddressToSitenamesExW(pipes_struct *p,
1500                                       struct netr_DsRAddressToSitenamesExW *r)
1501 {
1502         p->rng_fault_state = true;
1503         return WERR_NOT_SUPPORTED;
1504 }
1505
1506 /****************************************************************
1507 ****************************************************************/
1508
1509 WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p,
1510                                    struct netr_DsrGetDcSiteCoverageW *r)
1511 {
1512         p->rng_fault_state = true;
1513         return WERR_NOT_SUPPORTED;
1514 }
1515
1516 /****************************************************************
1517 ****************************************************************/
1518
1519 WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p,
1520                                       struct netr_DsrEnumerateDomainTrusts *r)
1521 {
1522         p->rng_fault_state = true;
1523         return WERR_NOT_SUPPORTED;
1524 }
1525
1526 /****************************************************************
1527 ****************************************************************/
1528
1529 WERROR _netr_DsrDeregisterDNSHostRecords(pipes_struct *p,
1530                                          struct netr_DsrDeregisterDNSHostRecords *r)
1531 {
1532         p->rng_fault_state = true;
1533         return WERR_NOT_SUPPORTED;
1534 }
1535
1536 /****************************************************************
1537 ****************************************************************/
1538
1539 NTSTATUS _netr_ServerTrustPasswordsGet(pipes_struct *p,
1540                                        struct netr_ServerTrustPasswordsGet *r)
1541 {
1542         p->rng_fault_state = true;
1543         return NT_STATUS_NOT_IMPLEMENTED;
1544 }
1545
1546 /****************************************************************
1547 ****************************************************************/
1548
1549 WERROR _netr_DsRGetForestTrustInformation(pipes_struct *p,
1550                                           struct netr_DsRGetForestTrustInformation *r)
1551 {
1552         p->rng_fault_state = true;
1553         return WERR_NOT_SUPPORTED;
1554 }
1555
1556 /****************************************************************
1557 ****************************************************************/
1558
1559 WERROR _netr_GetForestTrustInformation(pipes_struct *p,
1560                                        struct netr_GetForestTrustInformation *r)
1561 {
1562         p->rng_fault_state = true;
1563         return WERR_NOT_SUPPORTED;
1564 }
1565
1566 /****************************************************************
1567 ****************************************************************/
1568
1569 NTSTATUS _netr_LogonSamLogonWithFlags(pipes_struct *p,
1570                                       struct netr_LogonSamLogonWithFlags *r)
1571 {
1572         p->rng_fault_state = true;
1573         return NT_STATUS_NOT_IMPLEMENTED;
1574 }
1575
1576 /****************************************************************
1577 ****************************************************************/
1578
1579 WERROR _netr_NETRSERVERGETTRUSTINFO(pipes_struct *p,
1580                                     struct netr_NETRSERVERGETTRUSTINFO *r)
1581 {
1582         p->rng_fault_state = true;
1583         return WERR_NOT_SUPPORTED;
1584 }
1585