Closed 151058580845 closed 3 years ago
I'm not sure I understand the question. The protocol version is negotiated, depending on what the server supports and what you have configured in smbj to be allowed. In the logging you can see which protocol was selected.
The server comes in Samba 1,2,3 versions, but I now want to know which version of Samba I'm connecting to
You can configure SMBJ to require a certain SMB Dialect. For example:
SmbConfig config = SmbConfig.builder().withDialects(SMB2Dialect.SMB_3_0).withSecurityProvider(new BCSecurityProvider()).build();
SMBClient client = new SMBClient(config);
I need to be able to connect all versions of Samba, but different versions need to be processed differently, so I want to get the connected version dynamically,thanks
This is how we log it:
log.info("Connected to {} with Samba protocol {}", remoteSourceDir.getHostname(), connection.getNegotiatedProtocol().getDialect());
Once the connection is established, you can do the following:
Connection c = client.connect(host, ip);
SMB2Dialect dialect = c.getConnectionContext().getNegotiatedProtocol().getDialect();
This will get you the dialect that the connection is using.
I used this method, but when I connected to different versions of Samba, I always got the same data
I think you're mistaken the server version vs the negotiated protocol. The server version we cannot detect. And most samba server versions accept all versions of the SMB protocol (2.0, 2.0.2, 3.x)... So that just depends on what's negotiated during the connection setup.
Maybe I made a mistake. I'm sorry to trouble you. Thank you very much
Once the connection is established, you can do the following:
Connection c = client.connect(host, ip); SMB2Dialect dialect = c.getConnectionContext().getNegotiatedProtocol().getDialect();
This will get you the dialect that the connection is using.
Has this been refactored? Because I cannot find a connection.getConnectionContext()
with latest version smbj 0.10.0...
EDIT: found it. ConnectionInfo
was renamed to ConnectionContext
...
Cool, can this be closed?
I'm currently utilizing the smbj 0.12 library for Scala. I have a question regarding the default SMB version: if I don't explicitly pass any dialect, will it default to SMBv2 or SMBv3?
How do I know the version of the connection Samba protocol