diff -rub samba-3.0.22/source/libsmb/smbencrypt.c samba-3.0.22-jmk/source/libsmb/smbencrypt.c
--- samba-3.0.22/source/libsmb/smbencrypt.c	2006-01-24 17:46:35.000000000 -0600
+++ samba-3.0.22-jmk/source/libsmb/smbencrypt.c	2006-10-25 09:09:51.000000000 -0500
@@ -25,6 +25,9 @@
 #include "includes.h"
 #include "byteorder.h"
 
+#define SMB_HASH_LM 1
+#define SMB_HASH_NTLM 2
+
 /*
    This implements the X/Open SMB password encryption
    It takes a password ('unix' string), a 8 byte "crypt key" 
@@ -52,6 +55,57 @@
 	return ret;
 }
 
+/*
+   Support for using LM/NTLM hashes -- jmk@foofus.net 10/2006 
+   Greets: Foofus, Phenfen, Omi, Fizzgig, pMonkey
+*/
+void E_set_hash(int type, uchar hash[16])
+{
+	uint l;
+	pstring p;
+	int i, j;
+	char HexChar;
+	int HexValue;
+
+	if ( (getenv("SMBHASH")) && (strlen(getenv("SMBHASH")) == 65) )
+	{
+		pstrcpy(p, getenv("SMBHASH"));
+
+		for (i=0; i<16; i++) {
+			HexValue = 0x0;
+			for (j=0; j<2; j++) {
+				if (type == SMB_HASH_LM)
+					HexChar = (char)p[2*i+j];
+				else
+					HexChar = (char)p[2*i+j+33];
+
+				if (HexChar > 0x39)
+					HexChar = HexChar | 0x20;  /* convert upper case to lower */
+
+				if (!(((HexChar >= 0x30) && (HexChar <= 0x39))||   /* 0 - 9 */
+				   ((HexChar >= 0x61) && (HexChar <= 0x66)))) {    /* a - f */
+					fprintf(stderr, "Error invalid char (%c) for hash.\n", HexChar);
+					exit(1);
+				}
+
+				HexChar -= 0x30;
+				if (HexChar > 0x09)  /* HexChar is "a" - "f" */
+					HexChar -= 0x27;
+
+				HexValue = (HexValue << 4) | (char)HexChar;
+			}
+			hash[i] = (uchar)HexValue;
+		}
+	}
+	else
+	{
+		fprintf(stderr, "Error reading SMB HASH.\n");
+		fprintf(stderr, "\tEx: export SMBHASH=\"_LM_HASH_:_NTLM_HASH_\"\n");
+		exit(1);
+	}
+}
+/* jmk */
+
 /**
  * Creates the MD4 Hash of the users password in NT UNICODE.
  * @param passwd password in 'unix' charset.
@@ -63,6 +117,11 @@
 	int len;
 	smb_ucs2_t wpwd[129];
 	
+	/* Support for using NTLM hashes -- jmk@foofus.net 10/2006 */
+	if ( getenv("SMBHASH") ) {
+		fprintf(stderr, "HASH PASS: Substituting user supplied NTLM HASH...\n");
+		E_set_hash(SMB_HASH_NTLM, p16);
+	} else { 
 	/* Password must be converted to NT unicode - null terminated. */
 	push_ucs2(NULL, wpwd, (const char *)passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE);
 	/* Calculate length in bytes */
@@ -70,6 +129,7 @@
 
 	mdfour(p16, (unsigned char *)wpwd, len);
 	ZERO_STRUCT(wpwd);	
+	}
 }
 
 /**
@@ -106,6 +166,11 @@
 	fstring dospwd; 
 	ZERO_STRUCT(dospwd);
 	
+	/* Support for using LM hashes -- jmk@foofus.net 10/2006 */
+	if ( getenv("SMBHASH") ) {
+		fprintf(stderr, "HASH PASS: Substituting user supplied LM HASH...\n");
+		E_set_hash(SMB_HASH_LM, p16);
+	} else {
 	/* Password must be converted to DOS charset - null terminated, uppercase. */
 	push_ascii(dospwd, passwd, sizeof(dospwd), STR_UPPER|STR_TERMINATE);
        
@@ -117,6 +182,7 @@
 	}
 
 	ZERO_STRUCT(dospwd);	
+	}
 
 	return ret;
 }
