Changes all over the shop, but all towards:
[tprouty/samba.git] / source / auth / auth_sam.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Password and authentication handling
4    Copyright (C) Andrew Tridgell              1992-2000
5    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
6    Copyright (C) Andrew Bartlett              2001
7    Copyright (C) Gerald Carter                2003
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
26 #undef DBGC_CLASS
27 #define DBGC_CLASS DBGC_AUTH
28
29 /****************************************************************************
30  Core of smb password checking routine.
31 ****************************************************************************/
32
33 static BOOL smb_pwd_check_ntlmv1(const DATA_BLOB *nt_response,
34                                  const uchar *part_passwd,
35                                  const DATA_BLOB *sec_blob,
36                                  DATA_BLOB *user_sess_key)
37 {
38         /* Finish the encryption of part_passwd. */
39         uchar p24[24];
40         
41         if (part_passwd == NULL) {
42                 DEBUG(10,("No password set - DISALLOWING access\n"));
43                 /* No password set - always false ! */
44                 return False;
45         }
46         
47         if (sec_blob->length != 8) {
48                 DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect challenge size (%lu)\n", (unsigned long)sec_blob->length));
49                 return False;
50         }
51         
52         if (nt_response->length != 24) {
53                 DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect password length (%lu)\n", (unsigned long)nt_response->length));
54                 return False;
55         }
56
57         SMBOWFencrypt(part_passwd, sec_blob->data, p24);
58         if (user_sess_key != NULL) {
59                 *user_sess_key = data_blob(NULL, 16);
60                 SMBsesskeygen_ntv1(part_passwd, NULL, user_sess_key->data);
61         }
62         
63         
64         
65 #if DEBUG_PASSWORD
66         DEBUG(100,("Part password (P16) was |\n"));
67         dump_data(100, part_passwd, 16);
68         DEBUGADD(100,("Password from client was |\n"));
69         dump_data(100, nt_response->data, nt_response->length);
70         DEBUGADD(100,("Given challenge was |\n"));
71         dump_data(100, sec_blob->data, sec_blob->length);
72         DEBUGADD(100,("Value from encryption was |\n"));
73         dump_data(100, p24, 24);
74 #endif
75   return (memcmp(p24, nt_response->data, 24) == 0);
76 }
77
78 /****************************************************************************
79  Core of smb password checking routine. (NTLMv2, LMv2)
80  Note:  The same code works with both NTLMv2 and LMv2.
81 ****************************************************************************/
82
83 static BOOL smb_pwd_check_ntlmv2(const DATA_BLOB *ntv2_response,
84                                  const uchar *part_passwd,
85                                  const DATA_BLOB *sec_blob,
86                                  const char *user, const char *domain,
87                                  DATA_BLOB *user_sess_key)
88 {
89         /* Finish the encryption of part_passwd. */
90         uchar kr[16];
91         uchar value_from_encryption[16];
92         uchar client_response[16];
93         DATA_BLOB client_key_data;
94
95         if (part_passwd == NULL) {
96                 DEBUG(10,("No password set - DISALLOWING access\n"));
97                 /* No password set - always False */
98                 return False;
99         }
100
101         if (ntv2_response->length < 24) {
102                 /* We MUST have more than 16 bytes, or the stuff below will go
103                    crazy.  No known implementation sends less than the 24 bytes
104                    for LMv2, let alone NTLMv2. */
105                 DEBUG(0, ("smb_pwd_check_ntlmv2: incorrect password length (%lu)\n", 
106                           (unsigned long)ntv2_response->length));
107                 return False;
108         }
109
110         client_key_data = data_blob(ntv2_response->data+16, ntv2_response->length-16);
111         /* 
112            todo:  should we be checking this for anything?  We can't for LMv2, 
113            but for NTLMv2 it is meant to contain the current time etc.
114         */
115
116         memcpy(client_response, ntv2_response->data, sizeof(client_response));
117
118         if (!ntv2_owf_gen(part_passwd, user, domain, kr)) {
119                 return False;
120         }
121
122         SMBOWFencrypt_ntv2(kr, sec_blob, &client_key_data, value_from_encryption);
123         if (user_sess_key != NULL) {
124                 *user_sess_key = data_blob(NULL, 16);
125                 SMBsesskeygen_ntv2(kr, value_from_encryption, user_sess_key->data);
126         }
127
128 #if DEBUG_PASSWORD
129         DEBUG(100,("Part password (P16) was |\n"));
130         dump_data(100, part_passwd, 16);
131         DEBUGADD(100,("Password from client was |\n"));
132         dump_data(100, ntv2_response->data, ntv2_response->length);
133         DEBUGADD(100,("Variable data from client was |\n"));
134         dump_data(100, client_key_data.data, client_key_data.length);
135         DEBUGADD(100,("Given challenge was |\n"));
136         dump_data(100, sec_blob->data, sec_blob->length);
137         DEBUGADD(100,("Value from encryption was |\n"));
138         dump_data(100, value_from_encryption, 16);
139 #endif
140         data_blob_clear_free(&client_key_data);
141         return (memcmp(value_from_encryption, client_response, 16) == 0);
142 }
143
144 /****************************************************************************
145  Do a specific test for an smb password being correct, given a smb_password and
146  the lanman and NT responses.
147 ****************************************************************************/
148
149 static NTSTATUS sam_password_ok(const struct auth_context *auth_context,
150                                 TALLOC_CTX *mem_ctx,
151                                 SAM_ACCOUNT *sampass, 
152                                 const auth_usersupplied_info *user_info, 
153                                 DATA_BLOB *user_sess_key, 
154                                 DATA_BLOB *lm_sess_key)
155 {
156         uint16 acct_ctrl;
157         const uint8 *nt_pw, *lm_pw;
158         uint32 auth_flags;
159
160         acct_ctrl = pdb_get_acct_ctrl(sampass);
161         if (acct_ctrl & ACB_PWNOTREQ) {
162                 if (lp_null_passwords()) {
163                         DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", pdb_get_username(sampass)));
164                         return(NT_STATUS_OK);
165                 } else {
166                         DEBUG(3,("Account for user '%s' has no password and null passwords are NOT allowed.\n", pdb_get_username(sampass)));
167                         return(NT_STATUS_LOGON_FAILURE);
168                 }               
169         }
170
171         auth_flags = user_info->auth_flags;
172
173         if (IS_SAM_DEFAULT(sampass, PDB_NTPASSWD)) {
174                 DEBUG(3,("sam_password_ok: NO NT password stored for user %s.\n", 
175                          pdb_get_username(sampass)));
176                 /* No return, we want to check the LM hash below in this case */
177                 auth_flags &= (~(AUTH_FLAG_NTLMv2_RESP |  AUTH_FLAG_NTLM_RESP));
178         } else {
179                 /* Check for cleartext netlogon. Used by Exchange 5.5. */
180                 unsigned char zeros[8];
181
182                 memset(zeros,'\0',sizeof(zeros));
183                 if (auth_context->challenge.length == sizeof(zeros) && 
184                                 (memcmp(auth_context->challenge.data, zeros, auth_context->challenge.length) == 0 ) &&
185                                 user_info->nt_resp.length) {
186                         if ((nt_pw = pdb_get_nt_passwd(sampass)) != NULL) {
187                                 unsigned char pwhash[16];
188                                 mdfour(pwhash, user_info->nt_resp.data, user_info->nt_resp.length);
189                                 if (memcmp(pwhash, nt_pw, sizeof(pwhash)) == 0) {
190                                         return NT_STATUS_OK;
191                                 }
192                         }
193                 }
194         }
195         
196         if (auth_flags & AUTH_FLAG_NTLMv2_RESP) {
197                 nt_pw = pdb_get_nt_passwd(sampass);
198                 /* We have the NT MD4 hash challenge available - see if we can
199                    use it (ie. does it exist in the smbpasswd file).
200                 */
201                 DEBUG(4,("sam_password_ok: Checking NTLMv2 password with domain [%s]\n", user_info->client_domain.str));
202                 if (smb_pwd_check_ntlmv2( &user_info->nt_resp, 
203                                           nt_pw, &auth_context->challenge, 
204                                           user_info->smb_name.str, 
205                                           user_info->client_domain.str,
206                                           user_sess_key)) {
207                         return NT_STATUS_OK;
208                 }
209
210                 DEBUG(4,("sam_password_ok: Checking NTLMv2 password without a domain\n"));
211                 if (smb_pwd_check_ntlmv2( &user_info->nt_resp, 
212                                           nt_pw, &auth_context->challenge, 
213                                           user_info->smb_name.str, 
214                                           "",
215                                           user_sess_key)) {
216                         return NT_STATUS_OK;
217                 } else {
218                         DEBUG(3,("sam_password_ok: NTLMv2 password check failed\n"));
219                         return NT_STATUS_WRONG_PASSWORD;
220                 }
221         } else if (auth_flags & AUTH_FLAG_NTLM_RESP) {
222                 if (lp_ntlm_auth()) {           
223                         nt_pw = pdb_get_nt_passwd(sampass);
224                         /* We have the NT MD4 hash challenge available - see if we can
225                            use it (ie. does it exist in the smbpasswd file).
226                         */
227                         DEBUG(4,("sam_password_ok: Checking NT MD4 password\n"));
228                         if (smb_pwd_check_ntlmv1(&user_info->nt_resp, 
229                                                  nt_pw, &auth_context->challenge,
230                                                  user_sess_key)) {
231                                 /* The LM session key for this response is not very secure, 
232                                    so use it only if we otherwise allow LM authentication */
233                                 lm_pw = pdb_get_lanman_passwd(sampass);
234
235                                 if (lp_lanman_auth() && lm_pw) {
236                                         uint8 first_8_lm_hash[16];
237                                         memcpy(first_8_lm_hash, lm_pw, 8);
238                                         memset(first_8_lm_hash + 8, '\0', 8);
239                                         *lm_sess_key = data_blob(first_8_lm_hash, 16);
240                                 }
241                                 return NT_STATUS_OK;
242                         } else {
243                                 DEBUG(3,("sam_password_ok: NT MD4 password check failed for user %s\n",pdb_get_username(sampass)));
244                                 return NT_STATUS_WRONG_PASSWORD;
245                         }
246                 } else {
247                         DEBUG(2,("sam_password_ok: NTLMv1 passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass)));                   
248                         /* no return, becouse we might pick up LMv2 in the LM field */
249                 }
250         }
251         
252         if (auth_flags & AUTH_FLAG_LM_RESP) {
253                 if (user_info->lm_resp.length != 24) {
254                         DEBUG(2,("sam_password_ok: invalid LanMan password length (%lu) for user %s\n", 
255                                  (unsigned long)user_info->nt_resp.length, pdb_get_username(sampass)));         
256                 }
257                 
258                 if (!lp_lanman_auth()) {
259                         DEBUG(3,("sam_password_ok: Lanman passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass)));
260                 } else if (IS_SAM_DEFAULT(sampass, PDB_LMPASSWD)) {
261                         DEBUG(3,("sam_password_ok: NO LanMan password set for user %s (and no NT password supplied)\n",pdb_get_username(sampass)));
262                 } else {
263                         lm_pw = pdb_get_lanman_passwd(sampass);
264                         
265                         DEBUG(4,("sam_password_ok: Checking LM password\n"));
266                         if (smb_pwd_check_ntlmv1(&user_info->lm_resp, 
267                                                  lm_pw, &auth_context->challenge,
268                                                  NULL)) {
269                                 uint8 first_8_lm_hash[16];
270                                 memcpy(first_8_lm_hash, lm_pw, 8);
271                                 memset(first_8_lm_hash + 8, '\0', 8);
272                                 *user_sess_key = data_blob(first_8_lm_hash, 16);
273                                 *lm_sess_key = data_blob(first_8_lm_hash, 16);
274                                 return NT_STATUS_OK;
275                         }
276                 }
277
278                 if (IS_SAM_DEFAULT(sampass, PDB_NTPASSWD)) {
279                         DEBUG(4,("sam_password_ok: LM password check failed for user, no NT password %s\n",pdb_get_username(sampass)));
280                         return NT_STATUS_WRONG_PASSWORD;
281                 } 
282                 
283                 nt_pw = pdb_get_nt_passwd(sampass);
284
285                 /* This is for 'LMv2' authentication.  almost NTLMv2 but limited to 24 bytes.
286                    - related to Win9X, legacy NAS pass-though authentication
287                 */
288                 DEBUG(4,("sam_password_ok: Checking LMv2 password with domain %s\n", user_info->client_domain.str));
289                 if (smb_pwd_check_ntlmv2( &user_info->lm_resp, 
290                                           nt_pw, &auth_context->challenge, 
291                                           user_info->smb_name.str, 
292                                           user_info->client_domain.str,
293                                           NULL)) {
294                         return NT_STATUS_OK;
295                 }
296
297                 DEBUG(4,("sam_password_ok: Checking LMv2 password without a domain\n"));
298                 if (smb_pwd_check_ntlmv2( &user_info->lm_resp, 
299                                           nt_pw, &auth_context->challenge, 
300                                           user_info->smb_name.str, 
301                                           "",
302                                           NULL)) {
303                         return NT_STATUS_OK;
304                 }
305
306                 /* Apparently NT accepts NT responses in the LM field
307                    - I think this is related to Win9X pass-though authentication
308                 */
309                 DEBUG(4,("sam_password_ok: Checking NT MD4 password in LM field\n"));
310                 if (lp_ntlm_auth()) {
311                         if (smb_pwd_check_ntlmv1(&user_info->lm_resp, 
312                                                  nt_pw, &auth_context->challenge,
313                                                  NULL)) {
314                                 /* The session key for this response is still very odd.  
315                                    It not very secure, so use it only if we otherwise 
316                                    allow LM authentication */
317                                 lm_pw = pdb_get_lanman_passwd(sampass);
318                         
319                                 if (lp_lanman_auth() && lm_pw) {
320                                         uint8 first_8_lm_hash[16];
321                                         memcpy(first_8_lm_hash, lm_pw, 8);
322                                         memset(first_8_lm_hash + 8, '\0', 8);
323                                         *user_sess_key = data_blob(first_8_lm_hash, 16);
324                                         *lm_sess_key = data_blob(first_8_lm_hash, 16);
325                                 }
326                                 return NT_STATUS_OK;
327                         }
328                         DEBUG(3,("sam_password_ok: LM password, NT MD4 password in LM field and LMv2 failed for user %s\n",pdb_get_username(sampass)));
329                         return NT_STATUS_WRONG_PASSWORD;
330                 } else {
331                         DEBUG(3,("sam_password_ok: LM password and LMv2 failed for user %s, and NT MD4 password in LM field not permitted\n",pdb_get_username(sampass)));
332                         return NT_STATUS_WRONG_PASSWORD;
333                 }
334         }
335                 
336         /* Should not be reached, but if they send nothing... */
337         DEBUG(3,("sam_password_ok: NEITHER LanMan nor NT password supplied for user %s\n",pdb_get_username(sampass)));
338         return NT_STATUS_WRONG_PASSWORD;
339 }
340
341 /****************************************************************************
342  Do a specific test for a SAM_ACCOUNT being vaild for this connection 
343  (ie not disabled, expired and the like).
344 ****************************************************************************/
345
346 static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx,
347                                SAM_ACCOUNT *sampass, 
348                                const auth_usersupplied_info *user_info)
349 {
350         uint16  acct_ctrl = pdb_get_acct_ctrl(sampass);
351         char *workstation_list;
352         time_t kickoff_time;
353         
354         DEBUG(4,("sam_account_ok: Checking SMB password for user %s\n",pdb_get_username(sampass)));
355
356         /* Quit if the account was disabled. */
357         if (acct_ctrl & ACB_DISABLED) {
358                 DEBUG(1,("sam_account_ok: Account for user '%s' was disabled.\n", pdb_get_username(sampass)));
359                 return NT_STATUS_ACCOUNT_DISABLED;
360         }
361
362         /* Quit if the account was locked out. */
363         if (acct_ctrl & ACB_AUTOLOCK) {
364                 DEBUG(1,("sam_account_ok: Account for user %s was locked out.\n", pdb_get_username(sampass)));
365                 return NT_STATUS_ACCOUNT_LOCKED_OUT;
366         }
367
368         /* Test account expire time */
369         
370         kickoff_time = pdb_get_kickoff_time(sampass);
371         if (kickoff_time != 0 && time(NULL) > kickoff_time) {
372                 DEBUG(1,("sam_account_ok: Account for user '%s' has expired.\n", pdb_get_username(sampass)));
373                 DEBUG(3,("sam_account_ok: Account expired at '%ld' unix time.\n", (long)kickoff_time));
374                 return NT_STATUS_ACCOUNT_EXPIRED;
375         }
376
377         if (!(pdb_get_acct_ctrl(sampass) & ACB_PWNOEXP)) {
378                 time_t must_change_time = pdb_get_pass_must_change_time(sampass);
379                 time_t last_set_time = pdb_get_pass_last_set_time(sampass);
380
381                 /* check for immediate expiry "must change at next logon" */
382                 if (must_change_time == 0 && last_set_time != 0) {
383                         DEBUG(1,("sam_account_ok: Account for user '%s' password must change!.\n", pdb_get_username(sampass)));
384                         return NT_STATUS_PASSWORD_MUST_CHANGE;
385                 }
386
387                 /* check for expired password */
388                 if (must_change_time < time(NULL) && must_change_time != 0) {
389                         DEBUG(1,("sam_account_ok: Account for user '%s' password expired!.\n", pdb_get_username(sampass)));
390                         DEBUG(1,("sam_account_ok: Password expired at '%s' (%ld) unix time.\n", http_timestring(must_change_time), (long)must_change_time));
391                         return NT_STATUS_PASSWORD_EXPIRED;
392                 }
393         }
394
395         /* Test workstation. Workstation list is comma separated. */
396
397         workstation_list = talloc_strdup(mem_ctx, pdb_get_workstations(sampass));
398         if (!workstation_list)
399                 return NT_STATUS_NO_MEMORY;
400
401         if (*workstation_list) {
402                 BOOL invalid_ws = True;
403                 const char *s = workstation_list;
404                         
405                 fstring tok;
406                         
407                 while (next_token(&s, tok, ",", sizeof(tok))) {
408                         DEBUG(10,("sam_account_ok: checking for workstation match %s and %s (len=%d)\n",
409                                   tok, user_info->wksta_name.str, user_info->wksta_name.len));
410                         if(strequal(tok, user_info->wksta_name.str)) {
411                                 invalid_ws = False;
412                                 break;
413                         }
414                 }
415                 
416                 if (invalid_ws) 
417                         return NT_STATUS_INVALID_WORKSTATION;
418         }
419
420         if (acct_ctrl & ACB_DOMTRUST) {
421                 DEBUG(2,("sam_account_ok: Domain trust account %s denied by server\n", pdb_get_username(sampass)));
422                 return NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT;
423         }
424         
425         if (acct_ctrl & ACB_SVRTRUST) {
426                 DEBUG(2,("sam_account_ok: Server trust account %s denied by server\n", pdb_get_username(sampass)));
427                 return NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT;
428         }
429         
430         if (acct_ctrl & ACB_WSTRUST) {
431                 DEBUG(4,("sam_account_ok: Wksta trust account %s denied by server\n", pdb_get_username(sampass)));
432                 return NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT;
433         }
434         
435         return NT_STATUS_OK;
436 }
437
438 /****************************************************************************
439 check if a username/password is OK assuming the password is a 24 byte
440 SMB hash supplied in the user_info structure
441 return an NT_STATUS constant.
442 ****************************************************************************/
443
444 static NTSTATUS check_sam_security(const struct auth_context *auth_context,
445                                    void *my_private_data, 
446                                    TALLOC_CTX *mem_ctx,
447                                    const auth_usersupplied_info *user_info, 
448                                    auth_serversupplied_info **server_info)
449 {
450         SAM_ACCOUNT *sampass=NULL;
451         BOOL ret;
452         NTSTATUS nt_status;
453         DATA_BLOB user_sess_key = data_blob(NULL, 0);
454         DATA_BLOB lm_sess_key = data_blob(NULL, 0);
455
456         if (!user_info || !auth_context) {
457                 return NT_STATUS_UNSUCCESSFUL;
458         }
459
460         /* Can't use the talloc version here, because the returned struct gets
461            kept on the server_info */
462         if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sampass))) {
463                 return nt_status;
464         }
465
466         /* get the account information */
467
468         become_root();
469         ret = pdb_getsampwnam(sampass, user_info->internal_username.str);
470         unbecome_root();
471
472         if (ret == False) {
473                 DEBUG(3,("check_sam_security: Couldn't find user '%s' in passdb file.\n", user_info->internal_username.str));
474                 pdb_free_sam(&sampass);
475                 return NT_STATUS_NO_SUCH_USER;
476         }
477
478         nt_status = sam_password_ok(auth_context, mem_ctx, sampass, 
479                                     user_info, &user_sess_key, &lm_sess_key);
480         
481         if (!NT_STATUS_IS_OK(nt_status)) {
482                 pdb_free_sam(&sampass);
483                 return nt_status;
484         }
485
486         nt_status = sam_account_ok(mem_ctx, sampass, user_info);
487
488         if (!NT_STATUS_IS_OK(nt_status)) {
489                 pdb_free_sam(&sampass);
490                 return nt_status;
491         }
492
493         if (!NT_STATUS_IS_OK(nt_status = make_server_info_sam(server_info, sampass))) {         
494                 DEBUG(0,("check_sam_security: make_server_info_sam() failed with '%s'\n", nt_errstr(nt_status)));
495                 return nt_status;
496         }
497
498         (*server_info)->nt_session_key = user_sess_key;
499         (*server_info)->lm_session_key = lm_sess_key;
500
501         return nt_status;
502 }
503
504 /* module initialisation */
505 static NTSTATUS auth_init_sam_ignoredomain(struct auth_context *auth_context, const char *param, auth_methods **auth_method) 
506 {
507         if (!make_auth_methods(auth_context, auth_method)) {
508                 return NT_STATUS_NO_MEMORY;
509         }
510
511         (*auth_method)->auth = check_sam_security;      
512         (*auth_method)->name = "sam_ignoredomain";
513         return NT_STATUS_OK;
514 }
515
516
517 /****************************************************************************
518 Check SAM security (above) but with a few extra checks.
519 ****************************************************************************/
520
521 static NTSTATUS check_samstrict_security(const struct auth_context *auth_context,
522                                          void *my_private_data, 
523                                          TALLOC_CTX *mem_ctx,
524                                          const auth_usersupplied_info *user_info, 
525                                          auth_serversupplied_info **server_info)
526 {
527         BOOL is_local_name, is_my_domain;
528
529         if (!user_info || !auth_context) {
530                 return NT_STATUS_LOGON_FAILURE;
531         }
532
533         is_local_name = is_myname(user_info->domain.str);
534         is_my_domain  = strequal(user_info->domain.str, lp_workgroup());
535
536         /* check whether or not we service this domain/workgroup name */
537         
538         switch ( lp_server_role() ) {
539                 case ROLE_STANDALONE:
540                 case ROLE_DOMAIN_MEMBER:
541                         if ( !is_local_name ) {
542                                 DEBUG(6,("check_samstrict_security: %s is not one of my local names (%s)\n",
543                                         user_info->domain.str, (lp_server_role() == ROLE_DOMAIN_MEMBER 
544                                         ? "ROLE_DOMAIN_MEMBER" : "ROLE_STANDALONE") ));
545                                 return NT_STATUS_NOT_IMPLEMENTED;
546                         }
547                 case ROLE_DOMAIN_PDC:
548                 case ROLE_DOMAIN_BDC:
549                         if ( !is_local_name && !is_my_domain ) {
550                                 DEBUG(6,("check_samstrict_security: %s is not one of my local names or domain name (DC)\n",
551                                         user_info->domain.str));
552                                 return NT_STATUS_NOT_IMPLEMENTED;
553                         }
554                 default: /* name is ok */
555                         break;
556         }
557         
558         return check_sam_security(auth_context, my_private_data, mem_ctx, user_info, server_info);
559 }
560
561 /* module initialisation */
562 static NTSTATUS auth_init_sam(struct auth_context *auth_context, const char *param, auth_methods **auth_method) 
563 {
564         if (!make_auth_methods(auth_context, auth_method)) {
565                 return NT_STATUS_NO_MEMORY;
566         }
567
568         (*auth_method)->auth = check_samstrict_security;
569         (*auth_method)->name = "sam";
570         return NT_STATUS_OK;
571 }
572
573 NTSTATUS auth_sam_init(void)
574 {
575         smb_register_auth(AUTH_INTERFACE_VERSION, "sam", auth_init_sam);
576         smb_register_auth(AUTH_INTERFACE_VERSION, "sam_ignoredomain", auth_init_sam_ignoredomain);
577         return NT_STATUS_OK;
578 }