s4:auth_sam: don't allow interactive logons with UF_SMARTCARD_REQUIRED
[Samba.git] / source4 / auth / ntlm / auth_sam.c
blobb223706f884ccbc4e79f9c2eafd5ed1dc89345d0
1 /*
2 Unix SMB/CIFS implementation.
3 Password and authentication handling
4 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001-2009
5 Copyright (C) Gerald Carter 2003
6 Copyright (C) Stefan Metzmacher 2005
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 3 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, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "system/time.h"
24 #include <ldb.h>
25 #include "libcli/ldap/ldap_ndr.h"
26 #include "libcli/security/security.h"
27 #include "auth/auth.h"
28 #include "../libcli/auth/ntlm_check.h"
29 #include "auth/ntlm/auth_proto.h"
30 #include "auth/auth_sam.h"
31 #include "dsdb/samdb/samdb.h"
32 #include "dsdb/common/util.h"
33 #include "param/param.h"
34 #include "librpc/gen_ndr/ndr_irpc_c.h"
35 #include "lib/messaging/irpc.h"
36 #include "libcli/auth/libcli_auth.h"
37 #include "libds/common/roles.h"
39 NTSTATUS auth_sam_init(void);
41 extern const char *user_attrs[];
42 extern const char *domain_ref_attrs[];
44 /****************************************************************************
45 Look for the specified user in the sam, return ldb result structures
46 ****************************************************************************/
48 static NTSTATUS authsam_search_account(TALLOC_CTX *mem_ctx, struct ldb_context *sam_ctx,
49 const char *account_name,
50 struct ldb_dn *domain_dn,
51 struct ldb_message **ret_msg)
53 int ret;
55 /* pull the user attributes */
56 ret = dsdb_search_one(sam_ctx, mem_ctx, ret_msg, domain_dn, LDB_SCOPE_SUBTREE,
57 user_attrs,
58 DSDB_SEARCH_SHOW_EXTENDED_DN,
59 "(&(sAMAccountName=%s)(objectclass=user))",
60 ldb_binary_encode_string(mem_ctx, account_name));
61 if (ret == LDB_ERR_NO_SUCH_OBJECT) {
62 DEBUG(3,("sam_search_user: Couldn't find user [%s] in samdb, under %s\n",
63 account_name, ldb_dn_get_linearized(domain_dn)));
64 return NT_STATUS_NO_SUCH_USER;
66 if (ret != LDB_SUCCESS) {
67 return NT_STATUS_INTERNAL_DB_CORRUPTION;
70 return NT_STATUS_OK;
73 /****************************************************************************
74 Do a specific test for an smb password being correct, given a smb_password and
75 the lanman and NT responses.
76 ****************************************************************************/
77 static NTSTATUS authsam_password_ok(struct auth4_context *auth_context,
78 TALLOC_CTX *mem_ctx,
79 uint16_t acct_flags,
80 const struct samr_Password *lm_pwd,
81 const struct samr_Password *nt_pwd,
82 const struct auth_usersupplied_info *user_info,
83 DATA_BLOB *user_sess_key,
84 DATA_BLOB *lm_sess_key)
86 NTSTATUS status;
88 switch (user_info->password_state) {
89 case AUTH_PASSWORD_PLAIN:
91 const struct auth_usersupplied_info *user_info_temp;
92 status = encrypt_user_info(mem_ctx, auth_context,
93 AUTH_PASSWORD_HASH,
94 user_info, &user_info_temp);
95 if (!NT_STATUS_IS_OK(status)) {
96 DEBUG(1, ("Failed to convert plaintext password to password HASH: %s\n", nt_errstr(status)));
97 return status;
99 user_info = user_info_temp;
101 /*fall through*/
103 case AUTH_PASSWORD_HASH:
104 *lm_sess_key = data_blob(NULL, 0);
105 *user_sess_key = data_blob(NULL, 0);
106 status = hash_password_check(mem_ctx,
107 lpcfg_lanman_auth(auth_context->lp_ctx),
108 user_info->password.hash.lanman,
109 user_info->password.hash.nt,
110 user_info->mapped.account_name,
111 lm_pwd, nt_pwd);
112 NT_STATUS_NOT_OK_RETURN(status);
113 break;
115 case AUTH_PASSWORD_RESPONSE:
116 status = ntlm_password_check(mem_ctx,
117 lpcfg_lanman_auth(auth_context->lp_ctx),
118 lpcfg_ntlm_auth(auth_context->lp_ctx),
119 user_info->logon_parameters,
120 &auth_context->challenge.data,
121 &user_info->password.response.lanman,
122 &user_info->password.response.nt,
123 user_info->mapped.account_name,
124 user_info->client.account_name,
125 user_info->client.domain_name,
126 lm_pwd, nt_pwd,
127 user_sess_key, lm_sess_key);
128 NT_STATUS_NOT_OK_RETURN(status);
129 break;
132 return NT_STATUS_OK;
137 send a message to the drepl server telling it to initiate a
138 REPL_SECRET getncchanges extended op to fetch the users secrets
140 static void auth_sam_trigger_repl_secret(struct auth4_context *auth_context,
141 struct ldb_dn *user_dn)
143 struct dcerpc_binding_handle *irpc_handle;
144 struct drepl_trigger_repl_secret r;
145 struct tevent_req *req;
146 TALLOC_CTX *tmp_ctx;
148 tmp_ctx = talloc_new(auth_context);
149 if (tmp_ctx == NULL) {
150 return;
153 irpc_handle = irpc_binding_handle_by_name(tmp_ctx, auth_context->msg_ctx,
154 "dreplsrv",
155 &ndr_table_irpc);
156 if (irpc_handle == NULL) {
157 DEBUG(1,(__location__ ": Unable to get binding handle for dreplsrv\n"));
158 TALLOC_FREE(tmp_ctx);
159 return;
162 r.in.user_dn = ldb_dn_get_linearized(user_dn);
165 * This seem to rely on the current IRPC implementation,
166 * which delivers the message in the _send function.
168 * TODO: we need a ONE_WAY IRPC handle and register
169 * a callback and wait for it to be triggered!
171 req = dcerpc_drepl_trigger_repl_secret_r_send(tmp_ctx,
172 auth_context->event_ctx,
173 irpc_handle,
174 &r);
176 /* we aren't interested in a reply */
177 talloc_free(req);
178 TALLOC_FREE(tmp_ctx);
183 * Check that a password is OK, and update badPwdCount if required.
186 static NTSTATUS authsam_password_check_and_record(struct auth4_context *auth_context,
187 TALLOC_CTX *mem_ctx,
188 struct ldb_dn *domain_dn,
189 struct ldb_message *msg,
190 uint16_t acct_flags,
191 const struct auth_usersupplied_info *user_info,
192 DATA_BLOB *user_sess_key,
193 DATA_BLOB *lm_sess_key)
195 NTSTATUS nt_status;
196 NTSTATUS auth_status;
197 TALLOC_CTX *tmp_ctx;
198 int i, ret;
199 int history_len = 0;
200 struct ldb_context *sam_ctx = auth_context->sam_ctx;
201 const char * const attrs[] = { "pwdHistoryLength", NULL };
202 struct ldb_message *dom_msg;
203 struct samr_Password *lm_pwd;
204 struct samr_Password *nt_pwd;
206 tmp_ctx = talloc_new(mem_ctx);
207 if (tmp_ctx == NULL) {
208 return NT_STATUS_NO_MEMORY;
212 * This call does more than what it appears to do, it also
213 * checks for the account lockout.
215 * It is done here so that all parts of Samba that read the
216 * password refuse to even operate on it if the account is
217 * locked out, to avoid mistakes like CVE-2013-4496.
219 nt_status = samdb_result_passwords(tmp_ctx, auth_context->lp_ctx,
220 msg, &lm_pwd, &nt_pwd);
221 if (!NT_STATUS_IS_OK(nt_status)) {
222 TALLOC_FREE(tmp_ctx);
223 return nt_status;
226 if (lm_pwd == NULL && nt_pwd == NULL) {
227 bool am_rodc;
228 if (samdb_rodc(auth_context->sam_ctx, &am_rodc) == LDB_SUCCESS && am_rodc) {
230 * we don't have passwords for this
231 * account. We are an RODC, and this account
232 * may be one for which we either are denied
233 * REPL_SECRET replication or we haven't yet
234 * done the replication. We return
235 * NT_STATUS_NOT_IMPLEMENTED which tells the
236 * auth code to try the next authentication
237 * mechanism. We also send a message to our
238 * drepl server to tell it to try and
239 * replicate the secrets for this account.
241 auth_sam_trigger_repl_secret(auth_context, msg->dn);
242 TALLOC_FREE(tmp_ctx);
243 return NT_STATUS_NOT_IMPLEMENTED;
247 auth_status = authsam_password_ok(auth_context, tmp_ctx,
248 acct_flags,
249 lm_pwd, nt_pwd,
250 user_info,
251 user_sess_key, lm_sess_key);
252 if (NT_STATUS_IS_OK(auth_status)) {
253 if (user_sess_key->data) {
254 talloc_steal(mem_ctx, user_sess_key->data);
256 if (lm_sess_key->data) {
257 talloc_steal(mem_ctx, lm_sess_key->data);
259 TALLOC_FREE(tmp_ctx);
260 return NT_STATUS_OK;
262 *user_sess_key = data_blob_null;
263 *lm_sess_key = data_blob_null;
265 if (!NT_STATUS_EQUAL(auth_status, NT_STATUS_WRONG_PASSWORD)) {
266 TALLOC_FREE(tmp_ctx);
267 return auth_status;
271 * We only continue if this was a wrong password
272 * and we'll always return NT_STATUS_WRONG_PASSWORD
273 * no matter what error happens.
276 /* pull the domain password property attributes */
277 ret = dsdb_search_one(sam_ctx, tmp_ctx, &dom_msg, domain_dn, LDB_SCOPE_BASE,
278 attrs, 0, "objectClass=domain");
279 if (ret == LDB_SUCCESS) {
280 history_len = ldb_msg_find_attr_as_uint(dom_msg, "pwdHistoryLength", 0);
281 } else if (ret == LDB_ERR_NO_SUCH_OBJECT) {
282 DEBUG(3,("Couldn't find domain %s: %s!\n",
283 ldb_dn_get_linearized(domain_dn),
284 ldb_errstring(sam_ctx)));
285 } else {
286 DEBUG(3,("error finding domain %s: %s!\n",
287 ldb_dn_get_linearized(domain_dn),
288 ldb_errstring(sam_ctx)));
291 for (i = 1; i < MIN(history_len, 3); i++) {
292 static const struct samr_Password zero_hash;
293 struct samr_Password zero_string_hash;
294 struct samr_Password zero_string_des_hash;
295 struct samr_Password *nt_history_pwd = NULL;
296 struct samr_Password *lm_history_pwd = NULL;
297 NTTIME pwdLastSet;
298 struct timeval tv_now;
299 NTTIME now;
300 int allowed_period_mins;
301 NTTIME allowed_period;
303 nt_status = samdb_result_passwords_from_history(tmp_ctx,
304 auth_context->lp_ctx,
305 msg, i,
306 &lm_history_pwd,
307 &nt_history_pwd);
308 if (!NT_STATUS_IS_OK(nt_status)) {
310 * If we don't find element 'i' we won't find
311 * 'i+1' ...
313 break;
317 * We choose to avoid any issues
318 * around different LM and NT history
319 * lengths by only checking the NT
320 * history
322 if (nt_history_pwd == NULL) {
324 * If we don't find element 'i' we won't find
325 * 'i+1' ...
327 break;
330 /* Skip over all-zero hashes in the history */
331 if (memcmp(nt_history_pwd->hash, zero_hash.hash,
332 sizeof(zero_hash.hash)) == 0) {
333 continue;
337 * This looks odd, but the password_hash module writes this in if
338 * (somehow) we didn't have an old NT hash
341 E_md4hash("", zero_string_hash.hash);
342 if (memcmp(nt_history_pwd->hash, zero_string_hash.hash, 16) == 0) {
343 continue;
346 E_deshash("", zero_string_des_hash.hash);
347 if (!lm_history_pwd || memcmp(lm_history_pwd->hash, zero_string_des_hash.hash, 16) == 0) {
348 lm_history_pwd = NULL;
351 auth_status = authsam_password_ok(auth_context, tmp_ctx,
352 acct_flags,
353 lm_history_pwd,
354 nt_history_pwd,
355 user_info,
356 user_sess_key,
357 lm_sess_key);
358 if (!NT_STATUS_IS_OK(auth_status)) {
360 * If this was not a correct password, try the next
361 * one from the history
363 *user_sess_key = data_blob_null;
364 *lm_sess_key = data_blob_null;
365 continue;
368 if (i != 1) {
370 * The authentication was OK, but not against
371 * the previous password, which is stored at index 1.
373 * We just return the original wrong password.
374 * This skips the update of the bad pwd count,
375 * because this is almost certainly user error
376 * (or automatic login on a computer using a cached
377 * password from before the password change),
378 * not an attack.
380 TALLOC_FREE(tmp_ctx);
381 return NT_STATUS_WRONG_PASSWORD;
384 if (user_info->password_state != AUTH_PASSWORD_RESPONSE) {
386 * The authentication was OK against the previous password,
387 * but it's not a NTLM network authentication.
389 * We just return the original wrong password.
390 * This skips the update of the bad pwd count,
391 * because this is almost certainly user error
392 * (or automatic login on a computer using a cached
393 * password from before the password change),
394 * not an attack.
396 TALLOC_FREE(tmp_ctx);
397 return NT_STATUS_WRONG_PASSWORD;
401 * If the password was OK, it's a NTLM network authentication
402 * and it was the previous password.
404 * Now we see if it is within the grace period,
405 * so that we don't break cached sessions on other computers
406 * before the user can lock and unlock their other screens
407 * (resetting their cached password).
409 * See http://support.microsoft.com/kb/906305
410 * OldPasswordAllowedPeriod ("old password allowed period")
411 * is specified in minutes. The default is 60.
413 allowed_period_mins = lpcfg_old_password_allowed_period(auth_context->lp_ctx);
415 * NTTIME uses 100ns units
417 allowed_period = allowed_period_mins * 60 * 1000*1000*10;
418 pwdLastSet = samdb_result_nttime(msg, "pwdLastSet", 0);
419 tv_now = timeval_current();
420 now = timeval_to_nttime(&tv_now);
422 if (now < pwdLastSet) {
424 * time jump?
426 * We just return the original wrong password.
427 * This skips the update of the bad pwd count,
428 * because this is almost certainly user error
429 * (or automatic login on a computer using a cached
430 * password from before the password change),
431 * not an attack.
433 TALLOC_FREE(tmp_ctx);
434 return NT_STATUS_WRONG_PASSWORD;
437 if ((now - pwdLastSet) >= allowed_period) {
439 * The allowed period is over.
441 * We just return the original wrong password.
442 * This skips the update of the bad pwd count,
443 * because this is almost certainly user error
444 * (or automatic login on a computer using a cached
445 * password from before the password change),
446 * not an attack.
448 TALLOC_FREE(tmp_ctx);
449 return NT_STATUS_WRONG_PASSWORD;
453 * We finally allow the authentication with the
454 * previous password within the allowed period.
456 if (user_sess_key->data) {
457 talloc_steal(mem_ctx, user_sess_key->data);
459 if (lm_sess_key->data) {
460 talloc_steal(mem_ctx, lm_sess_key->data);
463 TALLOC_FREE(tmp_ctx);
464 return auth_status;
468 * If we are not in the allowed period or match an old password,
469 * we didn't return early. Now update the badPwdCount et al.
471 nt_status = authsam_update_bad_pwd_count(auth_context->sam_ctx,
472 msg, domain_dn);
473 if (!NT_STATUS_IS_OK(nt_status)) {
475 * We need to return the original
476 * NT_STATUS_WRONG_PASSWORD error, so there isn't
477 * anything more we can do than write something into
478 * the log
480 DEBUG(0, ("Failed to note bad password for user [%s]: %s\n",
481 user_info->mapped.account_name,
482 nt_errstr(nt_status)));
485 TALLOC_FREE(tmp_ctx);
486 return NT_STATUS_WRONG_PASSWORD;
489 static NTSTATUS authsam_authenticate(struct auth4_context *auth_context,
490 TALLOC_CTX *mem_ctx, struct ldb_context *sam_ctx,
491 struct ldb_dn *domain_dn,
492 struct ldb_message *msg,
493 const struct auth_usersupplied_info *user_info,
494 DATA_BLOB *user_sess_key, DATA_BLOB *lm_sess_key)
496 NTSTATUS nt_status;
497 bool interactive = (user_info->password_state == AUTH_PASSWORD_HASH);
498 uint32_t acct_flags = samdb_result_acct_flags(msg, NULL);
499 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
500 if (!tmp_ctx) {
501 return NT_STATUS_NO_MEMORY;
504 /* You can only do an interactive login to normal accounts */
505 if (user_info->flags & USER_INFO_INTERACTIVE_LOGON) {
506 if (!(acct_flags & ACB_NORMAL)) {
507 TALLOC_FREE(tmp_ctx);
508 return NT_STATUS_NO_SUCH_USER;
510 if (acct_flags & ACB_SMARTCARD_REQUIRED) {
511 if (acct_flags & ACB_DISABLED) {
512 DEBUG(2,("authsam_authenticate: Account for user '%s' "
513 "was disabled.\n",
514 user_info->mapped.account_name));
515 TALLOC_FREE(tmp_ctx);
516 return NT_STATUS_ACCOUNT_DISABLED;
518 DEBUG(2,("authsam_authenticate: Account for user '%s' "
519 "requires interactive smartcard logon.\n",
520 user_info->mapped.account_name));
521 TALLOC_FREE(tmp_ctx);
522 return NT_STATUS_SMARTCARD_LOGON_REQUIRED;
526 nt_status = authsam_password_check_and_record(auth_context, tmp_ctx,
527 domain_dn, msg, acct_flags,
528 user_info,
529 user_sess_key, lm_sess_key);
530 if (!NT_STATUS_IS_OK(nt_status)) {
531 TALLOC_FREE(tmp_ctx);
532 return nt_status;
535 nt_status = authsam_account_ok(tmp_ctx, auth_context->sam_ctx,
536 user_info->logon_parameters,
537 domain_dn,
538 msg,
539 user_info->workstation_name,
540 user_info->mapped.account_name,
541 false, false);
542 if (!NT_STATUS_IS_OK(nt_status)) {
543 TALLOC_FREE(tmp_ctx);
544 return nt_status;
547 nt_status = authsam_logon_success_accounting(auth_context->sam_ctx,
548 msg, domain_dn,
549 interactive);
550 if (!NT_STATUS_IS_OK(nt_status)) {
551 TALLOC_FREE(tmp_ctx);
552 return nt_status;
555 if (user_sess_key && user_sess_key->data) {
556 talloc_steal(mem_ctx, user_sess_key->data);
558 if (lm_sess_key && lm_sess_key->data) {
559 talloc_steal(mem_ctx, lm_sess_key->data);
562 TALLOC_FREE(tmp_ctx);
563 return nt_status;
568 static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx,
569 TALLOC_CTX *mem_ctx,
570 const struct auth_usersupplied_info *user_info,
571 struct auth_user_info_dc **user_info_dc)
573 NTSTATUS nt_status;
574 const char *account_name = user_info->mapped.account_name;
575 struct ldb_message *msg;
576 struct ldb_dn *domain_dn;
577 DATA_BLOB user_sess_key, lm_sess_key;
578 TALLOC_CTX *tmp_ctx;
580 if (ctx->auth_ctx->sam_ctx == NULL) {
581 DEBUG(0, ("No SAM available, cannot log in users\n"));
582 return NT_STATUS_INVALID_SYSTEM_SERVICE;
585 if (!account_name || !*account_name) {
586 /* 'not for me' */
587 return NT_STATUS_NOT_IMPLEMENTED;
590 tmp_ctx = talloc_new(mem_ctx);
591 if (!tmp_ctx) {
592 return NT_STATUS_NO_MEMORY;
595 domain_dn = ldb_get_default_basedn(ctx->auth_ctx->sam_ctx);
596 if (domain_dn == NULL) {
597 talloc_free(tmp_ctx);
598 return NT_STATUS_NO_SUCH_DOMAIN;
601 nt_status = authsam_search_account(tmp_ctx, ctx->auth_ctx->sam_ctx, account_name, domain_dn, &msg);
602 if (!NT_STATUS_IS_OK(nt_status)) {
603 talloc_free(tmp_ctx);
604 return nt_status;
607 nt_status = authsam_authenticate(ctx->auth_ctx, tmp_ctx, ctx->auth_ctx->sam_ctx, domain_dn, msg, user_info,
608 &user_sess_key, &lm_sess_key);
609 if (!NT_STATUS_IS_OK(nt_status)) {
610 talloc_free(tmp_ctx);
611 return nt_status;
614 nt_status = authsam_make_user_info_dc(tmp_ctx, ctx->auth_ctx->sam_ctx, lpcfg_netbios_name(ctx->auth_ctx->lp_ctx),
615 lpcfg_sam_name(ctx->auth_ctx->lp_ctx),
616 domain_dn,
617 msg,
618 user_sess_key, lm_sess_key,
619 user_info_dc);
620 if (!NT_STATUS_IS_OK(nt_status)) {
621 talloc_free(tmp_ctx);
622 return nt_status;
625 talloc_steal(mem_ctx, *user_info_dc);
626 talloc_free(tmp_ctx);
628 return NT_STATUS_OK;
631 static NTSTATUS authsam_ignoredomain_want_check(struct auth_method_context *ctx,
632 TALLOC_CTX *mem_ctx,
633 const struct auth_usersupplied_info *user_info)
635 if (!user_info->mapped.account_name || !*user_info->mapped.account_name) {
636 return NT_STATUS_NOT_IMPLEMENTED;
639 return NT_STATUS_OK;
642 /****************************************************************************
643 Check SAM security (above) but with a few extra checks.
644 ****************************************************************************/
645 static NTSTATUS authsam_want_check(struct auth_method_context *ctx,
646 TALLOC_CTX *mem_ctx,
647 const struct auth_usersupplied_info *user_info)
649 bool is_local_name, is_my_domain;
651 if (!user_info->mapped.account_name || !*user_info->mapped.account_name) {
652 return NT_STATUS_NOT_IMPLEMENTED;
655 is_local_name = lpcfg_is_myname(ctx->auth_ctx->lp_ctx,
656 user_info->mapped.domain_name);
657 is_my_domain = lpcfg_is_mydomain(ctx->auth_ctx->lp_ctx,
658 user_info->mapped.domain_name);
660 /* check whether or not we service this domain/workgroup name */
661 switch (lpcfg_server_role(ctx->auth_ctx->lp_ctx)) {
662 case ROLE_STANDALONE:
663 return NT_STATUS_OK;
665 case ROLE_DOMAIN_MEMBER:
666 if (!is_local_name) {
667 DEBUG(6,("authsam_check_password: %s is not one of my local names (DOMAIN_MEMBER)\n",
668 user_info->mapped.domain_name));
669 return NT_STATUS_NOT_IMPLEMENTED;
671 return NT_STATUS_OK;
673 case ROLE_ACTIVE_DIRECTORY_DC:
674 if (!is_local_name && !is_my_domain) {
675 DEBUG(6,("authsam_check_password: %s is not one of my local names or domain name (DC)\n",
676 user_info->mapped.domain_name));
677 return NT_STATUS_NOT_IMPLEMENTED;
679 return NT_STATUS_OK;
682 DEBUG(6,("authsam_check_password: lpcfg_server_role() has an undefined value\n"));
683 return NT_STATUS_NOT_IMPLEMENTED;
687 /* Wrapper for the auth subsystem pointer */
688 static NTSTATUS authsam_get_user_info_dc_principal_wrapper(TALLOC_CTX *mem_ctx,
689 struct auth4_context *auth_context,
690 const char *principal,
691 struct ldb_dn *user_dn,
692 struct auth_user_info_dc **user_info_dc)
694 return authsam_get_user_info_dc_principal(mem_ctx, auth_context->lp_ctx, auth_context->sam_ctx,
695 principal, user_dn, user_info_dc);
697 static const struct auth_operations sam_ignoredomain_ops = {
698 .name = "sam_ignoredomain",
699 .want_check = authsam_ignoredomain_want_check,
700 .check_password = authsam_check_password_internals,
701 .get_user_info_dc_principal = authsam_get_user_info_dc_principal_wrapper,
702 .flags = AUTH_METHOD_LOCAL_SAM
705 static const struct auth_operations sam_ops = {
706 .name = "sam",
707 .want_check = authsam_want_check,
708 .check_password = authsam_check_password_internals,
709 .get_user_info_dc_principal = authsam_get_user_info_dc_principal_wrapper,
710 .flags = AUTH_METHOD_LOCAL_SAM
713 _PUBLIC_ NTSTATUS auth4_sam_init(void);
714 _PUBLIC_ NTSTATUS auth4_sam_init(void)
716 NTSTATUS ret;
718 ret = auth_register(&sam_ops);
719 if (!NT_STATUS_IS_OK(ret)) {
720 DEBUG(0,("Failed to register 'sam' auth backend!\n"));
721 return ret;
724 ret = auth_register(&sam_ignoredomain_ops);
725 if (!NT_STATUS_IS_OK(ret)) {
726 DEBUG(0,("Failed to register 'sam_ignoredomain' auth backend!\n"));
727 return ret;
730 return ret;