[jcifs] File naming problem

Thomas Bley thomas.bley at simple-groupware.de
Sat Dec 31 04:41:55 GMT 2005


Hi Mike,

I took Samba 3.0.12 and created a share with german special characters 
(=umlaute) named 'testöäü':
The umlaute are in iso8859-1, I hope you see it in my mail.

My code:

SmbFile file = new SmbFile( "smb://administrator:admin@192.168.0.200/" );

long t1 = System.currentTimeMillis();
SmbFile[] files = file.listFiles();
long t2 = System.currentTimeMillis() - t1;

for( int i = 0; i < files.length; i++ ) {
System.out.print( " " + files[i].getName() );
}
System.out.println("result should be testöäü");
System.out.println( files.length + " files in " + t2 + "ms" );

The results (gives test”„?, but not testöäü):

#JCIFS PROPERTIES
#Sat Dec 31 05:25:30 CET 2005
java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path=E\:\\Program Files\\Java2SDK 1-41\\jre\\bin
java.vm.version=1.4.1_01-b01
jcifs.encoding=ISO8859_1
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=DE
sun.os.patch.level=Service Pack 2
java.vm.specification.name=Java Virtual Machine Specification
user.dir=h\:\\workspace\\jcifs
java.runtime.version=1.4.1_01-b01
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=E\:\\Program Files\\Java2SDK 1-41\\jre\\lib\\endorsed
os.arch=x86
java.io.tmpdir=E\:\\Temp\\
line.separator=\r\n
java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows XP
sun.java2d.fontpath=
java.library.path=E\:\\Program Files\\Java2SDK 
1-41\\bin;.;E\:\\WINNT\\system32;E\:\\WINNT;e\:\\PROGRA~1\\gtk\\bin;E\:\\WINNT\\system32;E\:\\WINNT;E\:\\WINNT\\System32\\Wbem;E\:\\Program 
Files\\Java2SDK 1-41\\jre\\bin;e\:\\program 
files\\linuxtools;e\:\\program 
files\\linuxtools\\mc;D\:\\Development\\oraclient
java.specification.name=Java Platform API Specification
java.class.version=48.0
java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory
os.version=5.1
user.home=E\:\\Documents and Settings\\admin
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=Cp1252
java.specification.version=1.4
jcifs.util.loglevel=10
user.name=admin
java.class.path=h\:\\workspace\\jcifs\\bin;h\:\\webdisk\\lib\\servlet-api.jar
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=E\:\\Program Files\\Java2SDK 1-41\\jre
java.specification.vendor=Sun Microsystems Inc.
user.language=de
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode
java.version=1.4.1_01
java.ext.dirs=E\:\\Program Files\\Java2SDK 1-41\\jre\\lib\\ext
sun.boot.class.path=E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\rt.jar;E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\i18n.jar;E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\sunrsasign.jar;E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\jsse.jar;E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\jce.jar;E\:\\Program Files\\Java2SDK 
1-41\\jre\\lib\\charsets.jar;E\:\\Program Files\\Java2SDK 1-41\\jre\\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.cpu.isalist=pentium i486 i386
New data read: Transport1[0.0.0.0<00>/192.168.0.200: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 49 7D 00 00 01 00 |..........I}....|

byteCount=26 but readBytesWireFormat returned 24
NodeStatusRequest[nameTrnId=1,isResponse=false,opCode=QUERY,isAuthAnswer=false,isTruncated=false,isRecurAvailable=false,isRecurDesired=false,isBroadcast=false,resultCode=0,questionCount=1,answerCount=0,authorityCount=0,additionalCount=0,questionName=*<00>,questionType=0x0021,questionClass=IN,recordName=null,recordType=0x0000,recordClass=0x0000,ttl=0,rDataLength=0]
00000: 00 01 00 00 00 01 00 00 00 00 00 00 20 43 4B 41 |............ CKA|
00010: 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAAAAAAAA|
00020: 41 41 41 41 41 41 41 41 41 41 41 41 41 00 00 21 |AAAAAAAAAAAAA..!|
00030: 00 01 |.. |

NodeStatusRequest[nameTrnId=2,isResponse=false,opCode=QUERY,isAuthAnswer=false,isTruncated=false,isRecurAvailable=false,isRecurDesired=false,isBroadcast=false,resultCode=0,questionCount=1,answerCount=0,authorityCount=0,additionalCount=0,questionName=*<00>,questionType=0x0021,questionClass=IN,recordName=null,recordType=0x0000,recordClass=0x0000,ttl=0,rDataLength=0]
00000: 00 02 00 00 00 01 00 00 00 00 00 00 20 43 4B 41 |............ CKA|
00010: 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAAAAAAAA|
00020: 41 41 41 41 41 41 41 41 41 41 41 41 41 00 00 21 |AAAAAAAAAAAAA..!|
00030: 00 01 |.. |

java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:671)
at jcifs.netbios.NameServiceClient.run(NameServiceClient.java:184)
at java.lang.Thread.run(Thread.java:536)
treeConnect: unc=\\192.168.0.200\IPC$,service=?????
sessionSetup: accountName=administrator,primaryDomain=?
SmbComSessionSetupAndX[command=SMB_COM_SESSION_SETUP_ANDX,received=false,errorCode=0,flags=0x0018,flags2=0xC003,signSeq=0,tid=0,pid=12050,uid=0,mid=2,wordCount=13,byteCount=115,andxCommand=0x75,andxOffset=176,snd_buf_size=16644,maxMpxCount=10,VC_NUMBER=1,sessionKey=0,passwordLength=24,unicodePasswordLength=24,capabilities=84,accountName=administrator,primaryDomain=?,NATIVE_OS=Windows 
XP,NATIVE_LANMAN=jCIFS]
SmbComTreeConnectAndX[command=SMB_COM_TREE_CONNECT_ANDX,received=false,errorCode=0,flags=0x0018,flags2=0x0000,signSeq=0,tid=0,pid=12050,uid=0,mid=0,wordCount=4,byteCount=49,andxCommand=0xFF,andxOffset=0,disconnectTid=false,passwordLength=1,password=,path=\\192.168.0.200\IPC$,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 12 2F 00 00 02 00 |.........../....|
00020: 0D 75 00 B0 00 04 41 0A 00 01 00 00 00 00 00 18 |.u.°..A.........|
00030: 00 18 00 00 00 00 00 54 00 00 00 73 00 DB AB 4C |.......T...s.Û«L|
00040: DA F3 DF 81 C3 B4 8C 7D BA 7A 5E 0B 57 B0 87 40 |Úóß.ô.}ºz^.W°.@|
00050: F9 7E 2D 66 A5 78 FC 28 06 72 A8 D3 EE 99 86 87 |ù~-f¥xü(.r¨Óî...|
00060: A7 70 C1 DA 1C 2B FD AD 8E 40 50 44 1B 00 61 00 |§pÁÚ.+ý­. at PD..a.|
00070: 64 00 6D 00 69 00 6E 00 69 00 73 00 74 00 72 00 |d.m.i.n.i.s.t.r.|
00080: 61 00 74 00 6F 00 72 00 00 00 3F 00 00 00 57 00 |a.t.o.r...?...W.|
00090: 69 00 6E 00 64 00 6F 00 77 00 73 00 20 00 58 00 |i.n.d.o.w.s. .X.|
000A0: 50 00 00 00 6A 00 43 00 49 00 46 00 53 00 00 00 |P...j.C.I.F.S...|
000B0: 04 FF 00 00 00 00 00 01 00 31 00 00 5C 00 5C 00 |.ÿ.......1..\.\.|
000C0: 31 00 39 00 32 00 2E 00 31 00 36 00 38 00 2E 00 |1.9.2...1.6.8...|
000D0: 30 00 2E 00 32 00 30 00 30 00 5C 00 49 00 50 00 |0...2.0.0.\.I.P.|
000E0: 43 00 24 00 00 00 3F 3F 3F 3F 3F 00 |C.$...?????. |

New data read: Transport1[0.0.0.0<00>/192.168.0.200: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 12 2F 64 00 02 00 |.........../d...|

NetShareEnum[command=SMB_COM_TRANSACTION,received=false,errorCode=0,flags=0x0018,flags2=0xC003,signSeq=0,tid=1,pid=12050,uid=100,mid=3,wordCount=14,byteCount=46,totalParameterCount=19,totalDataCount=0,maxParameterCount=8,maxDataCount=65023,maxSetupCount=0,flags=0x00,timeout=5000,parameterCount=19,parameterOffset=90,parameterDisplacement=0,dataCount=0,dataOffset=110,dataDisplacement=0,setupCount=0,pad=0,pad1=1] 
profiles/
00000: FF 53 4D 42 25 00 00 00 00 18 03 C0 00 00 00 00 |ÿSMB%......À....|
00010: 00 00 00 00 00 00 00 00 01 00 12 2F 64 00 03 00 |.........../d...|
00020: 0E 13 00 00 00 08 00 FF FD 00 00 00 00 88 13 00 |.......ÿý.......|
00030: 00 00 00 13 00 5A 00 00 00 00 00 00 00 2E 00 00 |.....Z..........|
00040: 5C 00 50 00 49 00 50 00 45 00 5C 00 4C 00 41 00 |\.P.I.P.E.\.L.A.|
00050: 4E 00 4D 00 41 00 4E 00 00 00 00 00 57 72 4C 65 |N.M.A.N.....WrLe|
00060: 68 00 42 31 33 42 57 7A 00 01 00 FF FD |h.B13BWz...ÿý |

New data read: Transport1[0.0.0.0<00>/192.168.0.200:445]
00000: FF 53 4D 42 25 00 00 00 00 88 01 C0 00 00 00 00 |ÿSMB%......À....|
00010: 00 00 00 00 00 00 00 00 01 00 12 2F 64 00 03 00 |.........../d...|

ShareInfo1[netName=profiles,type=0x0000,remark=Network Profiles Service]
ShareInfo1[netName=users,type=0x0000,remark=All users]
ShareInfo1[netName=test”„?,type=0x0000,remark=All users]
ShareInfo1[netName=012345678912,type=0x0000,remark=All users]
ShareInfo1[netName=groups,type=0x0000,remark=All groups] users/ test”„?/ 
012345678912/ groups/ IPC$/ ADMIN$/
result should be testöäü
7 files in 7060ms

ShareInfo1[netName=IPC$,type=0x0003,remark=IPC Service (Samba 
3.0.12-5-SUSE)]
ShareInfo1[netName=ADMIN$,type=0x0003,remark=IPC Service (Samba 
3.0.12-5-SUSE)]


I also tried:
System.setProperty( "jcifs.encoding", "Cp1252" ); // gives test”„?
System.setProperty( "jcifs.encoding", "ISO8859_1" ); // gives test???
System.setProperty( "jcifs.encoding", "UTF8" ); // gives test???
System.setProperty( "jcifs.encoding", "ASCII" ); // gives test???


Maybe you can help ?

Thanks,
thomas


Michael B Allen wrote:
> On Thu, 29 Dec 2005 03:30:05 +0000 (UTC)
> Alvin Anwar <alvin_anwar at msn.com> wrote:
>
>   
>> Hi all,
>>
>> Currently I noticed there's an inconsistency error in getting the 
>> files' names for different level of shared directory. Let me elaborate 
>> first. *Please correct me if I'm wrong somewhere, it might be my mistake
>> after all*
>>
>> In JCIFS SmbFile getType() function, the shared directory is 
>> specified as
>> \\ TYPE_SERVER \ TYPE_SHARE \ TYPE_FILESYSTEM \ TYPE_FILESYSTEM ...
>>
>> Currently I'm working on using JCIFS on file servers running Windows XP
>> SP 2 Chinese version. The unstability was found when I tries to list 
>> the files using listFiles() from SmbFile class at server level
>> (TYPE_SERVER). 
>>
>> When I retrieve the name and display it in a webpage (using IntergraTUM
>> WebDisk), some of the shared directory with Chinese characters are 
>> retrieved wrongly (which makes everything a broken link). On the other 
>>     
>
> To retrieve server and share lists jCIFS uses an older "RAP" protocol
> that does not support Unicode. MSRPC is necessary to properly enumerate
> servers and shares that contain Unicode characters. We have implemented
> MSRPC via a project called Jarapac and there are example programs that
> can properly emumerate shares. But that work was never integrated before
> people moved on to other things. Currently jCIFS is in maintainence mode.
>
> But it is strange that the servers and shares are listed at all. Try the
> examples/ListFiles.java example in the JCIFS packae. One possability is
> that the server you are communicating with isn't negotiating Unicode but
> is using the OEM codeset instead. If this is the case the RAP functions
> might actually work if you change the jcifs.encoding property (see the
> Overview page of the API documentation).
>
> Mike
>
>
>   



More information about the jcifs mailing list