smb-enumerate-shares v1.1.4
smb-enumerate-shares
Enumeration of SMB shares for Node.js
smb-enumerate-shares provides a single function that takes a number of parameters and will return a promise with the available shares on the provided server
Install
$ npm install smb-enumerate-sharesUsage
smbEnumerateShares(options)
Retrieves the shares available on the host given in the options. The options parameter can have the following properties:
host(required) - The host to list the shares of. Can be a name or an ip address.port(optional) - The port to connect to. Defaults to 445.username(optional) - The username of an account on the server. Defaults to guestpassword(optional) - The password of the account. Defaults to emptydomain(optional) - The SMB NT domain. Defaults to WORKGROUPtimeout(optional) - The length of time in milliseconds the connection will wait for a response from the server. Defaults to 5000
Options may also be an SMB connection url string of the following format:
smb://[[<domain>;]<username>[:<password>]@]<host>[:<port>][/<path>]
This returns a promise resolving in an array of share objects. Each object has the following properties:
name- The name of the sharehidden- Whether this share is tagged as hidden. These shares normally end in a dollar signtemporary- Whether this share is marked as temporarycomments- Comments on this share set by the servertype- The share type which is one of the following:"DISK_TREE","PRINT_QUEUE","COMM_DEVICE"or"IPC"
Examples
const smbEnumerateShares = require('smb-enumerate-shares')
// enumerate shares on host 'myserver'
smbEnumerateShares({host: 'myserver'})
.then(shares => {
for(let share of shares) {
console.log(share.name)
}
})
.catch(err => {
// handle an error
})
// or use the smb url syntax
smbEnumerateShares('smb://admin:hunter2@myserver/')
.then(shares => console.log(shares))Bugs & Issues
This package is designed to be small and efficient, which means it does not have proper network package parsing. Problems may occur in non-typical situations. Please report issues in the issue tracker to improve this project.