smbj-rpc
smbj-rpc copied to clipboard
Share listing on macOS (High) Sierra
I'm trying to write an SMB2 client for Android. I need to read share list from the server. I'm doing something like this:
SmbConfig cfg = SmbConfig.builder().
withMultiProtocolNegotiate(true).
withSecurityProvider(new BCSecurityProvider()).
build();
SMBClient client = new SMBClient(cfg);
try (Connection connection = client.connect("server")) {
AuthenticationContext ac = new AuthenticationContext(username, password.toCharArray(), "WORKGROUP");
Session session = connection.authenticate(ac);
RPCTransport transport = SMBTransportFactories.SRVSVC.getTransport(session);
final ServerService serverService = new ServerService(transport);
final List<NetShareInfo0> shares = serverService.getShares0();
for (final NetShareInfo0 share : shares) {
System.out.println(share);
}
} catch (Exception e) {
}
This code works fine when connected to Windows 10 PC, but I'am constantly getting the following exception with both macOS Sierra (10.12.8) and High Sierra (10.13.3) at "getTransport" method:
com.rapid7.helper.smbj.io.SMB2Exception:
SMB2_CREATE returned STATUS_ACCESS_DENIED (3221225506/3221225506): expected=[STATUS_SUCCESS]
Is it anything I just do not understand here?
This must have to do with Apples SMBx implementation. smbj-RPC is throwing an exception when it tries to create a named pipe by sending and SMB2 create request. The response is an "Access denied" which then causes the exception.
Any workaround to this issue would be very helpful.
Same issue here with 10.5.9 LEOPARD
Any ideas?
Thanks
I'm also facing the same issue with MAC OS only. `try{ final Connection smbConnection = smbClient.connect(mAddress); final AuthenticationContext smbAuthenticationContext = new AuthenticationContext( String.valueOf(userName), passWord, String.valueOf(domain)); final Session session = smbConnection.authenticate(smbAuthenticationContext);
final RPCTransport transport = SMBTransportFactories.SRVSVC.getTransport(session);
final ServerService serverService = new ServerService(transport);
final List<NetShareInfo0> shares = serverService.getShares0();
for (final NetShareInfo0 share : shares) {
shareNameList.add(share.getNetName().toString());
Log.d(TAG, share.getNetName().toString());
}
}catch(Exception e) {
e.printStackTrace();
}`
W/System.err: com.rapid7.helper.smbj.io.SMB2Exception: SMB2_CREATE returned 3221225506 (3221225506/3221225506): expected=[STATUS_SUCCESS]
W/System.err: at com.rapid7.helper.smbj.io.SMB2SessionMessage.sendAndRead(SMB2SessionMessage.java:99)
W/System.err: at com.rapid7.helper.smbj.share.NamedPipe.
is there any solution ??
@tosmun-r7 hello, I've fixed the issue on smbj-rpc related to share listing for MAC and I've tested it on MAC, Windows and Linux too working well. Changes should be pushed on smbj-rpc.
@imbokhary Could, please, at least share the patch?
@imbokhary Any ideas?
Thanks
Any update on this issue ?
@imbokhary It would be great if you can share your fix.