2 Unix SMB/CIFS implementation.
4 endpoint server for the netlogon pipe
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "rpc_server/common/common.h"
26 struct server_pipe_state {
27 struct netr_Credential client_challenge;
28 struct netr_Credential server_challenge;
31 char *computer_name; /* for logging only */
33 uint16_t sec_chan_type;
34 struct creds_CredentialState *creds;
39 a client has connected to the netlogon server using schannel, so we need
40 to re-establish the credentials state
42 static NTSTATUS netlogon_schannel_setup(struct dcesrv_call_state *dce_call)
44 struct server_pipe_state *state;
47 state = talloc_p(dce_call->conn, struct server_pipe_state);
49 return NT_STATUS_NO_MEMORY;
52 state->authenticated = True;
54 if (dce_call->conn->auth_state.session_info == NULL) {
56 smb_panic("No session info provided by schannel level setup!");
57 return NT_STATUS_NO_USER_SESSION_KEY;
60 status = dcerpc_schannel_creds(dce_call->conn->auth_state.gensec_security,
64 if (!NT_STATUS_IS_OK(status)) {
65 DEBUG(3, ("getting schannel credentials failed with %s\n", nt_errstr(status)));
70 dce_call->conn->private = state;
76 a hook for bind on the netlogon pipe
78 static NTSTATUS netlogon_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *di)
80 dce_call->conn->private = NULL;
82 /* if this is a schannel bind then we need to reconstruct the pipe state */
83 if (dce_call->conn->auth_state.auth_info &&
84 dce_call->conn->auth_state.auth_info->auth_type == DCERPC_AUTH_TYPE_SCHANNEL) {
87 DEBUG(5, ("schannel bind on netlogon\n"));
89 status = netlogon_schannel_setup(dce_call);
90 if (!NT_STATUS_IS_OK(status)) {
91 DEBUG(3, ("schannel bind on netlogon failed with %s\n", nt_errstr(status)));
99 /* this function is called when the client disconnects the endpoint */
100 static void netlogon_unbind(struct dcesrv_connection *conn, const struct dcesrv_interface *di)
102 struct server_pipe_state *pipe_state = conn->private;
105 talloc_free(pipe_state);
108 conn->private = NULL;
111 #define DCESRV_INTERFACE_NETLOGON_BIND netlogon_bind
112 #define DCESRV_INTERFACE_NETLOGON_UNBIND netlogon_unbind
114 static NTSTATUS netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
115 struct netr_ServerReqChallenge *r)
117 struct server_pipe_state *pipe_state = dce_call->conn->private;
119 ZERO_STRUCTP(r->out.credentials);
121 /* destroyed on pipe shutdown */
124 talloc_free(pipe_state);
125 dce_call->conn->private = NULL;
128 pipe_state = talloc_p(dce_call->conn, struct server_pipe_state);
130 return NT_STATUS_NO_MEMORY;
133 pipe_state->authenticated = False;
134 pipe_state->creds = NULL;
135 pipe_state->account_name = NULL;
136 pipe_state->computer_name = NULL;
138 pipe_state->client_challenge = *r->in.credentials;
140 generate_random_buffer(pipe_state->server_challenge.data,
141 sizeof(pipe_state->server_challenge.data));
143 *r->out.credentials = pipe_state->server_challenge;
145 dce_call->conn->private = pipe_state;
150 static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
151 struct netr_ServerAuthenticate3 *r)
153 struct server_pipe_state *pipe_state = dce_call->conn->private;
155 struct samr_Password *mach_pwd;
158 struct ldb_message **msgs;
160 const char *attrs[] = {"unicodePwd", "lmPwdHash", "ntPwdHash", "userAccountControl",
163 ZERO_STRUCTP(r->out.credentials);
165 *r->out.negotiate_flags = *r->in.negotiate_flags;
168 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
169 return NT_STATUS_ACCESS_DENIED;
172 sam_ctx = samdb_connect(mem_ctx);
173 if (sam_ctx == NULL) {
174 return NT_STATUS_INVALID_SYSTEM_SERVICE;
176 /* pull the user attributes */
177 num_records = samdb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
178 "(&(sAMAccountName=%s)(objectclass=user))",
181 if (num_records == 0) {
182 DEBUG(3,("Couldn't find user [%s] in samdb.\n",
183 r->in.account_name));
184 return NT_STATUS_NO_SUCH_USER;
187 if (num_records > 1) {
188 DEBUG(0,("Found %d records matching user [%s]\n", num_records, r->in.account_name));
189 return NT_STATUS_INTERNAL_DB_CORRUPTION;
192 acct_flags = samdb_result_acct_flags(msgs[0],
193 "userAccountControl");
195 if (acct_flags & ACB_DISABLED) {
196 DEBUG(1, ("Account [%s] is disabled\n", r->in.account_name));
197 return NT_STATUS_ACCESS_DENIED;
200 if (r->in.secure_channel_type == SEC_CHAN_WKSTA) {
201 if (!(acct_flags & ACB_WSTRUST)) {
202 DEBUG(1, ("Client asked for a workstation secure channel, but is not a workstation (member server) acb flags: 0x%x\n", acct_flags));
203 return NT_STATUS_ACCESS_DENIED;
205 } else if (r->in.secure_channel_type == SEC_CHAN_DOMAIN) {
206 if (!(acct_flags & ACB_DOMTRUST)) {
207 DEBUG(1, ("Client asked for a trusted domain secure channel, but is not a trusted domain: acb flags: 0x%x\n", acct_flags));
208 return NT_STATUS_ACCESS_DENIED;
210 } else if (r->in.secure_channel_type == SEC_CHAN_BDC) {
211 if (!(acct_flags & ACB_SVRTRUST)) {
212 DEBUG(1, ("Client asked for a server secure channel, but is not a server (domain controller): acb flags: 0x%x\n", acct_flags));
213 return NT_STATUS_ACCESS_DENIED;
216 DEBUG(1, ("Client asked for an invalid secure channel type: %d\n",
217 r->in.secure_channel_type));
218 return NT_STATUS_ACCESS_DENIED;
221 pipe_state->acct_flags = acct_flags;
222 pipe_state->sec_chan_type = r->in.secure_channel_type;
224 *r->out.rid = samdb_result_rid_from_sid(mem_ctx, msgs[0], "objectSid", 0);
226 nt_status = samdb_result_passwords(mem_ctx, msgs[0], NULL, &mach_pwd);
227 if (!NT_STATUS_IS_OK(nt_status) || mach_pwd == NULL) {
228 return NT_STATUS_ACCESS_DENIED;
231 if (!pipe_state->creds) {
232 pipe_state->creds = talloc_p(pipe_state, struct creds_CredentialState);
233 if (!pipe_state->creds) {
234 return NT_STATUS_NO_MEMORY;
238 creds_server_init(pipe_state->creds, &pipe_state->client_challenge,
239 &pipe_state->server_challenge, mach_pwd,
241 *r->in.negotiate_flags);
243 if (!creds_server_check(pipe_state->creds, r->in.credentials)) {
244 return NT_STATUS_ACCESS_DENIED;
247 pipe_state->authenticated = True;
249 if (pipe_state->account_name) {
250 /* We don't want a memory leak on this long-lived talloc context */
251 talloc_free(pipe_state->account_name);
254 pipe_state->account_name = talloc_strdup(pipe_state, r->in.account_name);
256 if (pipe_state->computer_name) {
257 /* We don't want a memory leak on this long-lived talloc context */
258 talloc_free(pipe_state->account_name);
261 pipe_state->computer_name = talloc_strdup(pipe_state, r->in.computer_name);
263 /* remember this session key state */
264 nt_status = schannel_store_session_key(mem_ctx, pipe_state->computer_name, pipe_state->creds);
269 static NTSTATUS netr_ServerAuthenticate(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
270 struct netr_ServerAuthenticate *r)
272 struct netr_ServerAuthenticate3 r3;
275 * negotiate_flags is used as an [in] parameter
276 * so it need to be initialised.
278 * (I think ... = 0; seems wrong here --metze)
280 uint32 negotiate_flags = 0;
282 r3.in.server_name = r->in.server_name;
283 r3.in.account_name = r->in.account_name;
284 r3.in.secure_channel_type = r->in.secure_channel_type;
285 r3.in.computer_name = r->in.computer_name;
286 r3.in.credentials = r->in.credentials;
287 r3.out.credentials = r->out.credentials;
288 r3.in.negotiate_flags = &negotiate_flags;
289 r3.out.negotiate_flags = &negotiate_flags;
292 return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
295 static NTSTATUS netr_ServerAuthenticate2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
296 struct netr_ServerAuthenticate2 *r)
298 struct netr_ServerAuthenticate3 r3;
301 r3.in.server_name = r->in.server_name;
302 r3.in.account_name = r->in.account_name;
303 r3.in.secure_channel_type = r->in.secure_channel_type;
304 r3.in.computer_name = r->in.computer_name;
305 r3.in.credentials = r->in.credentials;
306 r3.out.credentials = r->out.credentials;
307 r3.in.negotiate_flags = r->in.negotiate_flags;
308 r3.out.negotiate_flags = r->out.negotiate_flags;
311 return netr_ServerAuthenticate3(dce_call, mem_ctx, &r3);
315 static BOOL netr_creds_server_step_check(struct server_pipe_state *pipe_state,
316 struct netr_Authenticator *received_authenticator,
317 struct netr_Authenticator *return_authenticator)
319 if (!pipe_state->authenticated) {
322 return creds_server_step_check(pipe_state->creds,
323 received_authenticator,
324 return_authenticator);
328 static NTSTATUS netr_ServerPasswordSet(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
329 struct netr_ServerPasswordSet *r)
331 struct server_pipe_state *pipe_state = dce_call->conn->private;
335 int num_records_domain;
337 struct ldb_message **msgs;
338 struct ldb_message **msgs_domain;
340 struct ldb_message mod, *msg_set_pw = &mod;
341 const char *domain_dn;
342 const char *domain_sid;
344 const char *attrs[] = {"objectSid", NULL };
346 const char **domain_attrs = attrs;
350 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
351 return NT_STATUS_ACCESS_DENIED;
354 if (!netr_creds_server_step_check(pipe_state, &r->in.credential, &r->out.return_authenticator)) {
355 return NT_STATUS_ACCESS_DENIED;
358 sam_ctx = samdb_connect(mem_ctx);
359 if (sam_ctx == NULL) {
360 return NT_STATUS_INVALID_SYSTEM_SERVICE;
362 /* pull the user attributes */
363 num_records = samdb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
364 "(&(sAMAccountName=%s)(objectclass=user))",
365 pipe_state->account_name);
367 if (num_records == 0) {
368 DEBUG(3,("Couldn't find user [%s] in samdb.\n",
369 pipe_state->account_name));
370 return NT_STATUS_NO_SUCH_USER;
373 if (num_records > 1) {
374 DEBUG(0,("Found %d records matching user [%s]\n", num_records,
375 pipe_state->account_name));
376 return NT_STATUS_INTERNAL_DB_CORRUPTION;
379 domain_sid = samdb_result_sid_prefix(mem_ctx, msgs[0], "objectSid");
381 DEBUG(0,("no objectSid in user record\n"));
382 return NT_STATUS_INTERNAL_DB_CORRUPTION;
385 /* find the domain's DN */
386 num_records_domain = samdb_search(sam_ctx, mem_ctx, NULL,
387 &msgs_domain, domain_attrs,
388 "(&(objectSid=%s)(objectclass=domain))",
391 if (num_records_domain == 0) {
392 DEBUG(3,("check_sam_security: Couldn't find domain [%s] in passdb file.\n",
394 return NT_STATUS_NO_SUCH_USER;
397 if (num_records_domain > 1) {
398 DEBUG(0,("Found %d records matching domain [%s]\n",
399 num_records_domain, domain_sid));
400 return NT_STATUS_INTERNAL_DB_CORRUPTION;
403 domain_dn = msgs_domain[0]->dn;
405 mod.dn = talloc_strdup(mem_ctx, msgs[0]->dn);
407 return NT_STATUS_NO_MEMORY;
410 creds_des_decrypt(pipe_state->creds, &r->in.new_password);
412 /* set the password - samdb needs to know both the domain and user DNs,
413 so the domain password policy can be used */
414 nt_status = samdb_set_password(sam_ctx, mem_ctx,
415 msgs[0]->dn, domain_dn,
417 NULL, /* Don't have plaintext */
418 NULL, &r->in.new_password,
419 False /* This is not considered a password change */,
422 if (!NT_STATUS_IS_OK(nt_status)) {
426 ret = samdb_replace(sam_ctx, mem_ctx, msg_set_pw);
428 /* we really need samdb.c to return NTSTATUS */
429 return NT_STATUS_UNSUCCESSFUL;
439 static WERROR netr_LogonUasLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
440 struct netr_LogonUasLogon *r)
442 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
449 static WERROR netr_LogonUasLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
450 struct netr_LogonUasLogoff *r)
452 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
457 netr_LogonSamLogonWithFlags
460 static NTSTATUS netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
461 struct netr_LogonSamLogonWithFlags *r)
463 struct server_pipe_state *pipe_state = dce_call->conn->private;
465 struct auth_context *auth_context;
466 struct auth_usersupplied_info *user_info;
467 struct auth_serversupplied_info *server_info;
470 static const char zeros[16];
471 struct netr_SamBaseInfo *sam;
472 struct netr_SamInfo2 *sam2;
473 struct netr_SamInfo3 *sam3;
474 struct netr_SamInfo6 *sam6;
477 DEBUG(1, ("No challenge requested by client, cannot authenticate\n"));
478 return NT_STATUS_ACCESS_DENIED;
481 r->out.return_authenticator = talloc_p(mem_ctx, struct netr_Authenticator);
482 if (!r->out.return_authenticator) {
483 return NT_STATUS_NO_MEMORY;
486 if (!netr_creds_server_step_check(pipe_state, r->in.credential, r->out.return_authenticator)) {
487 return NT_STATUS_ACCESS_DENIED;
490 switch (r->in.logon_level) {
494 creds_arcfour_crypt(pipe_state->creds,
495 r->in.logon.password->lmpassword.hash,
496 sizeof(r->in.logon.password->lmpassword.hash));
497 creds_arcfour_crypt(pipe_state->creds,
498 r->in.logon.password->ntpassword.hash,
499 sizeof(r->in.logon.password->ntpassword.hash));
501 nt_status = make_auth_context_subsystem(pipe_state, &auth_context);
502 if (!NT_STATUS_IS_OK(nt_status)) {
506 chal = auth_context->get_ntlm_challenge(auth_context);
507 nt_status = make_user_info_netlogon_interactive(&user_info,
508 r->in.logon.password->identity_info.account_name.string,
509 r->in.logon.password->identity_info.domain_name.string,
510 r->in.logon.password->identity_info.workstation.string,
512 &r->in.logon.password->lmpassword,
513 &r->in.logon.password->ntpassword);
518 nt_status = make_auth_context_fixed(pipe_state,
519 &auth_context, r->in.logon.network->challenge);
520 if (!NT_STATUS_IS_OK(nt_status)) {
524 nt_status = make_user_info_netlogon_network(&user_info,
525 r->in.logon.network->identity_info.account_name.string,
526 r->in.logon.network->identity_info.domain_name.string,
527 r->in.logon.network->identity_info.workstation.string,
528 r->in.logon.network->lm.data, r->in.logon.network->lm.length,
529 r->in.logon.network->nt.data, r->in.logon.network->nt.length);
532 free_auth_context(&auth_context);
533 return NT_STATUS_INVALID_PARAMETER;
536 if (!NT_STATUS_IS_OK(nt_status)) {
540 nt_status = auth_context->check_ntlm_password(auth_context,
544 if (!NT_STATUS_IS_OK(nt_status)) {
545 free_auth_context(&auth_context);
548 free_auth_context(&auth_context);
550 sam = talloc_p(mem_ctx, struct netr_SamBaseInfo);
554 sam->last_logon = server_info->last_logon;
555 sam->last_logoff = server_info->last_logoff;
556 sam->acct_expiry = server_info->acct_expiry;
557 sam->last_password_change = server_info->last_password_change;
558 sam->allow_password_change = server_info->allow_password_change;
559 sam->force_password_change = server_info->force_password_change;
561 sam->account_name.string = talloc_strdup(mem_ctx, server_info->account_name);
562 sam->full_name.string = talloc_strdup(mem_ctx, server_info->full_name);
563 sam->logon_script.string = talloc_strdup(mem_ctx, server_info->logon_script);
564 sam->profile_path.string = talloc_strdup(mem_ctx, server_info->profile_path);
565 sam->home_directory.string = talloc_strdup(mem_ctx, server_info->home_directory);
566 sam->home_drive.string = talloc_strdup(mem_ctx, server_info->home_drive);
568 sam->logon_count = server_info->logon_count;
569 sam->bad_password_count = sam->bad_password_count;
570 sam->rid = server_info->user_sid->sub_auths[server_info->user_sid->num_auths-1];
571 sam->primary_gid = server_info->primary_group_sid->sub_auths[server_info->primary_group_sid->num_auths-1];
572 sam->group_count = 0;
573 sam->groupids = NULL;
574 sam->user_flags = 0; /* TODO: w2k3 uses 0x120 - what is this? */
575 sam->acct_flags = server_info->acct_flags;
576 sam->logon_server.string = lp_netbios_name();
578 sam->domain.string = talloc_strdup(mem_ctx, server_info->domain);
580 sam->domain_sid = dom_sid_dup(mem_ctx, server_info->user_sid);
581 sam->domain_sid->num_auths--;
583 if (server_info->user_session_key.length == sizeof(sam->key.key)) {
584 memcpy(sam->key.key, server_info->user_session_key.data, sizeof(sam->key.key));
586 ZERO_STRUCT(sam->key.key);
589 /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
590 /* It appears that level 6 is not individually encrypted */
591 if ((r->in.validation_level != 6)
592 && memcmp(sam->key.key, zeros,
593 sizeof(sam->key.key)) != 0) {
594 creds_arcfour_crypt(pipe_state->creds,
596 sizeof(sam->key.key));
599 if (server_info->lm_session_key.length == sizeof(sam->LMSessKey.key)) {
600 memcpy(sam->LMSessKey.key, server_info->lm_session_key.data,
601 sizeof(sam->LMSessKey.key));
603 ZERO_STRUCT(sam->LMSessKey.key);
606 /* Don't crypt an all-zero key, it would give away the NETLOGON pipe session key */
607 /* It appears that level 6 is not individually encrypted */
608 if ((r->in.validation_level != 6)
609 && memcmp(sam->LMSessKey.key, zeros,
610 sizeof(sam->LMSessKey.key)) != 0) {
611 creds_arcfour_crypt(pipe_state->creds,
613 sizeof(sam->LMSessKey.key));
616 switch (r->in.validation_level) {
618 sam2 = talloc_p(mem_ctx, struct netr_SamInfo2);
621 r->out.validation.sam2 = sam2;
625 sam3 = talloc_p(mem_ctx, struct netr_SamInfo3);
628 r->out.validation.sam3 = sam3;
632 sam6 = talloc_p(mem_ctx, struct netr_SamInfo6);
635 sam6->forest.string = lp_realm();
636 sam6->principle.string = talloc_asprintf(mem_ctx, "%s@%s",
637 sam->account_name.string, sam6->forest.string);
638 r->out.validation.sam6 = sam6;
645 r->out.authoritative = 1;
653 static NTSTATUS netr_LogonSamLogon(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
654 struct netr_LogonSamLogon *r)
656 struct netr_LogonSamLogonWithFlags r2;
661 r2.in.server_name = r->in.server_name;
662 r2.in.workstation = r->in.workstation;
663 r2.in.credential = r->in.credential;
664 r2.in.return_authenticator = r->in.return_authenticator;
665 r2.in.logon_level = r->in.logon_level;
666 r2.in.logon = r->in.logon;
667 r2.in.validation_level = r->in.validation_level;
670 status = netr_LogonSamLogonWithFlags(dce_call, mem_ctx, &r2);
672 r->out.return_authenticator = r2.out.return_authenticator;
673 r->out.validation = r2.out.validation;
674 r->out.authoritative = r2.out.authoritative;
683 static NTSTATUS netr_LogonSamLogoff(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
684 struct netr_LogonSamLogoff *r)
686 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
694 static NTSTATUS netr_DatabaseDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
695 struct netr_DatabaseDeltas *r)
697 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
704 static NTSTATUS netr_DatabaseSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
705 struct netr_DatabaseSync *r)
707 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
714 static NTSTATUS netr_AccountDeltas(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
715 struct netr_AccountDeltas *r)
717 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
724 static NTSTATUS netr_AccountSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
725 struct netr_AccountSync *r)
727 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
734 static NTSTATUS netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
735 struct netr_GetDcName *r)
737 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
744 static WERROR netr_LogonControl(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
745 struct netr_LogonControl *r)
747 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
754 static WERROR netr_GetAnyDCName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
755 struct netr_GetAnyDCName *r)
757 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
764 static WERROR netr_LogonControl2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
765 struct netr_LogonControl2 *r)
767 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
774 static NTSTATUS netr_DatabaseSync2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
775 struct netr_DatabaseSync2 *r)
777 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
784 static NTSTATUS netr_DatabaseRedo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
785 struct netr_DatabaseRedo *r)
787 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
794 static WERROR netr_LogonControl2Ex(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
795 struct netr_LogonControl2Ex *r)
797 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
802 netr_NETRENUMERATETRUSTEDDOMAINS
804 static WERROR netr_NETRENUMERATETRUSTEDDOMAINS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
805 struct netr_NETRENUMERATETRUSTEDDOMAINS *r)
807 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
814 static WERROR netr_DSRGETDCNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
815 struct netr_DSRGETDCNAME *r)
817 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
822 netr_NETRLOGONDUMMYROUTINE1
824 static WERROR netr_NETRLOGONDUMMYROUTINE1(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
825 struct netr_NETRLOGONDUMMYROUTINE1 *r)
827 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
832 netr_NETRLOGONSETSERVICEBITS
834 static WERROR netr_NETRLOGONSETSERVICEBITS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
835 struct netr_NETRLOGONSETSERVICEBITS *r)
837 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
842 netr_NETRLOGONGETTRUSTRID
844 static WERROR netr_NETRLOGONGETTRUSTRID(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
845 struct netr_NETRLOGONGETTRUSTRID *r)
847 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
852 netr_NETRLOGONCOMPUTESERVERDIGEST
854 static WERROR netr_NETRLOGONCOMPUTESERVERDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
855 struct netr_NETRLOGONCOMPUTESERVERDIGEST *r)
857 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
862 netr_NETRLOGONCOMPUTECLIENTDIGEST
864 static WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
865 struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r)
867 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
874 static WERROR netr_DSRGETDCNAMEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
875 struct netr_DSRGETDCNAMEX *r)
877 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
884 static WERROR netr_DSRGETSITENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
885 struct netr_DSRGETSITENAME *r)
887 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
892 fill in a netr_DomainTrustInfo from a ldb search result
894 static NTSTATUS fill_domain_trust_info(TALLOC_CTX *mem_ctx, struct ldb_message *res,
895 struct netr_DomainTrustInfo *info)
899 info->domainname.string = samdb_result_string(res, "flatName", NULL);
900 if (info->domainname.string == NULL) {
901 info->domainname.string = samdb_result_string(res, "name", NULL);
902 info->fulldomainname.string = samdb_result_string(res, "dnsDomain", NULL);
904 info->fulldomainname.string = samdb_result_string(res, "name", NULL);
907 /* TODO: we need proper forest support */
908 info->forest.string = info->fulldomainname.string;
910 info->guid = samdb_result_guid(res, "objectGUID");
911 info->sid = samdb_result_dom_sid(mem_ctx, res, "objectSid");
917 netr_LogonGetDomainInfo
918 this is called as part of the ADS domain logon procedure.
920 static NTSTATUS netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
921 struct netr_LogonGetDomainInfo *r)
923 struct server_pipe_state *pipe_state = dce_call->conn->private;
924 const char * const attrs[] = { "name", "dnsDomain", "objectSid",
925 "objectGUID", "flatName", NULL };
927 struct ldb_message **res1, **res2;
928 struct netr_DomainInfo1 *info1;
933 return NT_STATUS_ACCESS_DENIED;
936 if (!netr_creds_server_step_check(pipe_state,
937 r->in.credential, r->out.credential)) {
938 return NT_STATUS_ACCESS_DENIED;
941 sam_ctx = samdb_connect(mem_ctx);
942 if (sam_ctx == NULL) {
943 return NT_STATUS_INVALID_SYSTEM_SERVICE;
946 /* we need to do two searches. The first will pull our primary
947 domain and the second will pull any trusted domains. Our
948 primary domain is also a "trusted" domain, so we need to
949 put the primary domain into the lists of returned trusts as
951 ret1 = samdb_search(sam_ctx, mem_ctx, NULL, &res1, attrs, "(objectClass=domainDNS)");
953 return NT_STATUS_INTERNAL_DB_CORRUPTION;
956 ret2 = samdb_search(sam_ctx, mem_ctx, NULL, &res2, attrs, "(objectClass=trustedDomain)");
958 return NT_STATUS_INTERNAL_DB_CORRUPTION;
961 info1 = talloc_p(mem_ctx, struct netr_DomainInfo1);
963 return NT_STATUS_NO_MEMORY;
968 info1->num_trusts = ret2 + 1;
969 info1->trusts = talloc_array_p(mem_ctx, struct netr_DomainTrustInfo,
971 if (info1->trusts == NULL) {
972 return NT_STATUS_NO_MEMORY;
975 status = fill_domain_trust_info(mem_ctx, res1[0], &info1->domaininfo);
976 if (!NT_STATUS_IS_OK(status)) {
980 status = fill_domain_trust_info(mem_ctx, res1[0], &info1->trusts[0]);
981 if (!NT_STATUS_IS_OK(status)) {
985 for (i=0;i<ret2;i++) {
986 status = fill_domain_trust_info(mem_ctx, res2[i], &info1->trusts[i+1]);
987 if (!NT_STATUS_IS_OK(status)) {
992 r->out.info.info1 = info1;
999 netr_NETRSERVERPASSWORDSET2
1001 static WERROR netr_NETRSERVERPASSWORDSET2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1002 struct netr_NETRSERVERPASSWORDSET2 *r)
1004 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1009 netr_NETRSERVERPASSWORDGET
1011 static WERROR netr_NETRSERVERPASSWORDGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1012 struct netr_NETRSERVERPASSWORDGET *r)
1014 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1019 netr_NETRLOGONSENDTOSAM
1021 static WERROR netr_NETRLOGONSENDTOSAM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1022 struct netr_NETRLOGONSENDTOSAM *r)
1024 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1029 netr_DSRADDRESSTOSITENAMESW
1031 static WERROR netr_DSRADDRESSTOSITENAMESW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1032 struct netr_DSRADDRESSTOSITENAMESW *r)
1034 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1039 netr_DSRGETDCNAMEEX2
1041 static WERROR netr_DSRGETDCNAMEEX2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1042 struct netr_DSRGETDCNAMEEX2 *r)
1044 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1049 netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN
1051 static WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1052 struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r)
1054 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1059 netr_NETRENUMERATETRUSTEDDOMAINSEX
1061 static WERROR netr_NETRENUMERATETRUSTEDDOMAINSEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1062 struct netr_NETRENUMERATETRUSTEDDOMAINSEX *r)
1064 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1069 netr_DSRADDRESSTOSITENAMESEXW
1071 static WERROR netr_DSRADDRESSTOSITENAMESEXW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1072 struct netr_DSRADDRESSTOSITENAMESEXW *r)
1074 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1079 netr_DSRGETDCSITECOVERAGEW
1081 static WERROR netr_DSRGETDCSITECOVERAGEW(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1082 struct netr_DSRGETDCSITECOVERAGEW *r)
1084 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1089 netr_NETRLOGONSAMLOGONEX
1091 static WERROR netr_NETRLOGONSAMLOGONEX(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1092 struct netr_NETRLOGONSAMLOGONEX *r)
1094 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1099 netr_DsrEnumerateDomainTrusts
1101 static WERROR netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1102 struct netr_DsrEnumerateDomainTrusts *r)
1104 struct netr_DomainTrust *trusts;
1107 struct ldb_message **res;
1108 const char * const attrs[] = { "name", "dnsDomain", "objectSid", "objectGUID", NULL };
1110 ZERO_STRUCT(r->out);
1112 sam_ctx = samdb_connect(mem_ctx);
1113 if (sam_ctx == NULL) {
1114 return WERR_GENERAL_FAILURE;
1117 ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs, "(objectClass=domainDNS)");
1119 return WERR_GENERAL_FAILURE;
1126 trusts = talloc_array_p(mem_ctx, struct netr_DomainTrust, ret);
1127 if (trusts == NULL) {
1132 r->out.trusts = trusts;
1134 /* TODO: add filtering by trust_flags, and correct trust_type
1136 for (i=0;i<ret;i++) {
1137 trusts[i].netbios_name = samdb_result_string(res[i], "name", NULL);
1138 trusts[i].dns_name = samdb_result_string(res[i], "dnsDomain", NULL);
1139 trusts[i].trust_flags =
1140 NETR_TRUST_FLAG_TREEROOT |
1141 NETR_TRUST_FLAG_IN_FOREST |
1142 NETR_TRUST_FLAG_PRIMARY;
1143 trusts[i].parent_index = 0;
1144 trusts[i].trust_type = 2;
1145 trusts[i].trust_attributes = 0;
1146 trusts[i].sid = samdb_result_dom_sid(mem_ctx, res[i], "objectSid");
1147 trusts[i].guid = samdb_result_guid(res[i], "objectGUID");
1156 netr_DSRDEREGISTERDNSHOSTRECORDS
1158 static WERROR netr_DSRDEREGISTERDNSHOSTRECORDS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1159 struct netr_DSRDEREGISTERDNSHOSTRECORDS *r)
1161 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1166 netr_NETRSERVERTRUSTPASSWORDSGET
1168 static WERROR netr_NETRSERVERTRUSTPASSWORDSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1169 struct netr_NETRSERVERTRUSTPASSWORDSGET *r)
1171 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1176 netr_DSRGETFORESTTRUSTINFORMATION
1178 static WERROR netr_DSRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1179 struct netr_DSRGETFORESTTRUSTINFORMATION *r)
1181 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1186 netr_NETRGETFORESTTRUSTINFORMATION
1188 static WERROR netr_NETRGETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1189 struct netr_NETRGETFORESTTRUSTINFORMATION *r)
1191 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1196 netr_NETRSERVERGETTRUSTINFO
1198 static WERROR netr_NETRSERVERGETTRUSTINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1199 struct netr_NETRSERVERGETTRUSTINFO *r)
1201 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1205 /* include the generated boilerplate */
1206 #include "librpc/gen_ndr/ndr_netlogon_s.c"