Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share listing on macOS (High) Sierra #129

Open
mcd2000 opened this issue Feb 28, 2018 · 8 comments
Open

Share listing on macOS (High) Sierra #129

mcd2000 opened this issue Feb 28, 2018 · 8 comments

Comments

@mcd2000
Copy link

mcd2000 commented Feb 28, 2018

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?

@hschottm
Copy link

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.

@fiasko131
Copy link

Same issue here with 10.5.9 LEOPARD

Any ideas?

Thanks

@imbokhary
Copy link

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.(NamedPipe.java:56)
W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.openPipe(SMBTransportFactories.java:99)
W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.openAndHandleStatusPipeNotAvailable(SMBTransportFactories.java:74)
W/System.err: at com.rapid7.client.dcerpc.transport.SMBTransportFactories.getTransport(SMBTransportFactories.java:58)
W/System.err: at com.samsung.android.app.networkstoragemanager.rpc.SMBjRPC.getShareList(SMBjRPC.java:49)

is there any solution ??

@imbokhary
Copy link

imbokhary commented Dec 5, 2019

@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.

@mcd2000
Copy link
Author

mcd2000 commented Dec 23, 2019

@imbokhary Could, please, at least share the patch?

@Hhcoco
Copy link

Hhcoco commented Sep 28, 2020

@imbokhary
Any ideas?

Thanks

@mreiterer
Copy link

Any update on this issue ?

@dkocher
Copy link

dkocher commented Aug 24, 2023

@imbokhary It would be great if you can share your fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants