bchelli / node-smb2 Goto Github PK
View Code? Open in Web Editor NEWSMB2 Client
SMB2 Client
Whenever I try to access a smb server with credentials it does not work. I'm doing:
var smb2Client = new SMB2({
share: "\10.0.1.45\Test",
domain: 'WORKGROUP',
username: 'correct_username',
password: 'correct_password'
});
It always show the same error
[Error: STATUS_LOGON_FAILURE (0xC000006D) : The attempted logon is invalid. This is either due to a bad username or authentication information.]
But, if I remove the smb server password and to try access it, it works.
Any help?
I can login with any domain or without domain using other linux smb2 client
Error Message:
Error: STATUS_LOGON_FAILURE (0xC000006D) : The attempted logon is invalid. This is either due to a bad username or authentication information.
at SMB2Forge.request (D:\workspace\webpack-template\node_modules\@marsaud\smb2\lib\tools\smb2-forge.js:22:15)
at D:\workspace\webpack-template\node_modules\@marsaud\smb2\lib\tools\smb2-connection.js:114:11
at Object.<anonymous> (D:\workspace\webpack-template\node_modules\@marsaud\smb2\lib\tools\message.js:15:15)
at Socket.<anonymous> (D:\workspace\webpack-template\node_modules\@marsaud\smb2\lib\tools\smb2-forge.js:71:31)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
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'
Would be great if it was possible to have a way to automatically discover smb shares on the network.
Got this message when trying to connect to smb service that I don't have access to
The code so far
smb2Client = new SMB2Original({
share: '\\\\00.00.00.00\\abc_export$',
domain: 'domain',
username: 'user',
password: 'pwd',
});
smb2Client.readdir('.', (err, files) => {
if (err) throw err;
console.log(files);
});
Error object:
{
"errorType": "Error",
"errorMessage": "STATUS_NOT_SUPPORTED (0xC00000BB) : The request is not supported.",
"code": "STATUS_NOT_SUPPORTED",
"stack": [
"Error: STATUS_NOT_SUPPORTED (0xC00000BB) : The request is not supported.",
" at Object.01000000 (/var/task/node_modules/smb2/lib/tools/message.js:25:21)",
" at Socket.<anonymous> (/var/task/node_modules/smb2/lib/tools/smb2-forge.js:72:31)",
" at Socket.emit (events.js:315:20)",
" at addChunk (internal/streams/readable.js:309:12)",
" at readableAddChunk (internal/streams/readable.js:284:9)",
" at Socket.Readable.push (internal/streams/readable.js:223:10)",
" at TCP.onStreamRead (internal/stream_base_commons.js:188:23)"
]
}
I've made what would be the most trivial example of the rename
function. After running the example, the file is created but it has zero bytes of data.
The example:
const SMB2 = require('smb2')
const { buildPath } = require('./jobs/util/smb-client')
const c = new SMB2({
share: process.env.NETWORK_DRIVE_SHARE,
domain: process.env.NETWORK_DRIVE_DOMAIN,
username: process.env.NETWORK_DRIVE_USERNAME,
password: process.env.NETWORK_DRIVE_PASSWORD,
autoCloseTimeout: 0
})
const workFilePath = buildPath('CodeImport', 'Work', 'test')
const wipFilePath = buildPath('CodeImport', 'WIP', 'test')
c.rename(workFilePath, wipFilePath, (err) => {
if (err) {
console.error(err)
}
c.close()
})
Currently the lib offers to read and write files or folders.
It would be cool to have an out-of-the-box copy feature. I guess one can have it by using current code (maybe) but that would still be pretty cool. If not, having a documented example may help.
Error: STATUS_ACCESS_DENIED (0xC0000022) : {Access Denied} A process has requested access to an object but has not been granted those access rights.
at Object.03000000 (/Applications/MAMP/htdocs/pdfviewver/node_modules/smb2/lib/tools/message.js:25:18)
at Socket.<anonymous> (/Applications/MAMP/htdocs/pdfviewver/node_modules/smb2/lib/tools/smb2-forge.js:72:31)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:531:20)
Node version: v4.4.5
npm version: 2.15.5
OS: OSX 10.10.4 Yosemite
I am not able to understand the issue here. Is the process node don't have proper rights or something else is messed up? I am sure about username password and domain values. I have tried this command as a super user as well.
Here is my code
var SMB2 = require('smb2');
var smb2Client = new SMB2({
share:'\\\\10.72.211.34\\Books\\'
, domain:'domainname'
, username:'username'
, password: process.env.PASS
// , debug: true
});
smb2Client.readdir('', function(err, files){
if(err) throw err;
console.log(files);
});
This is the additional output using debug true.
--request
fe534d42400000000000000000007e0000000000000000000000000000000000fdad5baa0000000000000000000000000000000000000000000000000000000024000200010000000000000000000000000000000000000000000000000000000000000002021002
--response
fe534d4240000000000000000000010001000000000000000000000000000000fdad5baa0000000000000000000000000000000000000000000000000000000041000300100200004d290ae5432f5b42982205cd9579146607000000000010000000100000001000f479d3b320c6d10123fa0d8374c5d10180007800204c4d20607606062b0601050502a06c306aa03c303a060a2b06010401823702021e06092a864882f71201020206092a864886f712010202060a2a864886f71201020203060a2b06010401823702020aa32a3028a0261b246e6f745f646566696e65645f696e5f5246433431373840706c656173655f69676e6f7265
--request
fe534d42400000000000000001007e0000000000000000000100000000000000fdad5baa000000000000000000000000000000000000000000000000000000001900000101000000000000005800350000000000000000004e544c4d535350000100000003b20000090009002c0000000c000c002000000031302e37312e3232382e333443484547472e434f4d
--response
fe534d4240000000160000c00100210001000000000000000100000000000000fdad5baa000000000d0000b80004000000000000000000000000000000000000090000004800d0004e544c4d53535000020000000a000a003800000005828102c466cd8093361cd000000000000000008e008e00420000000601b01d0000000f4300480045004700470002000a004300480045004700470001001400440045004c00480049002d00440043003000320004001200630068006500670067002e0063006f006d0003002800640065006c00680069002d0064006300300032002e00630068006500670067002e0063006f006d0005001200630068006500670067002e0063006f006d000700080055dbd5b320c6d10100000000
--request
fe534d42400000000000000001007e0000000000000000000200000000000000fdad5baa000000000d0000b800040000000000000000000000000000000000001900000101000000000000005800b80000000000000000004e544c4d5353500003000000180018008800000018001800a000000012001200400000001e001e0052000000180018007000000000000000b800000001820000430048004500470047002e0043004f004d00700068006100720074006900790061006c00700061006e006b0061006a00310030002e00370031002e003200320038002e003300340040185fd01157ea7ada0f7555c808341eef4f141d03f40c4beac983a6f0f70a0030bdb65399ce9d5d4feff37e5a1b4eee
--response
fe534d4240000000000000000100210009000000000000000200000000000000fdad5baa000000000d0000b8000400002ed7656fb8cbdfebb3dec750368605c50900000048000000
--request
fe534d42400000000000000003007e0000000000000000000300000000000000fdad5baa000000000d0000b800040000000000000000000000000000000000000900000048002a005c005c00310030002e00370031002e003200320038002e00330034005c0042006f006f006b0073005c00
--response
fe534d4240000000220000c00300210001000000000000000300000000000000fdad5baa000000000d0000b8000400000000000000000000000000000000000009000000000000005c
Hello
I found your smb2 is convenient.
But I have a issue with remove file
my folder: "dev"
my file: "89b775f5-10c2-49d3-8b2c-c76000dad5bc.jpeg" ( existed)
I tried to remove file follow:
smb2Client.unlink("dev\\89b775f5-10c2-49d3-8b2c-c76000dad5bc.jpeg", function (err) {
if (err) {
console.log(err);
next(err);
}
console.log("file has been deleted");
return next();
});
But I got a error message: "File does not exists."
I used smb2 "exists":
smb2Client.exists(`dev\\89b775f5-10c2-49d3-8b2c-c76000dad5bc.jpeg`, function (err, exists) {
if (err) {
console.log(err);
next(err);
}
console.log(exists ? "it's there" : "it's not there!");
return next();
});
But I got the same message, too.
Please help me check it!
Thanks for support!!!
Hello - thanks for providing this library.
Will it be possible to add an api to help get all file attributes e.g. created date, author, updated dates etc.
The example has it connecting to the c$
drive at the end of the share url. When on my desktop computer I connect to the network share with smb://<server-url>
followed by the folder path without specifying any drive. Is there a way to only have to specify those connection options with this library?
I am able to access the files using readdir but readFile is giving error
Code Used --
// load the library
var SMB2 = require('smb2');
// create an SMB2 instance
var smb2Client = new SMB2({
share:'\\\\<server>\\share$'
, domain:'<mydomain>'
, username:'<myusername>'
, password:'<mypassword>'
});
smb2Client.readdir('classS1\Files', function(err, files){
if(err) throw err;
console.log(files)
for (var i=0;i<10;i++)
{
smb2Client.readFile('classS1\\Files\\'+files[i], function(err, data){
if(err) throw err;
console.log(data)
});
}
Error --
Error: STATUS_ACCESS_DENIED (0xC0000022) : {Access Denied} A process has requested access to an object but has not been granted those access rights.
at Object.08000000 (c:\Anil\Test4SMB2\node_modules\smb2\lib\tools\message.js:25:21)
at Socket. (c:\Anil\Test4SMB2\node_modules\smb2\lib\tools\smb2-forge.js:72:31)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)
at readableAddChunk (_stream_readable.js:253:11)
at Socket.Readable.push (_stream_readable.js:211:10)
at TCP.onread (net.js:587:20)
I could connect to shared folder with smb2, doing readdir/readFile/writeFile ..etc all correctly.
But could smb2 save images like fs.writeFile?
My fs code : fs.writeFile("./public/images/imgFromNode.jpg", imgData, "binary", function (err) { ...
When I change fs.writeFile
to smb2Client.writeFile
, it could write jpg file into my path, but the file can't be open, the File size is also different.
What have I done wrong? Thanks
Hi there.
I've got error "Error: Invalid key length" after exectuing code below on Windows 10
var smb2Client = new smb2(config.smb); //valid config.smb
smb2Client.readdir('USB3\Lang', function (err, Data) {
if (err)
return cb(err);
//cb(null,exists ? "it's there" : "it's not there!");
console.log(Data);
});
And here is error stack:
crypto.js:190
this._handle.initiv(cipher, toBuf(key), toBuf(iv));
^
Error: Invalid key length
at Error (native)
at new Cipheriv (crypto.js:190:16)
at Object.Cipheriv (crypto.js:188:12)
at D:\Workspace\Eclipse\BeorgBot\node_modules\ntlm\lib\smbhash.js:47:22
at Array.forEach (native)
at lmhashbuf (D:\Workspace\Eclipse\BeorgBot\node_modules\ntlm\lib\smbhash.js:45:20)
at Object.encodeType3 (D:\Workspace\Eclipse\BeorgBot\node_modules\ntlm\lib\ntlm.js:106:3)
at Object.module.exports.message.generate (D:\Workspace\Eclipse\BeorgBot\node_modules\smb2\lib\messages\session_setup_step2.js:20:23)
at SMB2Forge.request (D:\Workspace\Eclipse\BeorgBot\node_modules\smb2\lib\tools\smb2-forge.js:20:24)
at D:\Workspace\Eclipse\BeorgBot\node_modules\smb2\lib\tools\smb2-connection.js:101:12
at Object.01000000 (D:\Workspace\Eclipse\BeorgBot\node_modules\smb2\lib\tools\message.js:20:15)
at Socket. (D:\Workspace\Eclipse\BeorgBot\node_modules\smb2\lib\tools\smb2-forge.js:72:31)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:177:18)
at Socket.Readable.push (_stream_readable.js:135:10)
at TCP.onread (net.js:542:20)
I cannot get this module to connect to my samba server using the code as advised in the documentation:
// load the library
var SMB2 = require('smb2');
// create an SMB2 instance
var smb2Client = new SMB2({share: "\\\\192.168.1.6\\media",
domain: '',
username: 'user_not_shown',
password: 'real_passworn_not_shown',
debug: true,
autoCloseTimeout: 0
});
smb2Client.readdir('Docos\\SMB_Test\\Adult', function(err, data){
if(err) {
console.log("Error (readdir):\n", err);
console.log("data", data);
} else {
console.log("Connection made.");
console.log(data);
}
});
--request
fe534d42400000000000000000007e0000000000000000000000000000000000d2e24ba20000000000000000000000000000000000000000000000000000000024000200010000000000000000000000000000000000000000000000000000000000000002021002
Please assist.
This is my first post - apologies if the format or content is ambiguous/unclear.
Hello,
Is it possible to use this module to enumerate shares on a host? Or for getting the NetBIOS name of a host by its IP?
Thanks!
Hi,
Can this be used for PROD environment or is it still in dev stage?
Thank you
I was able to write file to windows shared drive before Yasomite upgrade but not I am getting following error.I updated node and npm to the latest version but no luck
Error: STATUS_INVALID_PARAMETER (0xC000000D) : An invalid parameter was passed to a service or function.
at Object.05000000 (/node_modules/smb2/lib/tools/message.js:25:18)
at Socket. (/node_modules/smb2/lib/tools/smb2-forge.js:72:31)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
Are there any plans for implementing createReadStream and createWriteStream (they would be helpful when dealing with large files)? If welcomed I could work on a pull request for this.
I noticed that there is an old closed issue #9 opened in 2015 which resulted in a fork of this project to Node-SMB / marsaud-smb2. Are these projects likely to merge?
I am opening the connection to the server, checking for a file (smb2Client.exists), reading another file from the share (smb2Client.readFile), then doing some work that can take 30 seconds or more, then writing the file back to the share (smb2Client.createWriteStream) piped from a readStream
I previously had this working without issue until I ran into the timeouts. I set the autoCloseTimeout to 0 and tried to use the smb2Client.close in the writeStream.on('finish') but it throws an error after writing the file
TypeError: Cannot read property 'FileId' of undefined (node_modules/@marsaud/smb2/lib/messages/close.js:14:24)
the file is written properly but how can I solve the error thrown and close the connection properly?
I'm using node-smb2 on OSX and have run into an issue where I'm unable to connect due to an EALREADY error being thrown. I was able to connect previously, but after connecting to the same share with the OSX Finder, I've been receiving this error:
{ Error: connect EALREADY 10.10.17.83:445 - Local (172.19.0.2:40404)
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at internalConnect (net.js:971:16)
at GetAddrInfoReqWrap.emitLookup [as callback] (net.js:1106:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
code: 'EALREADY',
errno: 'EALREADY',
syscall: 'connect',
address: '10.10.17.83',
port: 445 }
The volume has been unmounted from my OSX filesystem. I've removed any references in the Finder to the share. Also, running smbutil statshares -a
shows an empty table.
I don't believe this is an issue with the node-smb2 but would appreciate any help in troubleshooting. Thanks!
I wrote the following code to connect and read a directory.
var SMB2 = require('smb2');
var smb2Client = new SMB2({
share:'\\\\foo\\bar\\'
, domain:'domain.name'
, username:'username'
, password:'password'
});
smb2Client.readdir('dir_name', function(err, files){
if(err) throw err;
console.log(files);
});
But it throws the following error, although I am sure my password is correct.
Error: STATUS_WRONG_PASSWORD (0xC000006A) : When trying to update a password, this return status indicates that the value provided as the current password is not correct.
at Object.02000000 (/Users/foo/node_modules/smb2/lib/tools/message.js:25:18)
at Socket.<anonymous> (/Users/foo/node_modules/smb2/lib/tools/smb2-forge.js:72:31)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:536:20)
I have implemented the same code using JCIFS library in Java, with the same credentials and it works perfectly.
I'm trying to read a bunch of files in parallel, but concurrent access seems to cause problems.
With following code one could test: set up the options for your share, and adapt the files array. With just one item in the array, all works fine, with more than one I get 'connect EINVAL'.
var smb2 = require('smb2');
var options = {
share: '***',
domain: '',
username: '***',
password: '***',
autoCloseTimeout: 0
};
var files = ['file1', 'file2'];
smbclient = new smb2(opts);
var readyCounter = files.length;
for(var i in files){
//get the file
(function(index){
try{
smbclient.readFile(files[index], {encoding: null}, function(err, data){
if(err){
console.log('Error reading file ' + files[index] + ': ' + err.message);
} else {
//data contains the raw data from the file --> parse it
parse(index, data);
readyCounter--;
if(readyCounter == 0){
console.log('ALL FILES READ');
smbclient.close();
}
}
});
} catch(e){
console.log(e);
}
})(i);
}
function parse(index, data){
console.log('file ' + index + ' ready');
}
Am getting ECONNRESET Issue while connecting the network folder with error no -4077
Is it possible to browserify the module or make it nodejs independend so it can be used in hybrid apps on smartphone-devices?
I am trying to connect to an internal smb-share:
const client = new SMB2({
share:"\\\\172.16.0.76\\rw",
username:"*USER*",
password:"*PASS*",
domain:"DOMAIN",
autoCloseTimeout:0
});
I can connect to that share from the host using windows tools,
but instantly getting following message:
TypeError: cb.apply is not a function
Hi,
The ability to stream through your client would be great, and usefull.
if mod here
"node_modules/ntlm/lib/smbhash.js:26:11"
inputstr? inputstr.substring(0, 14).toUpperCase() : '';
and add here
"node_modules/ntlm/lib/smbhash.js:61:28"
|| ""
return correct Error :)
tnx for your BIG work
If you try to get the files in a directory that has say more than 500 hundred files you won't get the complete list. The main issue is the buffer size that is 65K.
var Smb = require('smb2');
var client = new Smb({
share: '\\\\1.2.3.4\\Shared Folder',
domain: 'BlaBla',
username: '',
password: ''
});
client.readdir('subfolder', function (err, files) {
if (err) return new Error(err);
//error is null
console.log(files);
//the console output true list of files
//after this line process does not finishing
//it continues work about 5 seconds
});
If call more functions(ex. readdir,readfile and etc.) then work continues will be longer.
after migrating to node.js 6 we get an uncaught exception by using this module.
the stacktrace ...
Error: Invalid key length',
' at Error (native)',
' at new Cipheriv (crypto.js:184:16)',
' at Object.Cipheriv (crypto.js:182:12)',
' at makeResponse (/home/mithrandir/dev/node/node_modules/ntlm/lib/ntlm.js:212:22)',
' at Object.encodeType3 (/home/mithrandir/dev/node/node_modules/ntlm/lib/ntlm.js:112:13)',
' at Object.module.exports.message.generate (/home/mithrandir/dev/node/node_modules/smb2/lib/messages/session_setup_step2.js:20:23)',
' at SMB2Forge.request (/home/mithrandir/dev/node/node_modules/smb2/lib/tools/smb2-forge.js:20:24)',
' at /home/mithrandir/dev/node/node_modules/smb2/lib/tools/smb2-connection.js:101:12',
' at Object.01000000 (/home/mithrandir/dev/node/node_modules/smb2/lib/tools/message.js:20:15)',
' at Socket. (/home/mithrandir/dev/node/node_modules/smb2/lib/tools/smb2-forge.js:72:31)',
' at emitOne (events.js:96:13)',
' at Socket.emit (events.js:188:7)',
' at readableAddChunk (_stream_readable.js:172:18)',
' at Socket.Readable.push (_stream_readable.js:130:10)',
' at TCP.onread (net.js:535:20)
with node.js 5.11 it worked fine.
Hi,
I hope you're doing well.
I have a question.
Is there any method or any way to get current working directory?.
Thanks
Azam
I'm able to read share directory via explorer, I can also do create, update or delete via windows explorer as well.
I'm able to connect to a share, read directory via this module but I get STATUS_ACCESS_DENIED (0xC0000022) : {Access Denied} A process has requested access to an object but has not been granted those access rights, although I have all required permissions.
if you guys are facing this kind of problem try switching to https://www.npmjs.com/package/v9u-smb2 instead
I have been trying to use smb2 to create a new folder on remote.
I am not sure what 'path' is suppose to hold (absolute path on share, relative path to share, ...)
Imagine this
const smb2Client = new SMB2({
share:'\\\\ip.ip.ip.ip\\c$\\shareFolder',
domain:'ME',
username:'my',
password:'1234'
});
Then if I want to create 'plop' under 'shareFolder' what should I wrote?
I tried
smb2Client.mkdir('plop'
smb2Client.mkdir('.\plop'
smb2Client.mkdir('.\\plop'
smb2Client.mkdir('\\\\ip.ip.ip.ip\\c$\\shareFolder\\plop'
None seems to work.
Could you tell me if I'm doing this wrong?
Hi,
I would like to have more information about files and folders, like the timestamps, if it's a file or folder, etc.
Thank you!
I'm working on something that's going to be copying a large file from one Windows machine to another. The code I have looks like this:
function copyFileFromSourceToDestination(source, destination, on_success, on_error) {
try {
var source_smb = new smb2({
share: '\\\\' + source.ip + '\\c$',
domain: 'WORKGROUP',
username: source.username,
password: source.password
});
destination_smb = new smb2({
share: '\\\\' + destination.ip + '\\c$',
domain: 'nonayoarbiziniz',
username: destination.username,
password: destination.password
});
source_smb.exists('largefiles\\' + kSourceFileName, function(err, exists) {
if(err) {
return on_error(err);
}
if(!exists) {
return on_error('File not found on source');
}
source_smb.readFile('largefiles\\' + kSourceFileName, {'encoding': null}, function(err, data) {
if(err) {
return on_error(err);
}
console.log(data);
destination_smb.writeFile('Users\\' + destination.username + '\\AppData\\Local\\Temp\\' + kSourceFileName, data, {'encoding': null}, function(err) {
if(err) {
return on_error(err);
}
return on_success();
});
});
});
} catch(e) {
return on_error(e);
}
}
The result of the above function is on_success being called inside writeFile, but when I look at the file created on the destination machine, it was zero bytes. Once I saw that, I checked to make sure there was data being provided from the readFile callback, and there wasn't, only an empty buffer. However, there was no error message either which I thought was a bit odd. The file was there on the source machine, I know that because I checked myself and also we're doing the exists check at the beginning of the function.
I also took a second to throw a console.log(fileLength) in smb2/lib/api/readfile.js to make sure it was sensible; the result of it seemed a bit odd: -443374080. However, I did see that there was some bit masking in the code above it, so I don't know if that's just how the samba protocol worked. The file size that I see in Windows explorer is: 3,916,604,928 bytes. Not sure if that makes a difference, but it jumped out at me.
The next thing I tried was to dump the contents of file.EndofFile on line 39 to see what that was. The result was:
<Buffer 00 a6 e2 e5 00 00 00 00>
Anyway, I'm hung up on this and it's the last thing standing between me and finishing this project so I thought I'd throw a bug up here to see if you'd be able to help with it.
Thanks a lot and nice project ๐
Christopher Dale
I got an error using smb2: ECONNRESET
Here is the end of the log
{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
-- error
{ '0': { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' } }
My config is:
var smb2Client = new SMB2({
share:'\\\\MYHOSTNAME\\MYSHARE'
, domain:'MYDOMAIN'
, username:'MYUN'
, password:'MYPWD'
, debug: true
, autoCloseTimeout: 0
});
Any idea where to start looking?
PS: My folder have more than 20000 files.
const smb2 = require('smb2');
let smb2Client = new smb2({
share: '\\\\my-fs\\Projects$',
domain: 'my.own.domain',
username: 'myusername',
password: 'mypassword'
});
smb2Client.readdir('Downloads\\Yankee', (err, files) => {
if (err) throw err;
console.log(files);
});
This code alone throws the error:
Error: STATUS_INVALID_PARAMETER (0xC000000D) : An invalid parameter was passed to a service or function.
at Object.04000000 (D:\Developer\simpleProject\node_modules\smb2\lib\tools\message.js:25:18)
at Socket.<anonymous> (D:\Developer\simpleProject\node_modules\smb2\lib\tools\smb2-forge.js:72:31)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
What am I doing wrong?
I cant shake the error when using smb2 in its most basic form:
Error reading SMB directory: Error: STATUS_INVALID_PARAMETER (0xC000000D) : An invalid parameter was passed to a service or function.
I know this works because I can use the samba-client (smbclient) and connect, ls, etc... so the credentials works.
I am puzzled...
Here is the code. Thank you for any clue... (I hope this is a not a dead thread before it even starts...). Hope you can help.
const SMB2 = require('smb2');
// SMB2 Configuration
const smbConfig = {
share: "\\MY_IP\ShareName",
domain: "", // Leave empty if no domain
username: "user_hidden",
password: "password_hidden",
};
// Create SMB2 client
const smb2Client = new SMB2(smbConfig);
// Test directory path
const directoryPath = 'test_dir'; // Set to the directory path you want to test, empty for root -> empty does not work neither...
// Function to test SMB2 configuration
function testSmb2Config() {
console.log("Testing SMB2 Configuration...");
smb2Client.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading SMB directory:', err);
} else {
console.log('Directory content:', files);
}
});
}
// Run the test
testSmb2Config();
pretty basic...
Hi,
I'm using v9u-smb2 library in nodejs and trying to access shared folder , my Linux doesn't have a domain
I'm trying to access like that :
share: '\172.18.196.24\samba3_directory',
domain: 'WORKGROUP',
username: 'pmc',
password: 'password' // the real password
I got this error :
STATUS_LOGON_FAILURE (0xC000006D) : The attempted logon is invalid. This is either due to a bad username or authentication information.
at SMB2Forge.request (/home/pmc/tmp/barak/node-smb/node_modules/v9u-smb2/lib/tools/smb2-forge.js:39:15)
at /home/pmc/tmp/barak/node-smb/node_modules/v9u-smb2/lib/tools/smb2-connection.js:108:11
What can be the problem? this library can work with Linux? Except from samba that I installed on Linux and create shared folder , do I need to configure something else?
from other Linux I can access to this shared folder by write on terminal : smbclient \172.18.196.24\samba3_directory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.