r6839: Add support for building subsystems as shared libraries. This can be
[ira/wip.git] / source / 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
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(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  * Check a challenge-response password against the value of the NT or
209  * LM password hash.
210  *
211  * @param mem_ctx talloc context
212  * @param challenge 8-byte challenge.  If all zero, forces plaintext comparison
213  * @param nt_response 'unicode' NT response to the challenge, or unicode password
214  * @param lm_response ASCII or LANMAN response to the challenge, or password in DOS code page
215  * @param username internal Samba username, for log messages
216  * @param client_username username the client used
217  * @param client_domain domain name the client used (may be mapped)
218  * @param nt_pw MD4 unicode password from our passdb or similar
219  * @param lm_pw LANMAN ASCII password from our passdb or similar
220  * @param user_sess_key User session key
221  * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
222  */
223
224 NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
225                              const DATA_BLOB *challenge,
226                              const DATA_BLOB *lm_response,
227                              const DATA_BLOB *nt_response,
228                              const DATA_BLOB *lm_interactive_password,
229                              const DATA_BLOB *nt_interactive_password,
230                              const char *username, 
231                              const char *client_username, 
232                              const char *client_domain,
233                              const uint8_t *lm_pw, const uint8_t *nt_pw, 
234                              DATA_BLOB *user_sess_key, 
235                              DATA_BLOB *lm_sess_key)
236 {
237         static const uint8_t zeros[8];
238         DATA_BLOB tmp_sess_key;
239
240         if (nt_pw == NULL) {
241                 DEBUG(3,("ntlm_password_check: NO NT password stored for user %s.\n", 
242                          username));
243         }
244
245         if (lm_sess_key) {
246                 *lm_sess_key = data_blob(NULL, 0);
247         }
248         if (user_sess_key) {
249                 *user_sess_key = data_blob(NULL, 0);
250         }
251
252         if (nt_interactive_password && nt_interactive_password->length && nt_pw) { 
253                 if (nt_interactive_password->length != 16) {
254                         DEBUG(3,("ntlm_password_check: Interactive logon: Invalid NT password length (%d) supplied for user %s\n", (int)nt_interactive_password->length,
255                                  username));
256                         return NT_STATUS_WRONG_PASSWORD;
257                 }
258
259                 if (memcmp(nt_interactive_password->data, nt_pw, 16) == 0) {
260                         if (user_sess_key) {
261                                 *user_sess_key = data_blob_talloc(mem_ctx, NULL, 16);
262                                 SMBsesskeygen_ntv1(nt_pw, user_sess_key->data);
263                         }
264                         return NT_STATUS_OK;
265                 } else {
266                         DEBUG(3,("ntlm_password_check: Interactive logon: NT password check failed for user %s\n",
267                                  username));
268                         return NT_STATUS_WRONG_PASSWORD;
269                 }
270
271         } else if (lm_interactive_password && lm_interactive_password->length && lm_pw) { 
272                 if (lm_interactive_password->length != 16) {
273                         DEBUG(3,("ntlm_password_check: Interactive logon: Invalid LANMAN password length (%d) supplied for user %s\n", (int)lm_interactive_password->length,
274                                  username));
275                         return NT_STATUS_WRONG_PASSWORD;
276                 }
277
278                 if (!lp_lanman_auth()) {
279                         DEBUG(3,("ntlm_password_check: Interactive logon: only LANMAN password supplied for user %s, and LM passwords are disabled!\n",
280                                  username));
281                         return NT_STATUS_WRONG_PASSWORD;
282                 }
283
284                 if (memcmp(lm_interactive_password->data, lm_pw, 16) == 0) {
285                         return NT_STATUS_OK;
286                 } else {
287                         DEBUG(3,("ntlm_password_check: Interactive logon: LANMAN password check failed for user %s\n",
288                                  username));
289                         return NT_STATUS_WRONG_PASSWORD;
290                 }
291         }
292
293         /* Check for cleartext netlogon. Used by Exchange 5.5. */
294         if (challenge->length == sizeof(zeros) && 
295             (memcmp(challenge->data, zeros, challenge->length) == 0 )) {
296
297                 DEBUG(4,("ntlm_password_check: checking plaintext passwords for user %s\n",
298                          username));
299                 if (nt_pw && nt_response->length) {
300                         uint8_t pwhash[16];
301                         mdfour(pwhash, nt_response->data, nt_response->length);
302                         if (memcmp(pwhash, nt_pw, sizeof(pwhash)) == 0) {
303                                 return NT_STATUS_OK;
304                         } else {
305                                 DEBUG(3,("ntlm_password_check: NT (Unicode) plaintext password check failed for user %s\n",
306                                          username));
307                                 return NT_STATUS_WRONG_PASSWORD;
308                         }
309
310                 } else if (!lp_lanman_auth()) {
311                         DEBUG(3,("ntlm_password_check: (plaintext password check) LANMAN passwords NOT PERMITTED for user %s\n",
312                                  username));
313
314                 } else if (lm_pw && lm_response->length) {
315                         uint8_t dospwd[14]; 
316                         uint8_t p16[16]; 
317                         ZERO_STRUCT(dospwd);
318                         
319                         memcpy(dospwd, lm_response->data, MIN(lm_response->length, sizeof(dospwd)));
320                         /* Only the fisrt 14 chars are considered, password need not be null terminated. */
321
322                         /* we *might* need to upper-case the string here */
323                         E_P16((const uint8_t *)dospwd, p16);
324
325                         if (memcmp(p16, lm_pw, sizeof(p16)) == 0) {
326                                 return NT_STATUS_OK;
327                         } else {
328                                 DEBUG(3,("ntlm_password_check: LANMAN (ASCII) plaintext password check failed for user %s\n",
329                                          username));
330                                 return NT_STATUS_WRONG_PASSWORD;
331                         }
332                 } else {
333                         DEBUG(3, ("Plaintext authentication for user %s attempted, but neither NT nor LM passwords available\n", username));
334                         return NT_STATUS_WRONG_PASSWORD;
335                 }
336         }
337
338         if (nt_response->length != 0 && nt_response->length < 24) {
339                 DEBUG(2,("ntlm_password_check: invalid NT password length (%lu) for user %s\n", 
340                          (unsigned long)nt_response->length, username));                
341         }
342         
343         if (nt_response->length > 24 && nt_pw) {
344                 /* We have the NT MD4 hash challenge available - see if we can
345                    use it 
346                 */
347                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password with domain [%s]\n", client_domain));
348                 if (smb_pwd_check_ntlmv2(mem_ctx,
349                                          nt_response, 
350                                          nt_pw, challenge, 
351                                          client_username, 
352                                          client_domain,
353                                          False,
354                                          user_sess_key)) {
355                         if (lm_sess_key) {
356                                 *lm_sess_key = *user_sess_key;
357                                 if (user_sess_key->length) {
358                                         lm_sess_key->length = 8;
359                                 }
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                                          nt_pw, challenge, 
368                                          client_username, 
369                                          client_domain,
370                                          True,
371                                          user_sess_key)) {
372                         if (lm_sess_key) {
373                                 *lm_sess_key = *user_sess_key;
374                                 if (user_sess_key->length) {
375                                         lm_sess_key->length = 8;
376                                 }
377                         }
378                         return NT_STATUS_OK;
379                 }
380                 
381                 DEBUG(4,("ntlm_password_check: Checking NTLMv2 password without a domain\n"));
382                 if (smb_pwd_check_ntlmv2(mem_ctx,
383                                          nt_response, 
384                                          nt_pw, challenge, 
385                                          client_username, 
386                                          "",
387                                          False,
388                                          user_sess_key)) {
389                         if (lm_sess_key) {
390                                 *lm_sess_key = *user_sess_key;
391                                 if (user_sess_key->length) {
392                                         lm_sess_key->length = 8;
393                                 }
394                         }
395                         return NT_STATUS_OK;
396                 } else {
397                         DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));
398                 }
399         } else if (nt_response->length == 24 && nt_pw) {
400                 if (lp_ntlm_auth()) {           
401                         /* We have the NT MD4 hash challenge available - see if we can
402                            use it (ie. does it exist in the smbpasswd file).
403                         */
404                         DEBUG(4,("ntlm_password_check: Checking NT MD4 password\n"));
405                         if (smb_pwd_check_ntlmv1(mem_ctx, 
406                                                  nt_response, 
407                                                  nt_pw, challenge,
408                                                  user_sess_key)) {
409                                 /* The LM session key for this response is not very secure, 
410                                    so use it only if we otherwise allow LM authentication */
411                                 
412                                 if (lp_lanman_auth() && lm_pw) {
413                                         *lm_sess_key = data_blob_talloc(mem_ctx, lm_pw, 8);
414                                 }
415                                 return NT_STATUS_OK;
416                         } else {
417                                 DEBUG(3,("ntlm_password_check: NT MD4 password check failed for user %s\n",
418                                          username));
419                                 return NT_STATUS_WRONG_PASSWORD;
420                         }
421                 } else {
422                         DEBUG(2,("ntlm_password_check: NTLMv1 passwords NOT PERMITTED for user %s\n",
423                                  username));                    
424                         /* no return, becouse we might pick up LMv2 in the LM field */
425                 }
426         }
427         
428         if (lm_response->length == 0) {
429                 DEBUG(3,("ntlm_password_check: NEITHER LanMan nor NT password supplied for user %s\n",
430                          username));
431                 return NT_STATUS_WRONG_PASSWORD;
432         }
433         
434         if (lm_response->length < 24) {
435                 DEBUG(2,("ntlm_password_check: invalid LanMan password length (%lu) for user %s\n", 
436                          (unsigned long)nt_response->length, username));                
437                 return NT_STATUS_WRONG_PASSWORD;
438         }
439                 
440         if (!lp_lanman_auth()) {
441                 DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
442                          username));
443         } else if (!lm_pw) {
444                 DEBUG(3,("ntlm_password_check: NO LanMan password set for user %s (and no NT password supplied)\n",
445                          username));
446         } else {
447                 DEBUG(4,("ntlm_password_check: Checking LM password\n"));
448                 if (smb_pwd_check_ntlmv1(mem_ctx,
449                                          lm_response, 
450                                          lm_pw, challenge,
451                                          NULL)) {
452                         /* The session key for this response is still very odd.  
453                            It not very secure, so use it only if we otherwise 
454                            allow LM authentication */
455
456                         if (lp_lanman_auth() && lm_pw) {
457                                 uint8_t first_8_lm_hash[16];
458                                 memcpy(first_8_lm_hash, lm_pw, 8);
459                                 memset(first_8_lm_hash + 8, '\0', 8);
460                                 *user_sess_key = data_blob_talloc(mem_ctx, first_8_lm_hash, 16);
461                                 *lm_sess_key = data_blob_talloc(mem_ctx, lm_pw, 8);
462                         }
463                         return NT_STATUS_OK;
464                 }
465         }
466         
467         if (!nt_pw) {
468                 DEBUG(4,("ntlm_password_check: LM password check failed for user, no NT password %s\n",username));
469                 return NT_STATUS_WRONG_PASSWORD;
470         }
471         
472         /* This is for 'LMv2' authentication.  almost NTLMv2 but limited to 24 bytes.
473            - related to Win9X, legacy NAS pass-though authentication
474         */
475         DEBUG(4,("ntlm_password_check: Checking LMv2 password with domain %s\n", client_domain));
476         if (smb_pwd_check_ntlmv2(mem_ctx,
477                                  lm_response, 
478                                  nt_pw, challenge, 
479                                  client_username,
480                                  client_domain,
481                                  False,
482                                  &tmp_sess_key)) {
483                 if (nt_response->length > 24) {
484                         /* If NTLMv2 authentication has preceeded us
485                          * (even if it failed), then use the session
486                          * key from that.  See the RPC-SAMLOGON
487                          * torture test */
488                         smb_sess_key_ntlmv2(mem_ctx,
489                                             nt_response, 
490                                             nt_pw, challenge, 
491                                             client_username,
492                                             client_domain,
493                                             False,
494                                             user_sess_key);
495                 } else if (user_sess_key) {
496                         /* Otherwise, use the LMv2 session key */
497                         *user_sess_key = tmp_sess_key;
498                 }
499                 if (user_sess_key && lm_sess_key) {
500                         *lm_sess_key = *user_sess_key;
501                         if (user_sess_key->length) {
502                                 lm_sess_key->length = 8;
503                         }
504                 }
505                 return NT_STATUS_OK;
506         }
507         
508         DEBUG(4,("ntlm_password_check: Checking LMv2 password with upper-cased version of domain %s\n", client_domain));
509         if (smb_pwd_check_ntlmv2(mem_ctx,
510                                  lm_response, 
511                                  nt_pw, challenge, 
512                                  client_username,
513                                  client_domain,
514                                  True,
515                                  &tmp_sess_key)) {
516                 if (nt_response->length > 24) {
517                         /* If NTLMv2 authentication has preceeded us
518                          * (even if it failed), then use the session
519                          * key from that.  See the RPC-SAMLOGON
520                          * torture test */
521                         smb_sess_key_ntlmv2(mem_ctx,
522                                             nt_response, 
523                                             nt_pw, challenge, 
524                                             client_username,
525                                             client_domain,
526                                             True,
527                                             user_sess_key);
528                 } else if (user_sess_key) {
529                         /* Otherwise, use the LMv2 session key */
530                         *user_sess_key = tmp_sess_key;
531                 }
532                 if (user_sess_key && lm_sess_key) {
533                         *lm_sess_key = *user_sess_key;
534                         if (user_sess_key->length) {
535                                 lm_sess_key->length = 8;
536                         }
537                 }
538                 return NT_STATUS_OK;
539         }
540         
541         DEBUG(4,("ntlm_password_check: Checking LMv2 password without a domain\n"));
542         if (smb_pwd_check_ntlmv2(mem_ctx,
543                                  lm_response, 
544                                  nt_pw, challenge, 
545                                  client_username,
546                                  "",
547                                  False,
548                                  &tmp_sess_key)) {
549                 if (nt_response->length > 24) {
550                         /* If NTLMv2 authentication has preceeded us
551                          * (even if it failed), then use the session
552                          * key from that.  See the RPC-SAMLOGON
553                          * torture test */
554                         smb_sess_key_ntlmv2(mem_ctx,
555                                             nt_response, 
556                                             nt_pw, challenge, 
557                                             client_username,
558                                             "",
559                                             False,
560                                             user_sess_key);
561                 } else if (user_sess_key) {
562                         /* Otherwise, use the LMv2 session key */
563                         *user_sess_key = tmp_sess_key;
564                 }
565                 if (user_sess_key && lm_sess_key) {
566                         *lm_sess_key = *user_sess_key;
567                         if (user_sess_key->length) {
568                                 lm_sess_key->length = 8;
569                         }
570                 }
571                 return NT_STATUS_OK;
572         }
573
574         /* Apparently NT accepts NT responses in the LM field
575            - I think this is related to Win9X pass-though authentication
576         */
577         DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));
578         if (lp_ntlm_auth()) {
579                 if (smb_pwd_check_ntlmv1(mem_ctx, 
580                                          lm_response, 
581                                          nt_pw, challenge,
582                                          NULL)) {
583                         /* The session key for this response is still very odd.  
584                            It not very secure, so use it only if we otherwise 
585                            allow LM authentication */
586
587                         if (lp_lanman_auth() && lm_pw) {
588                                 uint8_t first_8_lm_hash[16];
589                                 memcpy(first_8_lm_hash, lm_pw, 8);
590                                 memset(first_8_lm_hash + 8, '\0', 8);
591                                 *user_sess_key = data_blob_talloc(mem_ctx, first_8_lm_hash, 16);
592                                 *lm_sess_key = data_blob_talloc(mem_ctx, lm_pw, 8);
593                         }
594                         return NT_STATUS_OK;
595                 }
596                 DEBUG(3,("ntlm_password_check: LM password, NT MD4 password in LM field and LMv2 failed for user %s\n",username));
597         } else {
598                 DEBUG(3,("ntlm_password_check: LM password and LMv2 failed for user %s, and NT MD4 password in LM field not permitted\n",username));
599         }
600         return NT_STATUS_WRONG_PASSWORD;
601 }
602