[jcifs] how to investigate authentication failure (with Unix share)

Schmidlin, Franck Franck.Schmidlin at northgate-is.com
Wed Aug 11 05:31:01 MDT 2010


 Dear all,

Could you suggest ways to investigate why my very simple code fails to connect to a unix share, from a windows machine?
The failure claims to be an authentication failure, but I am certain my credentials are correct.
This code works fine when accessing windows shares and works fine using a drive mapped to that unix share.

I do not however know enough about unix to figure out what could cause my user not to be able to authenticate when using JCIFS (v1.2.13) to access the share directly.

What follows is a (slightly sanitised) log of the problem.
I am personally incapable of interpreting this trace, so your help will be much appreciated.

Are there questions I should ask of the Unix administrator?
Are there additional flags I can pass to JCIFS?
Is the isLoggedInAsGuest=true relevant?

Thanks
 
Franck


--- The Trace :---------
TestSmb ---------------- TESTING -----------------
TestSmb smb://hmsrv4test/dti/letter_13-07-10-04-52.csv XXXXXXXX xxXxxxxxxxxxx password
#JCIFS PROPERTIES
#Wed Aug 11 11:04:35 BST 2010
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\bin
java.vm.version=11.0-b15
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http\://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=GB
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 2
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C\:\\NorthgateIS\\ApplicationConnect
java.runtime.version=1.6.0_10-b33
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\endorsed
os.arch=x86
java.io.tmpdir=C\:\\DOCUME~1\\XXXXX~1\\LOCALS~1\\Temp\\2\\
line.separator=\r\n
java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows 2003
sun.jnu.encoding=Cp1252
java.library.path=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\bin;.;C\:\\WINDOWS\\Sun\\Java\\bin;C\:\\WINDOWS\\system32;C\:\\WINDOWS;C\:\\WINDOWS\\system32;C\:\\WINDOWS;C\:\\WINDOWS\\System32\\Wbem
java.specification.name=Java Platform API Specification
java.class.version=50.0
sun.management.compiler=HotSpot Client Compiler
os.version=5.2
user.home=C\:\\Documents and Settings\\xxxxxxxxx
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=Cp1252
java.specification.version=1.6
jcifs.util.loglevel=10
user.name=ngfrontoffice
java.class.path=.;lib\\jcifs\\jcifs-1.2.13.jar
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0
java.specification.vendor=Sun Microsystems Inc.
user.language=en
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.6.0_10
java.ext.dirs=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\ext;C\:\\WINDOWS\\Sun\\Java\\lib\\ext
sun.boot.class.path=C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\endorsed\\serializer.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\endorsed\\xalan.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\endorsed\\xercesImpl.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\endorsed\\xml-apis.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\resources.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\rt.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\sunrsasign.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\jsse.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\jce.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\lib\\charsets.jar;C\:\\NorthgateIS\\ApplicationConnect\\jre_1_6_0\\classes
java.vendor=Sun Microsystems Inc.
file.separator=\\
java.vendor.url.bug=http\://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

NameQueryRequest[nameTrnId=1,isResponse=false,opCode=QUERY,isAuthAnswer=false,isTruncated=false,isRecurAvailable=false,isRecurDesired=true,isBroadcast=true,resultCode=0,questionCount=1,answerCount=0,authorityCount=0,additionalCount=0,questionName=HMSRV4TEST<20>,questionType=0x0020,questionClass=IN,recordName=null,recordType=0x0000,recordClass=0x0000,ttl=0,rDataLength=0]
00000: 00 01 01 10 00 01 00 00 00 00 00 00 20 45 49 45  |............ EIE|
00010: 4E 46 44 46 43 46 47 44 45 46 45 45 46 46 44 46  |NFDFCFGDEFEEFFDF|
00020: 45 43 41 43 41 43 41 43 41 43 41 43 41 00 00 20  |ECACACACACACA.. |
00030: 00 01                                            |..              |
 
NameQueryRequest[nameTrnId=2,isResponse=false,opCode=QUERY,isAuthAnswer=false,isTruncated=false,isRecurAvailable=false,isRecurDesired=true,isBroadcast=true,resultCode=0,questionCount=1,answerCount=0,authorityCount=0,additionalCount=0,questionName=HMSRV4TEST<20>,questionType=0x0020,questionClass=IN,recordName=null,recordType=0x0000,recordClass=0x0000,ttl=0,rDataLength=0]
00000: 00 02 01 10 00 01 00 00 00 00 00 00 20 45 49 45  |............ EIE|
00010: 4E 46 44 46 43 46 47 44 45 46 45 45 46 46 44 46  |NFDFCFGDEFEEFFDF|
00020: 45 43 41 43 41 43 41 43 41 43 41 43 41 00 00 20  |ECACACACACACA.. |
00030: 00 01                                            |..              |
 
SmbComNegotiate[command=SMB_COM_NEGOTIATE,received=false,errorCode=0,flags=0x0018,flags2=0xC003,signSeq=0,tid=0,pid=49077,uid=0,mid=1,wordCount=0,byteCount=12,wordCount=0,dialects=NT LM 0.12]
00000: FF 53 4D 42 72 00 00 00 00 18 03 C0 00 00 00 00  |ÿSMBr......À....|
00010: 00 00 00 00 00 00 00 00 00 00 B5 BF 00 00 01 00  |..........µ¿....|
00020: 00 0C 00 02 4E 54 20 4C 4D 20 30 2E 31 32 00     |....NT LM 0.12. |
 
New data read: Transport1[hmsrv4test/172.21.1.45:445]
00000: FF 53 4D 42 72 00 00 00 00 88 01 C0 00 00 00 00  |ÿSMBr......À....|
00010: 00 00 00 00 00 00 00 00 00 00 B5 BF 00 00 01 00  |..........µ¿....|
 
byteCount=18 but readBytesWireFormat returned 16
SmbComNegotiateResponse[command=SMB_COM_NEGOTIATE,received=false,errorCode=0,flags=0x0088,flags2=0xC001,signSeq=0,tid=0,pid=49077,uid=0,mid=1,wordCount=17,byteCount=18,wordCount=17,dialectIndex=0,securityMode=0x2,security=share,encryptedPasswords=true,maxMpxCount=50,maxNumberVcs=1,maxBufferSize=16644,maxRawSize=65536,sessionKey=0x00002EB6,capabilities=0x0080F3FD,serverTime=Wed Aug 11 11:06:12 BST 2010,serverTimeZone=65476,encryptionKeyLength=8,byteCount=18,encryptionKey=0x85C9D6A8FED6E805,oemDomainName=TEMP]
00000: FF 53 4D 42 72 00 00 00 00 88 01 C0 00 00 00 00  |ÿSMBr......À....|
00010: 00 00 00 00 00 00 00 00 00 00 B5 BF 00 00 01 00  |..........µ¿....|
00020: 11 00 00 02 32 00 01 00 04 41 00 00 00 00 01     |....2....A..... |

treeConnect: unc=\\hmsrv4test\DTI,service=?????
sessionSetup: accountName=xxXxxxxxxxxxx,primaryDomain=XXXXXXXX

SmbComSessionSetupAndX[command=SMB_COM_SESSION_SETUP_ANDX,received=false,errorCode=0,flags=0x0018,flags2=0xC003,signSeq=0,tid=0,pid=49077,uid=0,mid=2,wordCount=13,byteCount=85,andxCommand=0x75,andxOffset=146,snd_buf_size=16644,maxMpxCount=10,VC_NUMBER=1,sessionKey=0,passwordLength=0,unicodePasswordLength=0,capabilities=4180,accountName=xxXxxxxXxxxxx,primaryDomain=XXXXXXXX,NATIVE_OS=Windows 2003,NATIVE_LANMAN=jCIFS]
SmbComTreeConnectAndX[command=SMB_COM_TREE_CONNECT_ANDX,received=false,errorCode=0,flags=0x0018,flags2=0x0000,signSeq=0,tid=0,pid=49077,uid=0,mid=0,wordCount=4,byteCount=65,andxCommand=0xFF,andxOffset=0,disconnectTid=false,passwordLength=24,password=,path=\\hmsrv4test\DTI,service=?????]
00000: FF 53 4D 42 73 00 00 00 00 18 03 C0 00 00 00 00  |ÿSMBs......À....|
00010: 00 00 00 00 00 00 00 00 00 00 B5 BF 00 00 02 00  |..........µ¿....|
00020: 0D 75 00 92 00 04 41 0A 00 01 00 00 00 00 00 00  |.u....A.........|
00030: 00 00 00 00 00 00 00 54 10 00 00 55 00 00 78 00  |.......T...U..x.|
00040: 78 00 58 00 78 00 78 00 78 00 78 00 78 00 78 00  |x.X.x.x.x.x.x.x.|
00050: 78 00 78 00 78 00 78 00 00 00 58 00 58 00 58 00  |x.x.x.x...X.X.X.|
00060: 58 00 58 00 58 00 58 00 58 00 00 00 57 00 69 00  |X.X.X.X.X...W.i.|
00070: 6E 00 64 00 6F 00 77 00 73 00 20 00 32 00 30 00  |n.d.o.w.s. .2.0.|
00080: 30 00 33 00 00 00 6A 00 43 00 49 00 46 00 53 00  |0.3...j.C.I.F.S.|
00090: 00 00 04 FF 00 00 00 00 00 18 00 41 00 42 B9 83  |...ÿ.......A.B¹.|
000A0: 07 9C 89 5D 3C EA A8 92 5F 76 88 04 2D 1E B2 05  |...]<ê¨._v..-.².|
000B0: 79 2C 54 AB 17 00 5C 00 5C 00 68 00 6D 00 73 00  |y,T«..\.\.h.m.s.|
000C0: 72 00 76 00 34 00 74 00 65 00 73 00 74 00 5C 00  |r.v.4.t.e.s.t.\.|
000D0: 44 00 54 00 49 00 00 00 3F 3F 3F 3F 3F 00        |D.T.I...?????.  |

New data read: Transport1[hmsrv4test/172.21.1.45:445]
00000: FF 53 4D 42 73 00 00 00 00 88 01 C0 00 00 00 00  |ÿSMBs......À....|
00010: 00 00 00 00 00 00 00 00 01 00 B5 BF 00 00 02 00  |..........µ¿....|
 
SmbComSessionSetupAndXResponse[command=SMB_COM_SESSION_SETUP_ANDX,received=false,errorCode=0,flags=0x0088,flags2=0xC001,signSeq=0,tid=1,pid=49077,uid=0,mid=2,wordCount=3,byteCount=47,andxCommand=0x75,andxOffset=88,isLoggedInAsGuest=true,nativeOs=Unix,nativeLanMan=Samba 3.0.28,primaryDomain=TEMP]
00000: FF 53 4D 42 73 00 00 00 00 88 01 C0 00 00 00 00  |ÿSMBs......À....|
00010: 00 00 00 00 00 00 00 00 01 00 B5 BF 00 00 02 00  |..........µ¿....|
00020: 03 75 00 58 00 01 00 2F 00 00 55 00 6E 00 69 00  |.u.X.../..U.n.i.|
00030: 78 00 00 00 53 00 61 00 6D 00 62 00 61 00 20 00  |x...S.a.m.b.a. .|
00040: 33 00 2E 00 30 00 2E 00 32 00 38 00 00 00 54 00  |3...0...2.8...T.|
00050: 45 00 4D 00 50 00 00 00 03 FF 00 00 00 01 00 0D  |E.M.P....ÿ......|
00060: 00 41 3A 00 4E 00 54 00 46 00 53 00 00 00        |.A:.N.T.F.S...  |
 
jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
            at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:281)
            at jcifs.smb.SmbSession.send(SmbSession.java:233)
            at jcifs.smb.SmbTree.treeConnect(SmbTree.java:154)
            at jcifs.smb.SmbFile.connect(SmbFile.java:798)
            at jcifs.smb.SmbFile.connect0(SmbFile.java:768)
            at jcifs.smb.SmbFile.queryPath(SmbFile.java:1195)
            at jcifs.smb.SmbFile.exists(SmbFile.java:1277)
            at jcifs.smb.SmbFile.isDirectory(SmbFile.java:1350)
            at TestSmb.main(TestSmb.java:83)
TestSmb ---------------- THE END -----------------

--- End Of The Trace :---------

--- The Code  :---------
            System.out.println("\nTestSmb ---------------- TESTING -----------------");
            System.out.println("TestSmb "+strPath+" "+strDomain+" "+strUserId+" "+strUserPwd+(strCopyTo!=null?(" "+strCopyTo):""));
            
            jcifs.smb.SmbFile s = new jcifs.smb.SmbFile(strPath, 
                new jcifs.smb.NtlmPasswordAuthentication(strDomain, strUserId, strUserPwd) );
        
            if( s.isDirectory() ) 
            {
                String strFilenames[] = s.list();
                System.out.println(strPath+" is a folder. It contains "+strFilenames.length+" files:");
                for(int i=0; i<strFilenames.length; i++)
                { 
                    System.out.println("  "+i+": "+strFilenames[i]);
                }
            } 
            else if(s.isFile())
            {
                System.out.println(strPath+" is a file. It starts with the following content: ");
                java.io.BufferedReader read = new java.io.BufferedReader(
                    new java.io.InputStreamReader(s.getInputStream()));
                for(int i=0; i<10; i++)
                {
                    String str = read.readLine();
                    if(str!=null)
                    {
                        System.out.println("  "+i+": "+str);
                    }
                    else
                    {
                        break;
                    }
                }
                
                
                if(strCopyTo!=null)
                {
                    System.out.println("Copying "+ strPath+" to "+strCopyTo+"...");
                    s.copyTo(new jcifs.smb.SmbFile(strCopyTo, 
                        new jcifs.smb.NtlmPasswordAuthentication(strDomain, strUserId, strUserPwd)));
                    System.out.println("Copied successfully");
                }
            }
            else
            {
                System.out.println(strPath+" is neither a folder nor a file...");
            }
                  
        }
        catch (Throwable e)
        {
            e.printStackTrace(System.err);
        }
        System.out.println("TestSmb ---------------- THE END -----------------");

-----------------------------------------------------------------------------------------
This email is sent on behalf of Northgate Information Solutions Limited and its associated companies ("Northgate") and is strictly confidential and intended solely for the addressee(s).  
 
If you are not the intended recipient of this email you must: (i) not disclose, copy or distribute its contents to any other person nor use its contents in any way or you may be acting unlawfully;  (ii) contact Northgate immediately on +44 (0)1442 232424 quoting the name of the sender and the addressee then delete it from your system.
 
Northgate has taken reasonable precautions to ensure that no viruses are contained in this email, but does not accept any responsibility once this email has been transmitted.  You should scan attachments (if any) for viruses.
 
Northgate Information Solutions Limited. Registered in England no. 06442582  -  Northgate Information Solutions UK Limited. Registered in England no. 968498  -  NorthgateArinso UK Limited .Registered in England no. 1587537  -  Moorepay Limited.  Registered in England no. 891686  - First Business Support Limited. Registered in England no. 3056267 -  Registered Office: Peoplebuilding 2, Peoplebuilding Estate, Maylands Avenue, Hemel Hempstead, Hertfordshire HP2 4NW 
 
Northgate Managed Services Limited (NI).  Registered in Northern Ireland no. NI032979  -  LearnServe Limited (NI).  Registered in Northern Ireland no. NI043825
Registered Office: Hillview House, 61 Church Road, Newtownabbey, Co. Antrim, BT36 7LQ 

-----------------------------------------------------------------------------------------


More information about the jCIFS mailing list