Node-SMB / marsaud-smb2

SMB2 Client
53 stars 46 forks source link

How to check if cifs is connected or not? #72

Closed azamsolix closed 3 years ago

azamsolix commented 3 years ago

// create an SMB2 instance var smb2Client = new SMB2({ share: '\\10.2.153.109', domain: 'Domain', username: 'abcb2', password: '**!', }); I am getting error stating the share is not valid

What is mean by share? Could you please help me with this?

vdiez commented 3 years ago

a samba share consists of the host and the sharename. share attribute should be of the form \\\\hostname\\sharename

azamsolix commented 3 years ago

Thank you ! Just an confirmation sharename is nothing but path,right?

vdiez commented 3 years ago

no, there is a share and inside it there are paths. you connect to a share, once connected you can access to its root path \

azamsolix commented 3 years ago

Thank you so much for your help @vdiez Could you please help me with some sample code how can i access root path? Thanks Azam

vdiez commented 3 years ago

you have code examples in the main README of the package:

// load the library
var SMB2 = require('@marsaud/smb2');

// create an SMB2 instance
var smb2Client = new SMB2({
  share: '\\\\000.000.000.000\\c$',
  domain: 'DOMAIN',
  username: 'username',
  password: 'password!',
});

read contents from root dir:

smb2Client.readdir('\\', function(err, files) {
  if (err) throw err;
  console.log(files);
});
azamsolix commented 3 years ago

Yes,I understood. My question is how i can get rootpath? Thanks Azam

vdiez commented 3 years ago

what do you mean by rootpath? the root path of the share is always \

azamsolix commented 3 years ago

Hi, I am getting error after providing all the credentials

Error: STATUS_LOGON_FAILURE (0xC000006D) : The attempted logon is invalid. This is either due to a bad username or authentication information. at SMB2Forge.request (E:\REST-API-with-Nodejs\Back end\node_modules\@marsaud\smb2\lib\tools\smb2-forge.js:22:15) at E:\REST-API-with-Nodejs\Back end\node_modules\@marsaud\smb2\lib\tools\smb2-connection.js:114:11 at Object. (E:\REST-API-with-Nodejs\Back end\node_modules\@marsaud\smb2\lib\tools\message.js:15:15) at Socket. (E:\REST-API-with-Nodejs\Back end\node_modules\@marsaud\smb2\lib\tools\smb2-forge.js:71:31) at Socket.emit (events.js:210:5) at addChunk (_stream_readable.js:309:12) at readableAddChunk (_stream_readable.js:290:11) at Socket.Readable.push (_stream_readable.js:224:10) at TCP.onStreamRead (internal/stream_base_commons.js:182:23) { messageName: 'session_setup_step2', params: {}, message: 'STATUS_LOGON_FAILURE (0xC000006D) : The attempted logon is invalid. This is either due to a bad username or authentication information.', code: 'STATUS_LOGON_FAILURE'

I checked smbclient object and found out connected property is false.But,I am providing all the details correct. Could you please help me with this? Thanks Azam