r14363: Remove credentials.h from the global includes.
[abartlet/samba.git/.git] / source4 / auth / ntlm_check.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Password and authentication handling
4    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001-2004
5    Copyright (C) Gerald Carter                             2003
6    Copyright (C) Luke Kenneth Casson Leighton         1996-2000
7    
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.
12    
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.
17    
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.
21 */
22
23 #include "includes.h"
24 #include "lib/crypto/crypto.h"
25 #include "librpc/gen_ndr/ndr_netlogon.h"
26 #include "auth/credentials/credentials.h"
27 #include "libcli/auth/proto.h"
28
29 /****************************************************************************
30  Core of smb password checking routine.
31 ****************************************************************************/
32
33 static BOOL smb_pwd_check_ntlmv1(TALLOC_CTX *mem_ctx,
34                                  const DATA_BLOB *nt_response,
35                                  const uint8_t *part_passwd,
36                                  const DATA_BLOB *sec_blob,
37                                  DATA_BLOB *user_sess_key)
38 {
39         /* Finish the encryption of part_passwd. */
40         uint8_t p24[24];
41         
42         if (part_passwd == NULL) {
43                 DEBUG(10,("No password set - DISALLOWING access\n"));
44                 /* No password set - always false ! */
45                 return False;
46         }
47         
48         if (sec_blob->length != 8) {
49                 DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect challenge size (%lu)\n", 
50                           (unsigned long)sec_blob->length));
51                 return False;
52         }
53         
54         if (nt_response->length != 24) {
55                 DEBUG(0, ("smb_pwd_check_ntlmv1: incorrect password length (%lu)\n", 
56                           (unsigned long)nt_response->length));
57                 return False;
58         }
59
60         SMBOWFencrypt(part_passwd, sec_blob->data, p24);
61         
62 #if DEBUG_PASSWORD
63         DEBUG(100,("Part password (P16) was |\n"));
64         dump_data(100, part_passwd, 16);
65         DEBUGADD(100,("Password from client was |\n"));
66         dump_data(100, nt_response->data, nt_response->length);
67         DEBUGADD(100,("Given challenge was |\n"));
68         dump_data(100, sec_blob->data, sec_blob->length);
69         DEBUGADD(100,("Value from encryption was |\n"));
70         dump_data(100, p24, 24);
71 #endif
72         if (memcmp(p24, nt_response->data, 24) == 0) {
73                 if (user_sess_key != NULL) {
74                         *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
75                         SMBsesskeygen_ntv1(part_passwd, user_sess_key->data);
76                 }
77                 return True;
78         } 
79         return False;
80 }
81
82 /****************************************************************************
83  Core of smb password checking routine. (NTLMv2, LMv2)
84  Note:  The same code works with both NTLMv2 and LMv2.
85 ****************************************************************************/
86
87 static BOOL smb_pwd_check_ntlmv2(TALLOC_CTX *mem_ctx,
88                                  const DATA_BLOB *ntv2_response,
89                                  const uint8_t *part_passwd,
90                                  const DATA_BLOB *sec_blob,
91                                  const char *user, const char *domain,
92                                  BOOL upper_case_domain, /* should the domain be transformed into upper case? */
93                                  DATA_BLOB *user_sess_key)
94 {
95         /* Finish the encryption of part_passwd. */
96         uint8_t kr[16];
97         uint8_t value_from_encryption[16];
98         DATA_BLOB client_key_data;
99
100         if (part_passwd == NULL) {
101                 DEBUG(10,("No password set - DISALLOWING access\n"));
102                 /* No password set - always False */
103                 return False;
104         }
105
106         if (sec_blob->length != 8) {
107                 DEBUG(0, ("smb_pwd_check_ntlmv2: incorrect challenge size (%lu)\n", 
108                           (unsigned long)sec_blob->length));
109                 return False;
110         }
111         
112         if (ntv2_response->length < 24) {
113                 /* We MUST have more than 16 bytes, or the stuff below will go
114                    crazy.  No known implementation sends less than the 24 bytes
115                    for LMv2, let alone NTLMv2. */
116                 DEBUG(0, ("smb_pwd_check_ntlmv2: incorrect password length (%lu)\n", 
117                           (unsigned long)ntv2_response->length));
118                 return False;
119         }
120
121         client_key_data = data_blob_talloc(mem_ctx, ntv2_response->data+16, ntv2_response->length-16);
122         /* 
123            todo:  should we be checking this for anything?  We can't for LMv2, 
124            but for NTLMv2 it is meant to contain the current time etc.
125         */
126
127         if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
128                 return False;
129         }
130
131         SMBOWFencrypt_ntv2(kr, sec_blob, &client_key_data, value_from_encryption);
132
133 #if DEBUG_PASSWORD
134         DEBUG(100,("Part password (P16) was |\n"));
135         dump_data(100, part_passwd, 16);
136         DEBUGADD(100,("Password from client was |\n"));
137         dump_data(100, ntv2_response->data, ntv2_response->length);
138         DEBUGADD(100,("Variable data from client was |\n"));
139         dump_data(100, client_key_data.data, client_key_data.length);
140         DEBUGADD(100,("Given challenge was |\n"));
141         dump_data(100, sec_blob->data, sec_blob->length);
142         DEBUGADD(100,("Value from encryption was |\n"));
143         dump_data(100, value_from_encryption, 16);
144 #endif
145         data_blob_clear_free(&client_key_data);
146         if (memcmp(value_from_encryption, ntv2_response->data, 16) == 0) { 
147                 if (user_sess_key != NULL) {
148                         *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
149                         SMBsesskeygen_ntv2(kr, value_from_encryption, user_sess_key->data);
150                 }
151                 return True;
152         }
153         return False;
154 }
155
156 /****************************************************************************
157  Core of smb password checking routine. (NTLMv2, LMv2)
158  Note:  The same code works with both NTLMv2 and LMv2.
159 ****************************************************************************/
160
161 static BOOL smb_sess_key_ntlmv2(TALLOC_CTX *mem_ctx,
162                                 const DATA_BLOB *ntv2_response,
163                                 const uint8_t *part_passwd,
164                                 const DATA_BLOB *sec_blob,
165                                 const char *user, const char *domain,
166                                 BOOL upper_case_domain, /* should the domain be transformed into upper case? */
167                                 DATA_BLOB *user_sess_key)
168 {
169         /* Finish the encryption of part_passwd. */
170         uint8_t kr[16];
171         uint8_t value_from_encryption[16];
172         DATA_BLOB client_key_data;
173
174         if (part_passwd == NULL) {
175                 DEBUG(10,("No password set - DISALLOWING access\n"));
176                 /* No password set - always False */
177                 return False;
178         }
179
180         if (sec_blob->length != 8) {
181                 DEBUG(0, ("smb_sess_key_ntlmv2: incorrect challenge size (%lu)\n", 
182                           (unsigned long)sec_blob->length));
183                 return False;
184         }
185         
186         if (ntv2_response->length < 24) {
187                 /* We MUST have more than 16 bytes, or the stuff below will go
188                    crazy.  No known implementation sends less than the 24 bytes
189                    for LMv2, let alone NTLMv2. */
190                 DEBUG(0, ("smb_sess_key_ntlmv2: incorrect password length (%lu)\n", 
191                           (unsigned long)ntv2_response->length));
192                 return False;
193         }
194
195         client_key_data = data_blob_talloc(mem_ctx, ntv2_response->data+16, ntv2_response->length-16);
196
197         if (!ntv2_owf_gen(part_passwd, user, domain, upper_case_domain, kr)) {
198                 return False;
199         }
200
201         SMBOWFencrypt_ntv2(kr, sec_blob, &client_key_data, value_from_encryption);
202         *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
203         SMBsesskeygen_ntv2(kr, value_from_encryption, user_sess_key->data);
204         return True;
205 }
206
207 /**
208  * Compare password hashes against those from the SAM
209  *
210  * @param mem_ctx talloc context
211  * @param client_lanman LANMAN password hash, as supplied by the client
212  * @param client_nt NT (MD4) password hash, as supplied by the client
213  * @param username internal Samba username, for log messages
214  * @param client_username username the client used
215  * @param client_domain domain name the client used (may be mapped)
216  * @param stored_lanman LANMAN password hash, as stored on the SAM
217  * @param stored_nt NT (MD4) password hash, as stored on the SAM
218  * @param user_sess_key User session key
219  * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
220  */
221
222 NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
223                              const struct samr_Password *client_lanman,
224                              const struct samr_Password *client_nt,
225                              const char *username, 
226                              const struct samr_Password *stored_lanman, 
227                              const struct samr_Password *stored_nt)
228 {
229         if (stored_nt == NULL) {
230                 DEBUG(3,("ntlm_password_check: NO NT password stored for user %s.\n", 
231                          username));
232         }
233
234         if (client_nt && stored_nt) {
235                 if (memcmp(client_nt->hash, stored_nt->hash, sizeof(stored_nt->hash)) == 0) {
236                         return NT_STATUS_OK;
237                 } else {
238                         DEBUG(3,("ntlm_password_check: Interactive logon: NT password check failed for user %s\n",
239                                  username));
240                         return NT_STATUS_WRONG_PASSWORD;
241                 }
242
243         } else if (client_lanman && stored_lanman) {
244                 if (!lp_lanman_auth()) {
245                         DEBUG(3,("ntlm_password_check: Interactive logon: only LANMAN password supplied for user %s, and LM passwords are disabled!\n",
246                                  username));
247                         return NT_STATUS_WRONG_PASSWORD;
248                 }
249                 if (strchr_m(username, '@')) {
250                         return NT_STATUS_NOT_FOUND;
251                 }
252
253                 if (memcmp(client_lanman->hash, stored_lanman->hash, sizeof(stored_lanman->hash)) == 0) {
254                         return NT_STATUS_OK;
255                 } else {
256                         DEBUG(3,("ntlm_password_check: Interactive logon: LANMAN password check failed for user %s\n",
257                                  username));
258                         return NT_STATUS_WRONG_PASSWORD;
259                 }
260         }
261         if (strchr_m(username, '@')) {
262                 return NT_STATUS_NOT_FOUND;
263         }
264         return NT_STATUS_WRONG_PASSWORD;
265 }
266
267 /**
268  * Check a challenge-response password against the value of the NT or
269  * LM password hash.
270  *
271  * @param mem_ctx talloc context
272  * @param challenge 8-byte challenge.  If all zero, forces plaintext comparison
273  * @param nt_response 'unicode' NT response to the challenge, or unicode password
274  * @param lm_response ASCII or LANMAN response to the challenge, or password in DOS code page
275  * @param username internal Samba username, for log messages
276  * @param client_username username the client used
277  * @param client_domain domain name the client used (may be mapped)
278  * @param stored_lanman LANMAN ASCII password from our passdb or similar
279  * @param stored_nt MD4 unicode password from our passdb or similar
280  * @param user_sess_key User session key
281  * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
282  */
283
284 NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
285                              uint32_t logon_parameters,
286                              const DATA_BLOB *challenge,
287                              const DATA_BLOB *lm_response,
288                              const DATA_BLOB *nt_response,
289                              const char *username, 
290                              const char *client_username, 
291                              const char *client_domain,
292                              const struct samr_Password *stored_lanman, 
293                              const struct samr_Password *stored_nt, 
294                              DATA_BLOB *user_sess_key, 
295                              DATA_BLOB *lm_sess_key)
296 {
297         static const uint8_t zeros[8];
298         DATA_BLOB tmp_sess_key;
299
300         if (stored_nt == NULL) {
301                 DEBUG(3,("ntlm_password_check: NO NT password stored for user %s.\n", 
302                          username));
303         }
304
305         *lm_sess_key = data_blob(NULL, 0);
306         *user_sess_key = data_blob(NULL, 0);
307
308         /* Check for cleartext netlogon. Used by Exchange 5.5. */
309         if ((logon_parameters & MSV1_0_CLEARTEXT_PASSWORD_ALLOWED)
310             && challenge->length == sizeof(zeros) 
311             && (memcmp(challenge->data, zeros, challenge->length) == 0 )) {
312                 struct samr_Password client_nt;
313                 struct samr_Password client_lm;
314                 char *unix_pw = NULL;
315                 BOOL lm_ok;
316
317                 DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",
318                          username));
319                 mdfour(client_nt.hash, nt_response->data, nt_response->length);
320                 
321                 if (lm_response->length && 
322                     (convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, 
323                                           lm_response->data, lm_response->length, 
324                                            (void **)&unix_pw) != -1)) {
325                         if (E_deshash(unix_pw, client_lm.hash)) {
326                                 lm_ok = True;
327                         } else {
328                                 lm_ok = False;
329                         }
330                 } else {
331                         lm_ok = False;
332                 }
333                 return hash_password_check(mem_ctx, 
334                                            lm_ok ? &client_lm : NULL, 
335                                            nt_response->length ? &client_nt : NULL, 
336                                            username,  
337                                            stored_lanman, stored_nt);
338         }
339
340         if (nt_response->length != 0 && nt_response->length < 24) {
341                 DEBUG(2,("ntlm_password_check: invalid NT password length (%lu) for user %s\n", 
342                          (unsigned long)nt_response->length, username));                
343         }
344         
345         if (nt_response->length > 24 && stored_nt) {
346                 /* We have the NT MD4 hash challenge available - see if we can
347                    use it 
348                 */
349                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with domain [%s]\n", client_domain));
350                 if (smb_pwd_check_ntlmv2(mem_ctx,
351                                          nt_response, 
352                                          stored_nt->hash, challenge, 
353                                          client_username, 
354                                          client_domain,
355                                          False,
356                                          user_sess_key)) {
357                         *lm_sess_key = *user_sess_key;
358                         if (user_sess_key->length) {
359                                 lm_sess_key->length = 8;
360                         }
361                         return NT_STATUS_OK;
362                 }
363                 
364                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with uppercased version of domain [%s]\n", client_domain));
365                 if (smb_pwd_check_ntlmv2(mem_ctx,
366                                          nt_response, 
367                                          stored_nt->hash, challenge, 
368                                          client_username, 
369                                          client_domain,
370                                          True,
371                                          user_sess_key)) {
372                         *lm_sess_key = *user_sess_key;
373                         if (user_sess_key->length) {
374                                 lm_sess_key->length = 8;
375                         }
376                         return NT_STATUS_OK;
377                 }
378                 
379                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password without a domain\n"));
380                 if (smb_pwd_check_ntlmv2(mem_ctx,
381                                          nt_response, 
382                                          stored_nt->hash, challenge, 
383                                          client_username, 
384                                          "",
385                                          False,
386                                          user_sess_key)) {
387                         *lm_sess_key = *user_sess_key;
388                         if (user_sess_key->length) {
389                                 lm_sess_key->length = 8;
390                         }
391                         return NT_STATUS_OK;
392                 } else {
393                         DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));
394                 }
395         } else if (nt_response->length == 24 && stored_nt) {
396                 if (lp_ntlm_auth()) {           
397                         /* We have the NT MD4 hash challenge available - see if we can
398                            use it (ie. does it exist in the smbpasswd file).
399                         */
400                         DEBUG(4,("ntlm_password_check: Checking NT MD4 password\n"));
401                         if (smb_pwd_check_ntlmv1(mem_ctx, 
402                                                  nt_response, 
403                                                  stored_nt->hash, challenge,
404                                                  user_sess_key)) {
405                                 /* The LM session key for this response is not very secure, 
406                                    so use it only if we otherwise allow LM authentication */
407                                 
408                                 if (lp_lanman_auth() && stored_lanman) {
409                                         *lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
410                                 }
411                                 return NT_STATUS_OK;
412                         } else {
413                                 DEBUG(3,("ntlm_password_check: NT MD4 password check failed for user %s\n",
414                                          username));
415                                 return NT_STATUS_WRONG_PASSWORD;
416                         }
417                 } else {
418                         DEBUG(2,("ntlm_password_check: NTLMv1 passwords NOT PERMITTED for user %s\n",
419                                  username));                    
420                         /* no return, becouse we might pick up LMv2 in the LM field */
421                 }
422         }
423         
424         if (lm_response->length == 0) {
425                 DEBUG(3,("ntlm_password_check: NEITHER LanMan nor NT password supplied for user %s\n",
426                          username));
427                 return NT_STATUS_WRONG_PASSWORD;
428         }
429         
430         if (lm_response->length < 24) {
431                 DEBUG(2,("ntlm_password_check: invalid LanMan password length (%lu) for user %s\n", 
432                          (unsigned long)nt_response->length, username));                
433                 return NT_STATUS_WRONG_PASSWORD;
434         }
435                 
436         if (!lp_lanman_auth()) {
437                 DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
438                          username));
439         } else if (!stored_lanman) {
440                 DEBUG(3,("ntlm_password_check: NO LanMan password set for user %s (and no NT password supplied)\n",
441                          username));
442         } else if (strchr_m(username, '@')) {
443                 DEBUG(3,("ntlm_password_check: NO LanMan password allowed for username@realm logins (user: %s)\n",
444                          username));
445         } else {
446                 DEBUG(4,("ntlm_password_check: Checking LM password\n"));
447                 if (smb_pwd_check_ntlmv1(mem_ctx,
448                                          lm_response, 
449                                          stored_lanman->hash, challenge,
450                                          NULL)) {
451                         /* The session key for this response is still very odd.  
452                            It not very secure, so use it only if we otherwise 
453                            allow LM authentication */
454
455                         if (lp_lanman_auth() && stored_lanman) {
456                                 uint8_t first_8_lm_hash[16];
457                                 memcpy(first_8_lm_hash, stored_lanman->hash, 8);
458                                 memset(first_8_lm_hash + 8, '\0', 8);
459                                 *user_sess_key = data_blob_talloc(mem_ctx, first_8_lm_hash, 16);
460                                 *lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
461                         }
462                         return NT_STATUS_OK;
463                 }
464         }
465         
466         if (!stored_nt) {
467                 DEBUG(4,("ntlm_password_check: LM password check failed for user, no NT password %s\n",username));
468                 return NT_STATUS_WRONG_PASSWORD;
469         }
470         
471         /* This is for 'LMv2' authentication.  almost NTLMv2 but limited to 24 bytes.
472            - related to Win9X, legacy NAS pass-though authentication
473         */
474         DEBUG(4,("ntlm_password_check: Checking LMv2 password with domain %s\n", client_domain));
475         if (smb_pwd_check_ntlmv2(mem_ctx,
476                                  lm_response, 
477                                  stored_nt->hash, challenge, 
478                                  client_username,
479                                  client_domain,
480                                  False,
481                                  &tmp_sess_key)) {
482                 if (nt_response->length > 24) {
483                         /* If NTLMv2 authentication has preceeded us
484                          * (even if it failed), then use the session
485                          * key from that.  See the RPC-SAMLOGON
486                          * torture test */
487                         smb_sess_key_ntlmv2(mem_ctx,
488                                             nt_response, 
489                                             stored_nt->hash, challenge, 
490                                             client_username,
491                                             client_domain,
492                                             False,
493                                             user_sess_key);
494                 } else {
495                         /* Otherwise, use the LMv2 session key */
496                         *user_sess_key = tmp_sess_key;
497                 }
498                 *lm_sess_key = *user_sess_key;
499                 if (user_sess_key->length) {
500                         lm_sess_key->length = 8;
501                 }
502                 return NT_STATUS_OK;
503         }
504         
505         DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n", client_domain));
506         if (smb_pwd_check_ntlmv2(mem_ctx,
507                                  lm_response, 
508                                  stored_nt->hash, challenge, 
509                                  client_username,
510                                  client_domain,
511                                  True,
512                                  &tmp_sess_key)) {
513                 if (nt_response->length > 24) {
514                         /* If NTLMv2 authentication has preceeded us
515                          * (even if it failed), then use the session
516                          * key from that.  See the RPC-SAMLOGON
517                          * torture test */
518                         smb_sess_key_ntlmv2(mem_ctx,
519                                             nt_response, 
520                                             stored_nt->hash, challenge, 
521                                             client_username,
522                                             client_domain,
523                                             True,
524                                             user_sess_key);
525                 } else {
526                         /* Otherwise, use the LMv2 session key */
527                         *user_sess_key = tmp_sess_key;
528                 }
529                 *lm_sess_key = *user_sess_key;
530                 if (user_sess_key->length) {
531                         lm_sess_key->length = 8;
532                 }
533                 return NT_STATUS_OK;
534         }
535         
536         DEBUG(4,("ntlm_password_check: Checking LMv2 password without a domain\n"));
537         if (smb_pwd_check_ntlmv2(mem_ctx,
538                                  lm_response, 
539                                  stored_nt->hash, challenge, 
540                                  client_username,
541                                  "",
542                                  False,
543                                  &tmp_sess_key)) {
544                 if (nt_response->length > 24) {
545                         /* If NTLMv2 authentication has preceeded us
546                          * (even if it failed), then use the session
547                          * key from that.  See the RPC-SAMLOGON
548                          * torture test */
549                         smb_sess_key_ntlmv2(mem_ctx,
550                                             nt_response, 
551                                             stored_nt->hash, challenge, 
552                                             client_username,
553                                             "",
554                                             False,
555                                             user_sess_key);
556                 } else {
557                         /* Otherwise, use the LMv2 session key */
558                         *user_sess_key = tmp_sess_key;
559                 }
560                 *lm_sess_key = *user_sess_key;
561                 if (user_sess_key->length) {
562                         lm_sess_key->length = 8;
563                 }
564                 return NT_STATUS_OK;
565         }
566
567         /* Apparently NT accepts NT responses in the LM field
568            - I think this is related to Win9X pass-though authentication
569         */
570         DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));
571         if (lp_ntlm_auth()) {
572                 if (smb_pwd_check_ntlmv1(mem_ctx, 
573                                          lm_response, 
574                                          stored_nt->hash, challenge,
575                                          NULL)) {
576                         /* The session key for this response is still very odd.  
577                            It not very secure, so use it only if we otherwise 
578                            allow LM authentication */
579
580                         if (lp_lanman_auth() && stored_lanman) {
581                                 uint8_t first_8_lm_hash[16];
582                                 memcpy(first_8_lm_hash, stored_lanman->hash, 8);
583                                 memset(first_8_lm_hash + 8, '\0', 8);
584                                 *user_sess_key = data_blob_talloc(mem_ctx, first_8_lm_hash, 16);
585                                 *lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
586                         }
587                         return NT_STATUS_OK;
588                 }
589                 DEBUG(3,("ntlm_password_check: LM password, NT MD4 password in LM field and LMv2 failed for user %s\n",username));
590         } else {
591                 DEBUG(3,("ntlm_password_check: LM password and LMv2 failed for user %s, and NT MD4 password in LM field not permitted\n",username));
592         }
593
594         /* Try and match error codes */
595         if (strchr_m(username, '@')) {
596                 return NT_STATUS_NOT_FOUND;
597         }
598         return NT_STATUS_WRONG_PASSWORD;
599 }
600