Trying to read files from Azure Netapps (Network Drive). We successfully mount and read files with Window File Explorer.
With the same credentials, we are trying with JAVA smbj library.
While executing the java code in eclipse, getting following error,
com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Could not connect to \\AZUREANF.com\imagestorage
.
.
Suppressed: com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Error closing connection to \\AZUREANF.com\IPC$
The complete logs...
[main] INFO com.hierynomus.smbj.connection.PacketEncryptor - Initialized PacketEncryptor with Cipher << AES_128_GCM >>
[main] INFO com.hierynomus.smbj.connection.Connection - Successfully connected to: AZUREANF.com
[main] INFO com.hierynomus.smbj.connection.SMBSessionBuilder - Successfully authenticated TWSpringvale on AZUREANF.com, session is 3250754506031368179
[main] INFO com.hierynomus.smbj.session.Session - Connecting to \\AZUREANF.com\imagestorage on session 3250754506031368179
[main] INFO com.hierynomus.smbj.paths.DFSPathResolver - Attempting to resolve \\AZUREANF.com\imagestorage through DFS
[main] INFO com.hierynomus.smbj.paths.DFSPathResolver - Starting DFS resolution for \\AZUREANF.com\imagestorage
[main] INFO com.hierynomus.smbj.session.Session - Connecting to \\AZUREANF.com\IPC$ on session 3250754506031368179
[main] INFO com.hierynomus.smbj.session.Session - Logging off session 3250754506031368179 from host AZUREANF.com
[main] INFO com.hierynomus.smbj.connection.Connection - Closed connection to AZUREANF.com
[Packet Reader for AZUREANF.com] INFO com.hierynomus.smbj.transport.tcp.direct.DirectTcpPacketReader - Thread[Packet Reader for AZUREANF.com,5,main] stopped.
com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Could not connect to \\AZUREANF.com\imagestorage
at com.hierynomus.smbj.session.Session.connectTree(Session.java:151)
at com.hierynomus.smbj.session.Session.connectShare(Session.java:113)
at Reader.NetworkFilereader(Reader.java:70)
at Reader.main(Reader.java:129)
Suppressed: com.hierynomus.mssmb2.SMBApiException: STATUS_ACCESS_DENIED (0xc0000022): Error closing connection to \\AZUREANF.com\IPC$
at com.hierynomus.smbj.share.TreeConnect.close(TreeConnect.java:72)
at com.hierynomus.smbj.share.Share.close(Share.java:116)
at com.hierynomus.smbj.session.Session.logoff(Session.java:236)
at com.hierynomus.smbj.session.Session.close(Session.java:279)
at com.hierynomus.smbj.connection.Connection.close(Connection.java:178)
at com.hierynomus.smbj.connection.Connection.close(Connection.java:155)
at Reader.NetworkFilereader(Reader.java:118)
... 1 more
How to resolve this issue?
Ran into the same problem using smbj-0.11.5 with Azure NetApp Files.
There seems to be an issue related to encryption negotiation between the client and the server when 3.1.1 dialect is used (https://github.com/hierynomus/smbj/issues/747).
I suggest trying any of the following workarounds:
SmbConfig.builder().withDialects(SMB2Dialect.SMB_3_0)
SmbConfig.builder().withEncryptData(true)
Both worked for me with smbj-0.11.5 and Azure NetApp Files.