Search code examples
javawindowswindows-server-2008-r2windows-server-2012samba

Why would my samba connection fail after an upgrade to windows 2012?


I have a JSP running on Tomcat 6.0.26 (windows server 2008 r2 sp1) that has a samba (jcifs-1.3.17.jar) connection to list files found on a remote server.

This worked without any problems until the AD controller was updated to Windows 2012 (fully patched).

Now, I can't list the files on the Samba Share anymore.

SmbFile sfFile = new SmbFile("smb://myserver.com/share/", "subfolder", new NtlmPasswordAuthentication("MYDOM", session.getAttribute("UserID").toString(), session.getAttribute("UserCode").toString()));
SmbFile[] asfDirectoryList = sfFile.listFiles("webversion" + session.getAttribute("PLCode").toString().substring(0,3) + "*.xls");

The second line returns following exception:

    org.apache.jasper.JasperException: jcifs.smb.SmbException: The network name cannot be found.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:407)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

    jcifs.smb.SmbException: The network name cannot be found.
    jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563)
    jcifs.smb.SmbTransport.send(SmbTransport.java:663)
    jcifs.smb.SmbSession.send(SmbSession.java:238)
    jcifs.smb.SmbTree.treeConnect(SmbTree.java:176)
    jcifs.smb.SmbFile.doConnect(SmbFile.java:911)
    jcifs.smb.SmbFile.connect(SmbFile.java:954)
    jcifs.smb.SmbFile.connect0(SmbFile.java:880)
    jcifs.smb.SmbFile.resolveDfs(SmbFile.java:669)
    jcifs.smb.SmbFile.send(SmbFile.java:773)
    jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1986)
    jcifs.smb.SmbFile.doEnum(SmbFile.java:1738)
    jcifs.smb.SmbFile.listFiles(SmbFile.java:1715)
    jcifs.smb.SmbFile.listFiles(SmbFile.java:1681)
    org.apache.jsp.financials.frFinancialsFileListing_jsp._jspService(frFinancialsFileListing_jsp.java:220)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Does anyone know why this would happen and how to fix it?

[EDIT] The mystery: Updating the AD controller to Windows 2012 should not have an effect on a webserver accessing a share on a fileserver (both of which are running windows 2008 r2 sp1). I just cannot understand that.


Solution

  • With Windows Server 2012 R2 the SMB 1.0 has been disabled by default. Therefore you need to activate the SMB 1.0 again in Windows Server 2012 R2.

    1. Open the Add Roles and Features Wizard of Windows and check if the SMB 1.0/CIFS File Shareing Support is activated: enter image description here
    2. Enable the SMB 1.0 Support by opening the Registry Editor. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer and change the value of DependOnService from SamSS Srv2 to SamSS Srv enter image description here
    3. Restart Windows

    You can verify if the support is activated by checking the properties of the system service Server (LanmanServer) in the tab Dependencies that SMB 1.xxx is also activated: enter image description here

    Source: http://woshub.com/smb-1-0-support-in-windows-server-2012-r2/#!prettyPhoto