r11289: Fix comment.
[ira/wip.git] / source / rpc_server / netlogon / dcerpc_netlogon.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the netlogon pipe
5
6    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004
7    Copyright (C) Stefan Metzmacher <metze@samba.org>  2005
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #include "includes.h"
25 #include "librpc/gen_ndr/ndr_netlogon.h"
26 #include "rpc_server/dcerpc_server.h"
27 #include "rpc_server/common/common.h"
28 #include "librpc/gen_ndr/ndr_dcom.h"
29 #include "lib/ldb/include/ldb.h"
30 #include "auth/auth.h"
31
32 struct server_pipe_state {
33         struct netr_Credential client_challenge;
34         struct netr_Credential server_challenge;
35         struct creds_CredentialState *creds;
36 };
37
38
39 /*
40   a client has connected to the netlogon server using schannel, so we need
41   to re-establish the credentials state
42 */
43 static NTSTATUS netlogon_schannel_setup(struct dcesrv_call_state *dce_call) 
44 {
45         struct server_pipe_state *state;
46         NTSTATUS status;
47
48         /* We want the client and server challenge zero */
49         state = talloc_zero(dce_call->conn, struct server_pipe_state);
50         if (state == NULL) {
51                 return NT_STATUS_NO_MEMORY;
52         }
53         
54         status = dcerpc_schannel_creds(dce_call->conn->auth_state.gensec_security, 
55                                        state, 
56                                        &state->creds);
57
58         if (!NT_STATUS_IS_OK(status)) {
59                 DEBUG(3, ("getting schannel credentials failed with %s\n", nt_errstr(status)));
60                 talloc_free(state);
61                 return status;
62         }
63         
64         dce_call->context->private = state;
65
66         return NT_STATUS_OK;
67 }
68
69 /*
70   a hook for bind on the netlogon pipe
71 */
72 static NTSTATUS netlogon_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *di) 
73 {
74         dce_call->context->private = NULL;
75
76         /* if this is a schannel bind then we need to reconstruct the pipe state */
77         if (dce_call->conn->auth_state.auth_info &&
78             dce_call->conn->auth_state.auth_info->auth_type == DCERPC_AUTH_TYPE_SCHANNEL) {
79                 NTSTATUS status;
80
81                 DEBUG(5, ("schannel bind on netlogon\n"));
82
83                 status = netlogon_schannel_setup(dce_call);
84                 if (!NT_STATUS_IS_OK(status)) {
85                         DEBUG(3, ("schannel bind on netlogon failed with %s\n", nt_errstr(status)));
86                         return status;
87                 }
88         }
89
90         return NT_STATUS_OK;
91 }
92
93 #define DCESRV_INTERFACE_NETLOGON_BIND netlogon_bind
94
95 static NTSTATUS netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
96                                         struct netr_ServerReqChallenge *r)
97 {
98         struct server_pipe_state *pipe_state = dce_call->context->private;
99
100         ZERO_STRUCTP(r->out.credentials);
101
102         /* destroyed on pipe shutdown */
103
104         if (pipe_state) {
105                 talloc_free(pipe_state);
106                 dce_call->context->private = NULL;
107         }
108         
109         pipe_state = talloc(dce_call->context, struct server_pipe_state);
110         if (!pipe_state) {
111                 return NT_STATUS_NO_MEMORY;
112         }
113
114         pipe_state->creds = NULL;
115
116         pipe_state->client_challenge = *r->in.credentials;
117
118         generate_random_buffer(pipe_state->server_challenge.data, 
119                                sizeof(pipe_state->server_challenge.data));
120
121         *r->out.credentials = pipe_state->server_challenge;
122
123         dce_call->context->private = pipe_state;
124
125         return NT_STATUS_OK;
126 }
127
128 static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
129                                          struct netr_ServerAuthenticate3 *r)
130 {
131         struct server_pipe_state *pipe_state = dce_call->context->private;
132         void *sam_ctx;
133         struct samr_Password *mach_pwd;
134         uint16_t acct_flags;
135         int num_records;
136         struct ldb_message **msgs;
137         NTSTATUS nt_status;
138         const char *attrs[] = {"unicodePwd", "lmPwdHash", "ntPwdHash", "userAccountControl", 
139                                "objectSid", NULL};
140
141         ZERO_STRUCTP(r->out.credentials);
142         *r->out.rid = 0;
143         *r->out.negotiate_flags = *r->in.negotiate_flags;
144
145         if (!pipe_state) {
146                 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
147                 return NT_STATUS_ACCESS_DENIED;
148         }
149
150         sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
151         if (sam_ctx == NULL) {
152                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
153         }
154         /* pull the user attributes */
155         num_records = gendb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
156                                    "(&(sAMAccountName=%s)(objectclass=user))", 
157                                    r->in.account_name);
158
159         if (num_records == 0) {
160                 DEBUG(3,("Couldn't find user [%s] in samdb.\n", 
161                          r->in.account_name));
162                 return NT_STATUS_ACCESS_DENIED;
163         }
164
165         if (num_records > 1) {
166                 DEBUG(0,("Found %d records matching user [%s]\n", num_records, r->in.account_name));
167                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
168         }
169
170         acct_flags = samdb_result_acct_flags(msgs[0], 
171                                              "userAccountControl");
172
173         if (acct_flags & ACB_DISABLED) {
174                 DEBUG(1, ("Account [%s] is disabled\n", r->in.account_name));
175                 return NT_STATUS_ACCESS_DENIED;
176         }
177
178         if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
179                 if (!(acct_flags & ACB_WSTRUST)) {
180                         DEBUG(1, ("Client asked for a workstation secure channel, but is not a workstation (member server) acb flags: 0x%x\n", acct_flags));
181                         return NT_STATUS_ACCESS_DENIED;
182                 }
183         } else if (r->in.secure_channel_type == SEC_CHAN_DOMAIN) {
184                 if (!(acct_flags & ACB_DOMTRUST)) {
185                         DEBUG(1, ("Client asked for a trusted domain secure channel, but is not a trusted domain: acb flags: 0x%x\n", acct_flags));
186                         return NT_STATUS_ACCESS_DENIED;
187                 }
188         } else if (r->in.secure_channel_type == SEC_CHAN_BDC) {
189                 if (!(acct_flags & ACB_SVRTRUST)) {
190                         DEBUG(1, ("Client asked for a server secure channel, but is not a server (domain controller): acb flags: 0x%x\n", acct_flags));
191                         return NT_STATUS_ACCESS_DENIED;
192                 }
193         } else {
194                 DEBUG(1, ("Client asked for an invalid secure channel type: %d\n", 
195                           r->in.secure_channel_type));
196                 return NT_STATUS_ACCESS_DENIED;
197         }
198
199
200         *r->out.rid = samdb_result_rid_from_sid(mem_ctx, msgs[0], "objectSid", 0);
201
202         nt_status = samdb_result_passwords(mem_ctx, msgs[0], NULL, &mach_pwd);
203         if (!NT_STATUS_IS_OK(nt_status) || mach_pwd == NULL) {
204                 return NT_STATUS_ACCESS_DENIED;
205         }
206
207         if (pipe_state->creds) {
208                 talloc_free(pipe_state->creds);
209         }
210         pipe_state->creds = talloc(pipe_state, struct creds_CredentialState);
211         if (!pipe_state->creds) {
212                 return NT_STATUS_NO_MEMORY;
213         }
214
215         creds_server_init(pipe_state->creds, &pipe_state->client_challenge, 
216                           &pipe_state->server_challenge, mach_pwd,
217                           r->out.credentials,
218                           *r->in.negotiate_flags);
219         
220         if (!creds_server_check(pipe_state->creds, r->in.credentials)) {
221                 talloc_free(pipe_state->creds);
222                 pipe_state->creds = NULL;
223                 return NT_STATUS_ACCESS_DENIED;
224         }
225
226         pipe_state->creds->account_name = talloc_steal(pipe_state->creds, r->in.account_name);
227         
228         pipe_state->creds->computer_name = talloc_steal(pipe_state->creds, r->in.computer_name);
229
230         pipe_state->creds->secure_channel_type = r->in.secure_channel_type;
231
232         pipe_state->creds->sid = samdb_result_dom_sid(pipe_state->creds, msgs[0], "objectSid");
233
234         pipe_state->creds->domain = talloc_strdup(pipe_state->creds, lp_workgroup());
235
236         /* remember this session key state */
237         nt_status = schannel_store_session_key(mem_ctx, pipe_state->creds);
238
239         return nt_status;
240 }
241                                                  
242 static NTSTATUS netr_ServerAuthenticate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
243                                         struct netr_ServerAuthenticate *r)
244 {
245         struct netr_ServerAuthenticate3 r3;
246         uint32_t rid = 0;
247         /* TODO: 
248          * negotiate_flags is used as an [in] parameter
249          * so it need to be initialised.
250          *
251          * (I think ... = 0; seems wrong here --metze)
252          */
253         uint32_t negotiate_flags = 0;  
254
255         r3.in.server_name = r->in.server_name;
256         r3.in.account_name = r->in.account_name;
257         r3.in.secure_channel_type = r->in.secure_channel_type;
258         r3.in.computer_name = r->in.computer_name;
259         r3.in.credentials = r->in.credentials;
260         r3.out.credentials = r->out.credentials;
261         r3.in.negotiate_flags = &negotiate_flags;
262         r3.out.negotiate_flags = &negotiate_flags;
263         r3.out.rid = &rid;
264         
265         return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
266 }
267
268 static NTSTATUS netr_ServerAuthenticate2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
269                                          struct netr_ServerAuthenticate2 *r)
270 {
271         struct netr_ServerAuthenticate3 r3;
272         uint32_t rid = 0;
273
274         r3.in.server_name = r->in.server_name;
275         r3.in.account_name = r->in.account_name;
276         r3.in.secure_channel_type = r->in.secure_channel_type;
277         r3.in.computer_name = r->in.computer_name;
278         r3.in.credentials = r->in.credentials;
279         r3.out.credentials = r->out.credentials;
280         r3.in.negotiate_flags = r->in.negotiate_flags;
281         r3.out.negotiate_flags = r->out.negotiate_flags;
282         r3.out.rid = &rid;
283         
284         return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
285 }
286
287
288 static NTSTATUS netr_creds_server_step_check(struct server_pipe_state *pipe_state,
289                                              struct netr_Authenticator *received_authenticator,
290                                              struct netr_Authenticator *return_authenticator) 
291 {
292         if (!pipe_state) {
293                 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
294                 return NT_STATUS_ACCESS_DENIED;
295         }
296
297         return creds_server_step_check(pipe_state->creds, 
298                                        received_authenticator, 
299                                        return_authenticator);
300 }
301
302
303 static NTSTATUS netr_ServerPasswordSet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
304                                        struct netr_ServerPasswordSet *r)
305 {
306         struct server_pipe_state *pipe_state = dce_call->context->private;
307
308         struct ldb_context *sam_ctx;
309         NTSTATUS nt_status;
310
311         nt_status = netr_creds_server_step_check(pipe_state, &r->in.credential, &r->out.return_authenticator);
312         NT_STATUS_NOT_OK_RETURN(nt_status);
313
314         sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
315         if (sam_ctx == NULL) {
316                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
317         }
318
319         creds_des_decrypt(pipe_state->creds, &r->in.new_password);
320
321         /* Using the sid for the account as the key, set the password */
322         nt_status = samdb_set_password_sid(sam_ctx, mem_ctx, 
323                                            pipe_state->creds->sid,
324                                            NULL, /* Don't have plaintext */
325                                            NULL, &r->in.new_password,
326                                            False, /* This is not considered a password change */
327                                            False, /* don't restrict this password change (match w2k3) */
328                                            NULL, NULL);
329         return nt_status;
330 }
331
332
333 /* 
334   netr_LogonUasLogon 
335 */
336 static WERROR netr_LogonUasLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
337                                  struct netr_LogonUasLogon *r)
338 {
339         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
340 }
341
342
343 /* 
344   netr_LogonUasLogoff 
345 */
346 static WERROR netr_LogonUasLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
347                        struct netr_LogonUasLogoff *r)
348 {
349         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
350 }
351
352
353 /* 
354   netr_LogonSamLogonEx
355
356   This version of the function allows other wrappers to say 'do not check the credentials'
357 */
358 static NTSTATUS netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
359                                      struct netr_LogonSamLogonEx *r)
360 {
361         struct server_pipe_state *pipe_state = dce_call->context->private;
362
363         struct auth_context *auth_context;
364         struct auth_usersupplied_info *user_info;
365         struct auth_serversupplied_info *server_info;
366         NTSTATUS nt_status;
367         static const char zeros[16];
368         struct netr_SamBaseInfo *sam;
369         struct netr_SamInfo2 *sam2;
370         struct netr_SamInfo3 *sam3;
371         struct netr_SamInfo6 *sam6;
372         
373         user_info = talloc(mem_ctx, struct auth_usersupplied_info);
374         if (!user_info) {
375                 return NT_STATUS_NO_MEMORY;
376         }
377
378         user_info->flags = 0;
379         user_info->mapped_state = False;
380         user_info->remote_host = NULL;
381
382         switch (r->in.logon_level) {
383         case 1:
384         case 3:
385         case 5:
386                 if (pipe_state->creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
387                         creds_arcfour_crypt(pipe_state->creds, 
388                                             r->in.logon.password->lmpassword.hash, 
389                                             sizeof(r->in.logon.password->lmpassword.hash));
390                         creds_arcfour_crypt(pipe_state->creds, 
391                                             r->in.logon.password->ntpassword.hash, 
392                                             sizeof(r->in.logon.password->ntpassword.hash));
393                 } else {
394                         creds_des_decrypt(pipe_state->creds, &r->in.logon.password->lmpassword);
395                         creds_des_decrypt(pipe_state->creds, &r->in.logon.password->ntpassword);
396                 }
397
398                 /* TODO: we need to deny anonymous access here */
399                 nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
400                                                 dce_call->event_ctx);
401                 NT_STATUS_NOT_OK_RETURN(nt_status);
402
403                 user_info->client.account_name = r->in.logon.network->identity_info.account_name.string;
404                 user_info->client.domain_name = r->in.logon.network->identity_info.domain_name.string;
405                 user_info->workstation_name = r->in.logon.network->identity_info.workstation.string;
406                 
407                 user_info->password_state = AUTH_PASSWORD_HASH;
408                 user_info->password.hash.lanman = talloc(user_info, struct samr_Password);
409                 if (!user_info->password.hash.lanman) {
410                         return NT_STATUS_NO_MEMORY;
411                 }
412                 *user_info->password.hash.lanman = r->in.logon.password->lmpassword;
413
414                 user_info->password.hash.nt = talloc(user_info, struct samr_Password);
415                 if (!user_info->password.hash.nt) {
416                         return NT_STATUS_NO_MEMORY;
417                 }
418                 *user_info->password.hash.nt = r->in.logon.password->ntpassword;
419                 break;          
420         case 2:
421         case 6:
422
423                 /* TODO: we need to deny anonymous access here */
424                 nt_status = auth_context_create(mem_ctx, lp_auth_methods(), &auth_context,
425                                                 dce_call->event_ctx);
426                 NT_STATUS_NOT_OK_RETURN(nt_status);
427
428                 nt_status = auth_context_set_challenge(auth_context, r->in.logon.network->challenge, "netr_LogonSamLogonWithFlags");
429                 NT_STATUS_NOT_OK_RETURN(nt_status);
430
431                 user_info->client.account_name = r->in.logon.network->identity_info.account_name.string;
432                 user_info->client.domain_name = r->in.logon.network->identity_info.domain_name.string;
433                 user_info->workstation_name = r->in.logon.network->identity_info.workstation.string;
434                 
435                 user_info->password_state = AUTH_PASSWORD_RESPONSE;
436                 user_info->password.response.lanman = data_blob(r->in.logon.network->lm.data, r->in.logon.network->lm.length);
437                 user_info->password.response.nt = data_blob(r->in.logon.network->nt.data, r->in.logon.network->nt.length);
438         
439                 break;
440         default:
441                 return NT_STATUS_INVALID_PARAMETER;
442         }
443         
444         nt_status = auth_check_password(auth_context, mem_ctx, user_info, &server_info);
445         NT_STATUS_NOT_OK_RETURN(nt_status);
446
447         nt_status = auth_convert_server_info_sambaseinfo(mem_ctx, server_info, &sam);
448
449         NT_STATUS_NOT_OK_RETURN(nt_status);
450
451         /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
452         /* It appears that level 6 is not individually encrypted */
453         if ((r->in.validation_level != 6) 
454             && memcmp(sam->key.key, zeros,  
455                       sizeof(sam->key.key)) != 0) {
456
457                 /* This key is sent unencrypted without the ARCFOUR flag set */
458                 if (pipe_state->creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
459                         creds_arcfour_crypt(pipe_state->creds, 
460                                             sam->key.key, 
461                                             sizeof(sam->key.key));
462                 }
463         }
464
465         /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
466         /* It appears that level 6 is not individually encrypted */
467         if ((r->in.validation_level != 6) 
468             && memcmp(sam->LMSessKey.key, zeros,  
469                       sizeof(sam->LMSessKey.key)) != 0) {
470                 if (pipe_state->creds->negotiate_flags & NETLOGON_NEG_ARCFOUR) {
471                         creds_arcfour_crypt(pipe_state->creds, 
472                                             sam->LMSessKey.key, 
473                                             sizeof(sam->LMSessKey.key));
474                 } else {
475                         creds_des_encrypt_LMKey(pipe_state->creds, 
476                                                 &sam->LMSessKey);
477                 }
478         }
479
480         switch (r->in.validation_level) {
481         case 2:
482                 sam2 = talloc_zero(mem_ctx, struct netr_SamInfo2);
483                 NT_STATUS_HAVE_NO_MEMORY(sam2);
484                 sam2->base = *sam;
485                 r->out.validation.sam2 = sam2;
486                 break;
487
488         case 3:
489                 sam3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
490                 NT_STATUS_HAVE_NO_MEMORY(sam3);
491                 sam3->base = *sam;
492                 r->out.validation.sam3 = sam3;
493                 break;
494
495         case 6:
496                 sam6 = talloc_zero(mem_ctx, struct netr_SamInfo6);
497                 NT_STATUS_HAVE_NO_MEMORY(sam6);
498                 sam6->base = *sam;
499                 sam6->forest.string = lp_realm();
500                 sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s", 
501                                                          sam->account_name.string, sam6->forest.string);
502                 NT_STATUS_HAVE_NO_MEMORY(sam6->principle.string);
503                 r->out.validation.sam6 = sam6;
504                 break;
505
506         default:
507                 break;
508         }
509
510         r->out.authoritative = 1;
511
512         /* TODO: Describe and deal with these flags */
513         r->out.flags = 0;
514
515         return NT_STATUS_OK;
516 }
517
518 /* 
519   netr_LogonSamLogonWithFlags
520
521 */
522 static NTSTATUS netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
523                                             struct netr_LogonSamLogonWithFlags *r)
524 {
525         struct server_pipe_state *pipe_state = dce_call->context->private;
526         NTSTATUS nt_status;
527         struct netr_LogonSamLogonEx r2;
528
529         struct netr_Authenticator *return_authenticator;
530
531         return_authenticator = talloc(mem_ctx, struct netr_Authenticator);
532         NT_STATUS_HAVE_NO_MEMORY(return_authenticator);
533
534         nt_status = netr_creds_server_step_check(pipe_state, r->in.credential, return_authenticator);
535         NT_STATUS_NOT_OK_RETURN(nt_status);
536
537         ZERO_STRUCT(r2);
538
539         r2.in.server_name       = r->in.server_name;
540         r2.in.workstation       = r->in.workstation;
541         r2.in.logon_level       = r->in.logon_level;
542         r2.in.logon             = r->in.logon;
543         r2.in.validation_level  = r->in.validation_level;
544         r2.in.flags             = r->in.flags;
545
546         nt_status = netr_LogonSamLogonEx(dce_call, mem_ctx, &r2);
547
548         r->out.return_authenticator     = return_authenticator;
549         r->out.validation               = r2.out.validation;
550         r->out.authoritative            = r2.out.authoritative;
551         r->out.flags                    = r2.out.flags;
552
553         return nt_status;
554 }
555
556 /* 
557   netr_LogonSamLogon
558 */
559 static NTSTATUS netr_LogonSamLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
560                                    struct netr_LogonSamLogon *r)
561 {
562         struct netr_LogonSamLogonWithFlags r2;
563         NTSTATUS status;
564
565         ZERO_STRUCT(r2);
566
567         r2.in.server_name = r->in.server_name;
568         r2.in.workstation = r->in.workstation;
569         r2.in.credential  = r->in.credential;
570         r2.in.return_authenticator = r->in.return_authenticator;
571         r2.in.logon_level = r->in.logon_level;
572         r2.in.logon = r->in.logon;
573         r2.in.validation_level = r->in.validation_level;
574         r2.in.flags = 0;
575
576         status = netr_LogonSamLogonWithFlags(dce_call, mem_ctx, &r2);
577
578         r->out.return_authenticator = r2.out.return_authenticator;
579         r->out.validation = r2.out.validation;
580         r->out.authoritative = r2.out.authoritative;
581
582         return status;
583 }
584
585
586 /* 
587   netr_LogonSamLogoff 
588 */
589 static NTSTATUS netr_LogonSamLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
590                        struct netr_LogonSamLogoff *r)
591 {
592         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
593 }
594
595
596
597 /* 
598   netr_DatabaseDeltas 
599 */
600 static NTSTATUS netr_DatabaseDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
601                        struct netr_DatabaseDeltas *r)
602 {
603         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
604 }
605
606
607 /* 
608   netr_DatabaseSync 
609 */
610 static NTSTATUS netr_DatabaseSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
611                        struct netr_DatabaseSync *r)
612 {
613         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
614 }
615
616
617 /* 
618   netr_AccountDeltas 
619 */
620 static NTSTATUS netr_AccountDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
621                        struct netr_AccountDeltas *r)
622 {
623         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
624 }
625
626
627 /* 
628   netr_AccountSync 
629 */
630 static NTSTATUS netr_AccountSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
631                        struct netr_AccountSync *r)
632 {
633         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
634 }
635
636
637 /* 
638   netr_GetDcName 
639 */
640 static NTSTATUS netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
641                        struct netr_GetDcName *r)
642 {
643         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
644 }
645
646
647 /* 
648   netr_LogonControl 
649 */
650 static WERROR netr_LogonControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
651                        struct netr_LogonControl *r)
652 {
653         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
654 }
655
656
657 /* 
658   netr_GetAnyDCName 
659 */
660 static WERROR netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
661                        struct netr_GetAnyDCName *r)
662 {
663         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
664 }
665
666
667 /* 
668   netr_LogonControl2 
669 */
670 static WERROR netr_LogonControl2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
671                        struct netr_LogonControl2 *r)
672 {
673         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
674 }
675
676
677 /* 
678   netr_DatabaseSync2 
679 */
680 static NTSTATUS netr_DatabaseSync2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
681                        struct netr_DatabaseSync2 *r)
682 {
683         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
684 }
685
686
687 /* 
688   netr_DatabaseRedo 
689 */
690 static NTSTATUS netr_DatabaseRedo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
691                        struct netr_DatabaseRedo *r)
692 {
693         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
694 }
695
696
697 /* 
698   netr_LogonControl2Ex 
699 */
700 static WERROR netr_LogonControl2Ex(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
701                        struct netr_LogonControl2Ex *r)
702 {
703         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
704 }
705
706
707 /* 
708   netr_NETRENUMERATETRUSTEDDOMAINS 
709 */
710 static WERROR netr_NETRENUMERATETRUSTEDDOMAINS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
711                        struct netr_NETRENUMERATETRUSTEDDOMAINS *r)
712 {
713         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
714 }
715
716
717 /* 
718   netr_DSRGETDCNAME 
719 */
720 static WERROR netr_DSRGETDCNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
721                        struct netr_DSRGETDCNAME *r)
722 {
723         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
724 }
725
726
727 /* 
728   netr_NETRLOGONDUMMYROUTINE1 
729 */
730 static WERROR netr_NETRLOGONDUMMYROUTINE1(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
731                        struct netr_NETRLOGONDUMMYROUTINE1 *r)
732 {
733         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
734 }
735
736
737 /* 
738   netr_NETRLOGONSETSERVICEBITS 
739 */
740 static WERROR netr_NETRLOGONSETSERVICEBITS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
741                        struct netr_NETRLOGONSETSERVICEBITS *r)
742 {
743         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
744 }
745
746
747 /* 
748   netr_NETRLOGONGETTRUSTRID 
749 */
750 static WERROR netr_NETRLOGONGETTRUSTRID(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
751                        struct netr_NETRLOGONGETTRUSTRID *r)
752 {
753         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
754 }
755
756
757 /* 
758   netr_NETRLOGONCOMPUTESERVERDIGEST 
759 */
760 static WERROR netr_NETRLOGONCOMPUTESERVERDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
761                        struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
762 {
763         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
764 }
765
766
767 /* 
768   netr_NETRLOGONCOMPUTECLIENTDIGEST 
769 */
770 static WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
771                        struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
772 {
773         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
774 }
775
776
777 /* 
778   netr_DSRGETDCNAMEX 
779 */
780 static WERROR netr_DSRGETDCNAMEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
781                        struct netr_DSRGETDCNAMEX *r)
782 {
783         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
784 }
785
786
787 /* 
788   netr_DSRGETSITENAME 
789 */
790 static WERROR netr_DSRGETSITENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
791                        struct netr_DSRGETSITENAME *r)
792 {
793         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
794 }
795
796
797 /*
798   fill in a netr_DomainTrustInfo from a ldb search result
799 */
800 static NTSTATUS fill_domain_primary_info(TALLOC_CTX *mem_ctx, struct ldb_message *res,
801                                          struct netr_DomainTrustInfo *info, 
802                                          const char *local_domain)
803 {
804         ZERO_STRUCTP(info);
805
806         info->domainname.string = local_domain;
807         info->fulldomainname.string = talloc_asprintf(info, "%s.", samdb_result_string(res, "dnsDomain", NULL));
808         /* TODO: we need proper forest support */
809         info->forest.string = info->fulldomainname.string;
810         info->guid = samdb_result_guid(res, "objectGUID");
811         info->sid = samdb_result_dom_sid(mem_ctx, res, "objectSid");
812
813         return NT_STATUS_OK;
814 }
815
816 /*
817   fill in a netr_DomainTrustInfo from a ldb search result
818 */
819 static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx, struct ldb_message *res,
820                                        struct netr_DomainTrustInfo *info, 
821                                        const char *local_domain, BOOL is_local)
822 {
823         ZERO_STRUCTP(info);
824
825         if (is_local) {
826                 info->domainname.string = local_domain;
827                 info->fulldomainname.string = samdb_result_string(res, "dnsDomain", NULL);
828                 info->forest.string = NULL;
829                 info->guid = samdb_result_guid(res, "objectGUID");
830                 info->sid = samdb_result_dom_sid(mem_ctx, res, "objectSid");
831         } else {
832                 info->domainname.string = samdb_result_string(res, "flatName", NULL);
833                 info->fulldomainname.string = samdb_result_string(res, "name", NULL);
834                 info->forest.string = NULL;
835                 info->guid = samdb_result_guid(res, "objectGUID");
836                 info->sid = samdb_result_dom_sid(mem_ctx, res, "securityIdentifier");
837         }
838
839         return NT_STATUS_OK;
840 }
841
842 /* 
843   netr_LogonGetDomainInfo
844   this is called as part of the ADS domain logon procedure.
845 */
846 static NTSTATUS netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
847                                         struct netr_LogonGetDomainInfo *r)
848 {
849         struct server_pipe_state *pipe_state = dce_call->context->private;
850         const char * const attrs[] = { "dnsDomain", "objectSid", 
851                                        "objectGUID", "flatName", "securityIdentifier",
852                                        NULL };
853         const char * const ref_attrs[] = { "nETBIOSName", NULL };
854         struct ldb_context *sam_ctx;
855         struct ldb_message **res1, **res2, **ref_res;
856         struct netr_DomainInfo1 *info1;
857         int ret, ret1, ret2, i;
858         NTSTATUS status;
859
860         const char *local_domain;
861
862         status = netr_creds_server_step_check(pipe_state, 
863                                               r->in.credential, r->out.return_authenticator);
864         if (!NT_STATUS_IS_OK(status)) {
865                 return status;
866         }
867
868         sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
869         if (sam_ctx == NULL) {
870                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
871         }
872
873         /* we need to do two searches. The first will pull our primary
874            domain and the second will pull any trusted domains. Our
875            primary domain is also a "trusted" domain, so we need to
876            put the primary domain into the lists of returned trusts as
877            well */
878         ret1 = gendb_search(sam_ctx, mem_ctx, NULL, &res1, attrs, "(objectClass=domainDNS)");
879         if (ret1 != 1) {
880                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
881         }
882
883         /* try and find the domain */
884         ret = gendb_search(sam_ctx, mem_ctx, NULL, 
885                            &ref_res, ref_attrs, 
886                            "(&(objectClass=crossRef)(ncName=%s))", 
887                            ldb_dn_linearize(mem_ctx, res1[0]->dn));
888         if (ret != 1) {
889                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
890         }
891
892         local_domain = samdb_result_string(ref_res[0], "nETBIOSName", NULL);
893
894         ret2 = gendb_search(sam_ctx, mem_ctx, NULL, &res2, attrs, "(objectClass=trustedDomain)");
895         if (ret2 == -1) {
896                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
897         }
898
899         info1 = talloc(mem_ctx, struct netr_DomainInfo1);
900         if (info1 == NULL) {
901                 return NT_STATUS_NO_MEMORY;
902         }
903
904         ZERO_STRUCTP(info1);
905
906         info1->num_trusts = ret2 + 1;
907         info1->trusts = talloc_array(mem_ctx, struct netr_DomainTrustInfo, 
908                                        info1->num_trusts);
909         if (info1->trusts == NULL) {
910                 return NT_STATUS_NO_MEMORY;
911         }
912
913         status = fill_domain_primary_info(mem_ctx, res1[0], &info1->domaininfo, local_domain);
914         if (!NT_STATUS_IS_OK(status)) {
915                 return status;
916         }
917
918         for (i=0;i<ret2;i++) {
919                 status = fill_domain_trust_info(mem_ctx, res2[i], &info1->trusts[i], NULL, False);
920                 if (!NT_STATUS_IS_OK(status)) {
921                         return status;
922                 }
923         }
924
925         status = fill_domain_trust_info(mem_ctx, res1[0], &info1->trusts[i], local_domain, True);
926         if (!NT_STATUS_IS_OK(status)) {
927                 return status;
928         }
929
930         r->out.info.info1 = info1;
931
932         return NT_STATUS_OK;
933 }
934
935
936 /* 
937   netr_ServerPasswordSet2 
938 */
939 static NTSTATUS netr_ServerPasswordSet2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
940                                        struct netr_ServerPasswordSet2 *r)
941 {
942         struct server_pipe_state *pipe_state = dce_call->context->private;
943
944         struct ldb_context *sam_ctx;
945         NTSTATUS nt_status;
946         char new_pass[512];
947         uint32_t new_pass_len;
948         BOOL ret;
949
950         struct samr_CryptPassword password_buf;
951
952         nt_status = netr_creds_server_step_check(pipe_state, &r->in.credential, &r->out.return_authenticator);
953         NT_STATUS_NOT_OK_RETURN(nt_status);
954
955         sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx));
956         if (sam_ctx == NULL) {
957                 return NT_STATUS_INVALID_SYSTEM_SERVICE;
958         }
959
960         memcpy(password_buf.data, r->in.new_password.data, 512);
961         SIVAL(password_buf.data,512,r->in.new_password.length);
962         creds_arcfour_crypt(pipe_state->creds, password_buf.data, 516);
963
964         ret = decode_pw_buffer(password_buf.data, new_pass, sizeof(new_pass),
965                                &new_pass_len, STR_UNICODE);
966         if (!ret) {
967                 DEBUG(3,("netr_ServerPasswordSet2: failed to decode password buffer\n"));
968                 return NT_STATUS_ACCESS_DENIED;
969         }
970
971         /* Using the sid for the account as the key, set the password */
972         nt_status = samdb_set_password_sid(sam_ctx, mem_ctx,
973                                            pipe_state->creds->sid,
974                                            new_pass, /* we have plaintext */
975                                            NULL, NULL,
976                                            False, /* This is not considered a password change */
977                                            False, /* don't restrict this password change (match w2k3) */
978                                            NULL, NULL);
979         return nt_status;
980 }
981
982
983 /* 
984   netr_NETRSERVERPASSWORDGET 
985 */
986 static WERROR netr_NETRSERVERPASSWORDGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
987                        struct netr_NETRSERVERPASSWORDGET *r)
988 {
989         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
990 }
991
992
993 /* 
994   netr_NETRLOGONSENDTOSAM 
995 */
996 static WERROR netr_NETRLOGONSENDTOSAM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
997                        struct netr_NETRLOGONSENDTOSAM *r)
998 {
999         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1000 }
1001
1002
1003 /* 
1004   netr_DSRADDRESSTOSITENAMESW 
1005 */
1006 static WERROR netr_DSRADDRESSTOSITENAMESW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1007                        struct netr_DSRADDRESSTOSITENAMESW *r)
1008 {
1009         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1010 }
1011
1012
1013 /* 
1014   netr_DrsGetDCNameEx2
1015 */
1016 static WERROR netr_DrsGetDCNameEx2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1017                        struct netr_DrsGetDCNameEx2 *r)
1018 {
1019         const char * const attrs[] = { "dnsDomain", "objectGUID", NULL };
1020         void *sam_ctx;
1021         struct ldb_message **res;
1022         int ret;
1023
1024         ZERO_STRUCT(r->out);
1025
1026         sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
1027         if (sam_ctx == NULL) {
1028                 return WERR_DS_SERVICE_UNAVAILABLE;
1029         }
1030
1031         ret = gendb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
1032                                 "(&(objectClass=domainDNS)(dnsDomain=%s))",
1033                                 r->in.domain_name);
1034         if (ret != 1) {
1035                 return WERR_NO_SUCH_DOMAIN;
1036         }
1037
1038         r->out.info = talloc(mem_ctx, struct netr_DrsGetDCNameEx2Info);
1039         if (!r->out.info) {
1040                 return WERR_NOMEM;
1041         }
1042
1043         /* TODO: - return real IP address
1044          *       - check all r->in.* parameters (server_unc is ignored by w2k3!)
1045          */
1046         r->out.info->dc_unc             = talloc_asprintf(mem_ctx, "\\\\%s.%s", lp_netbios_name(),lp_realm());
1047         r->out.info->dc_address = talloc_strdup(mem_ctx, "\\\\0.0.0.0");
1048         r->out.info->dc_address_type    = 1;
1049         r->out.info->domain_guid        = samdb_result_guid(res[0], "objectGUID");
1050         r->out.info->domain_name        = samdb_result_string(res[0], "dnsDomain", NULL);
1051         r->out.info->forest_name        = samdb_result_string(res[0], "dnsDomain", NULL);
1052         r->out.info->dc_flags           = 0xE00001FD;
1053         r->out.info->dc_site_name       = talloc_strdup(mem_ctx, "Default-First-Site-Name");
1054         r->out.info->client_site_name   = talloc_strdup(mem_ctx, "Default-First-Site-Name");
1055
1056         return WERR_OK;
1057 }
1058
1059
1060 /* 
1061   netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN 
1062 */
1063 static WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1064                        struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1065 {
1066         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1067 }
1068
1069
1070 /* 
1071   netr_NETRENUMERATETRUSTEDDOMAINSEX 
1072 */
1073 static WERROR netr_NETRENUMERATETRUSTEDDOMAINSEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1074                        struct netr_NETRENUMERATETRUSTEDDOMAINSEX *r)
1075 {
1076         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1077 }
1078
1079
1080 /* 
1081   netr_DSRADDRESSTOSITENAMESEXW 
1082 */
1083 static WERROR netr_DSRADDRESSTOSITENAMESEXW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1084                        struct netr_DSRADDRESSTOSITENAMESEXW *r)
1085 {
1086         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1087 }
1088
1089
1090 /* 
1091   netr_DSRGETDCSITECOVERAGEW 
1092 */
1093 static WERROR netr_DSRGETDCSITECOVERAGEW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1094                        struct netr_DSRGETDCSITECOVERAGEW *r)
1095 {
1096         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1097 }
1098
1099
1100 /* 
1101   netr_DsrEnumerateDomainTrusts 
1102 */
1103 static WERROR netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1104                                               struct netr_DsrEnumerateDomainTrusts *r)
1105 {
1106         struct netr_DomainTrust *trusts;
1107         void *sam_ctx;
1108         int ret;
1109         struct ldb_message **dom_res, **ref_res;
1110         const char * const dom_attrs[] = { "dnsDomain", "objectSid", "objectGUID", NULL };
1111         const char * const ref_attrs[] = { "nETBIOSName", NULL };
1112
1113         ZERO_STRUCT(r->out);
1114
1115         sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info);
1116         if (sam_ctx == NULL) {
1117                 return WERR_GENERAL_FAILURE;
1118         }
1119
1120         ret = gendb_search_dn(sam_ctx, mem_ctx, samdb_base_dn(mem_ctx), &dom_res, dom_attrs);
1121         if (ret == -1) {
1122                 return WERR_GENERAL_FAILURE;            
1123         }
1124
1125         if (ret != 1) {
1126                 return WERR_GENERAL_FAILURE;
1127         }
1128
1129         ret = gendb_search(sam_ctx, mem_ctx, NULL, &ref_res, ref_attrs,
1130                            "(&(objectClass=crossRef)(ncName=%s))",
1131                            ldb_dn_linearize(mem_ctx, dom_res[0]->dn));
1132         if (ret == -1) {
1133                 return WERR_GENERAL_FAILURE;
1134         }
1135
1136         if (ret != 1) {
1137                 return WERR_GENERAL_FAILURE;
1138         }
1139
1140
1141
1142         trusts = talloc_array(mem_ctx, struct netr_DomainTrust, ret);
1143         if (trusts == NULL) {
1144                 return WERR_NOMEM;
1145         }
1146         
1147         r->out.count = 1;
1148         r->out.trusts = trusts;
1149
1150         /* TODO: add filtering by trust_flags, and correct trust_type
1151            and attributes */
1152         trusts[0].netbios_name = samdb_result_string(ref_res[0], "nETBIOSName", NULL);
1153         trusts[0].dns_name     = samdb_result_string(dom_res[0], "dnsDomain", NULL);
1154         trusts[0].trust_flags = 
1155                 NETR_TRUST_FLAG_TREEROOT | 
1156                 NETR_TRUST_FLAG_IN_FOREST | 
1157                 NETR_TRUST_FLAG_PRIMARY;
1158         trusts[0].parent_index = 0;
1159         trusts[0].trust_type = 2;
1160         trusts[0].trust_attributes = 0;
1161         trusts[0].sid  = samdb_result_dom_sid(mem_ctx, dom_res[0], "objectSid");
1162         trusts[0].guid = samdb_result_guid(dom_res[0], "objectGUID");
1163
1164         return WERR_OK;
1165 }
1166
1167
1168 /* 
1169   netr_DSRDEREGISTERDNSHOSTRECORDS 
1170 */
1171 static WERROR netr_DSRDEREGISTERDNSHOSTRECORDS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1172                        struct netr_DSRDEREGISTERDNSHOSTRECORDS *r)
1173 {
1174         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1175 }
1176
1177
1178 /* 
1179   netr_NETRSERVERTRUSTPASSWORDSGET 
1180 */
1181 static WERROR netr_NETRSERVERTRUSTPASSWORDSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1182                        struct netr_NETRSERVERTRUSTPASSWORDSGET *r)
1183 {
1184         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1185 }
1186
1187
1188 /* 
1189   netr_DSRGETFORESTTRUSTINFORMATION 
1190 */
1191 static WERROR netr_DSRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1192                        struct netr_DSRGETFORESTTRUSTINFORMATION *r)
1193 {
1194         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1195 }
1196
1197
1198 /* 
1199   netr_NETRGETFORESTTRUSTINFORMATION 
1200 */
1201 static WERROR netr_NETRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1202                        struct netr_NETRGETFORESTTRUSTINFORMATION *r)
1203 {
1204         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1205 }
1206
1207
1208 /* 
1209   netr_NETRSERVERGETTRUSTINFO 
1210 */
1211 static WERROR netr_NETRSERVERGETTRUSTINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1212                        struct netr_NETRSERVERGETTRUSTINFO *r)
1213 {
1214         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1215 }
1216
1217
1218 /* include the generated boilerplate */
1219 #include "librpc/gen_ndr/ndr_netlogon_s.c"