[jcifs] Problem with DFS - including attachement :-)

Rolf Breuning Rolf.Breuning at t-online.de
Wed Apr 14 09:17:08 GMT 2004


Hello,

I just started using jcifs 0.8-2 for access to a Win2000 / WinXP based
company network.

I discovered problems when accessing files or directories on DFS drives.
Please find attached a small class which allows to reproduce the problem
using the length() method for a file. However, all methods, e.g.
listFiles() etc. seem to suffer from this problem.

The attached class shows, that the DFS information is in principle
correctly obtained. If I extract the DFS information I can easily build
a new SmbFile which allows the access. However the sendTransaction()
method seems not to be able to apply the DFS information correctely.

Special things:
- I do not use the global properties, the authentication is added to the
smb:// string
- The resolved DFS reference points to the same server as originally
accessed, but uses another share name:
  //server1/share1/dir1/dir2/   ->   //server1/share2/

Kind regards

  Rolf

-------------- next part --------------
/*
 * SmbTest.java
 *
 * Created on 14. April 2004, 10:44
 */

import jcifs.smb.*;

/**
 *
 * @author  abreuol
 */
public class SmbTest {
    
    /** Creates a new instance of SmbTest */
    public SmbTest() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        // the smb url points to a file on an dfs directory
        SmbFile smb = new SmbFile( "smb://mydomain;myuser:mypassword@server/share/dir1/dir2/file.txt" );
        
        // at this point dfsReferral = null 
        System.out.println( smb.exists() );
        // now dfsReferral != null, points to correct server and share (in this particular case on the same server)
        System.out.println( "dfspath=" + smb.getDfsPath() );

        // In principal dfs information is available: I can use the information to create a new new smb file and successfully access the file
        String orgStart = smb.getPath().split("@")[0] + "@"; // take from original smb path everything used for authentication
        String dfsPath = smb.getDfsPath();
        dfsPath = dfsPath.substring( dfsPath.indexOf( "//" )+2 ); // take from dfs everything after smb://
        SmbFile smb2 = new SmbFile( orgStart + dfsPath );
        System.out.println( smb2.length() ); // will return the correct length
        
        // However, the access using the original smb file always fails
        System.out.println( smb.length() );
        /* jcifs.smb.SmbException: File not found
                at jcifs.smb.SmbTransport.sendTransaction(SmbTransport.java:915)
                at jcifs.smb.SmbSession.sendTransaction(SmbSession.java:96)
                at jcifs.smb.SmbTree.sendTransaction(SmbTree.java:70)
                at jcifs.smb.SmbFile.sendTransaction(SmbFile.java:583)
                at jcifs.smb.SmbFile.queryPath(SmbFile.java:1061)
                at jcifs.smb.SmbFile.length(SmbFile.java:1936)
        */

        
    }
    
}


More information about the jcifs mailing list