
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
The Windows NET USER command wrapped in JavaScript
NET USER
is a sub-command of the NET command line tool that is provided for shell-based
management of user accounts on Windows. If a username is specified, and no
change switches are used, it's roughly equivalent to using
getent passwd <username>
on Unix/Linux, or
id -P <username>
on macOS, then displaying formatted results. The output may not contain everything you could possibly want, but there's a lot.
The Windows command NET USER also allows administrators to create, change,
and delete user accounts. The current version of this module does not provide an
interface for that; it only retrieves information.
If you try to use this module from an under-privileged account on a system that has been security-hardened, you may see something like the following:
The command prompt has been disabled by your administrator. Press any key to continue . . .
... or you may see nothing, because the callback is never called. This means that the child process spawned by the module has been killed, and so you won't be able to get any results.
C:\Users\myUser>npm install net-user
var netUser = require('net-user')
Fetches the list of usernames for all accounts on the system, and passes it
back through the callback function.
callback: {Function}
error: {Error | null}data: {Array} array of strings, if no errorFetches the account information of the named user, and passes it back through
the callback function.
name: {string} The username.callback: {Function}
error: {Error | null} if any command error other than "No such user".data: {Object | null}name matches an account on the system, this is an object containing
all properties listed in the Field Mapping table below.name is not known by the system, this is null.Fetches the account information of every user known by the system, and passes it
back through the callback function.
callback: {Function}
error: {Error | null}dataList: {Array} in which each element is an object containing
all properties listed in the Field Mapping table below.Deprecated - use get() or list() instead.
If name supplied, becomes alias for netUser.get(name, callback).
If no name given, becomes alias for netUser.list(callback).
Deprecated. Alias for netUser.list(callback).
Deprecated. Alias for netUser.list(callback).
| `netUser()` result property | type | `NET USER` output label
|------------------------------|---------|---------------------------|
`user_name` | string | `User name`
`full_name` | string | `Full Name`
`comment` | string | `Comment`
`usr_comment` | string | `User's comment`
`country_code` | string | `Country code`
`acct_active` | boolean | `Account active`
`acct_expires` | Date | `Account expires`
`password_set` | Date | `Password last set`
`password_expires` | Date | `Password expires`
`password_changeable` | Date | `Password changeable`
`password_required` | boolean | `Password required`
`password_can_change` | boolean | `User may change password`
`workstations` | Array | `Workstations allowed`
`script_path` | string | `Logon script`
`profile` | string | `User profile`
`home_dir` | string | `Home directory`
`last_logon` | Date | `Last logon`
`logon_hours` | Array | `Logon hours allowed`
`local_groups` | Array | `Local Group Memberships`
`global_groups` | Array | `Global Group memberships`
user_name
This will be the same as the username argument given to get().
Never empty!
full_name
comment
usr_comment
If the corresponding account field is not set, the object property will be
set to undefined.
country_code
A three-digit string, or null. Refer to Microsoft documentation for the
country code mapping.
If the corresponding account field is not set, the object property usually
gets set to '000' (the corresponding value in the NET USER output is
000 (System Default)).
The string (null) has been seen for this in NET USER output; in that
case, this field is set to null.
acct_expires
password_set
password_expires
password_changeable
last_logon
Any of the Date-type fields can be set to null; that corresponds to
Never in the NET USER output.
password_set
The timestamp when the password was last successfully set.
password_changeable
Not a flag (see password_can_change for that). This is the timestamp
when the password was last found to be changeable.
(It's not clear how this is different from password_set, and the values
of the two fields have always been seen to be the same in my tests.)
workstations
If the value is null, it means the associated user is allowed to log on
from any workstation in the local domain.
(The corresponding value in the NET USER output is All.)
Otherwise the field value will be an array of workstation names, possibly
none.
script_path
profile
home_dir
Like the other string fields above, the value of these fields may be (and
usually are) undefined; but that doesn't mean there's no profile or home
directory associated with the username. It only means that the creator of
the account did not deviate from the default. If you're invested in
identifying the default root location of one of these items, then it's up
to you to find it. That's not impossible, but it varies by Windows version.
Good luck, Jim.
logon_hours
If the value is null, it means there are no restrictions on when the
associated user is allowed to be logged on.
(The corresponding value in the NET USER output is All.)
Otherwise the field value will be an array of strings specifying timespans,
possibly none.
local_groups
global_groups
The value is an array of group names, possibly none.
Those who wish to use the elements of these arrays, heed this warning:
Sometimes the group names are truncated in NET USER output.
If the user account that you query is a member of more than two groups, and
if even one of the groups has an especially long name, you will probably
have this problem.
A Windows group name can have up to 256 characters. The display space set
aside for the values in NET USER output is 44 columns, regardless of the
number of columns configured for the terminal window. More than one group
name can be displayed per line; if the first group name on a line is short,
and there are more group names, the next group name is displayed on the same
line, even if it's too long too fit in the remaining space. Furthermore,
group names are never wrapped to the next line. Result: truncation. This is
odd, because line wrapping is applied to a set of names in another field
of NET USER output (Workstations allowed), and no name is truncated there.
License: MIT
FAQs
The Windows NET USER command wrapped in JavaScript
The npm package net-user receives a total of 2 weekly downloads. As such, net-user popularity was classified as not popular.
We found that net-user demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.