Server Message Block
- [#cifs]: “Common Internet File System” (“CIFS”)
-
One of the questions, which seems most basic, is: “What do I call this thing?”
As a quick aside: “Samba” is the name of an implementation. Specifically, “Samba” is the name of software released for Unix. The protocol itself is called “SMB”, although there has also been a variation named CIFS which became known well enough that it is worth mentioning here.
The difference between CIFS and SMB and Why You Should Never Again Utter The Word, “CIFS” both tell the same story: Microsoft extended a version of SMB, which is now an old version, and named the extended version CIFS. However, Microsoft later released SMB2 (with Windows Vista... then after Windows 7, Microsoft released SMB3 with Windows 8).
Some of the extensions to CIFS may have been related to adding TCP/IP support, which souinds like a great thing. However, CIFS had some issues (like not working as well with less reliable network communications like what has become more common with wireless networking).
In reality, CIFS was not very different than SMB. SMB/CIFS indicates that there may be some difference in which TCP ports are used. However, overall the protocols were so similar that CIFS implementations and SMB implementations could effectively communicate. CIFS has been called a “dialect” of SMB.
The term CIFS is now shunned as a reference to a time when things didn't work quite as well. For instance, CIFS implementations were known to have some issues, like not working as well with the less reliable network communications that became more common when wireless networking started to become widespread. Microsoft documentation about CIFS and SMB mentions some features of CIFS.
For a while, CIFS was being treated like the newer name that used updated code. For example, Unix Stack Exchange: Huygens's response indicates that the CIFS filesystem support existed in the kernel while a command to mount SMB shares used some older code. However, CIFS is probably not the name that will be used for newer code, as newer code supports SMB2.
- Multiple versions of “Server Message Block” (“SMB”)
- (This section is still pretty unfinished...) SMB, SMB2, CIFS. Features such as signing/etc? URL discusses SMB signing
- Implementations
-
- [#samba]: Samba
-
This is software for Unix. It allows Unix systems to share folders over SMB. It also comes with an interactive client for interacting with remote shares. It does not mount remote shares so that they may be treated similar to local filesystems: doing that may require other software such as SMBFS or Sharity software.
- Setting up the server
-
Warning: UNTESTED INSTURCTIONS: These were based on vague memories and looking at an existing setup. There might be substantial steps missing. (Further testing should be performed.)
Get the Samba software package. (See the section about software installation for details about locating and installing this package.) Edit a text file, specifically the text file called
smb.conf
, which might be in/etc/samba/
(but may have been installed in some other location). There is a manual page for this file, including an online HTML version of the manual page for the smb.conf file.Check the line that says
hosts allow =
, which mentions what remote IPv4 addresses should be allowed to connect to the server. Also check the line that saysinterfaces =
which mentions what local network addresses to use to listen for relevant TCP/IP traffic.Way further down in the file, make some new shares. Make a new share. This is done by making a new line with the share's name contained inside square brackets. Set a desired comment, path, and status regarding if this share should be visible in a “public” list of shares, and whether any remote users might be allowed to write to the share's directories. One can also specify users that are allowed to log in. Here is an example:
[
sharname
];
Lines beginning with a semi-colon are ignored.
comment = Description of this share
path =
/
srv/shared/bigDir
public = yes
writable = yes
valid users =
someuser
create mask =
0755
Understand that SMB passwords have not been set at this point. However, the online HTML version of the manual page for the
command notes that this program “communicates with a locally running” copy of an SMB server. “As a consequence in order for this to succeed thesmbpasswd
daemon must be running on the local machine.” So, passwords are not going to be set before the server is running. Restrict network access as needed to make sure that isn't a security problem.smbd
Then, once the configuration file is made and any other necessary security is implemented, go ahead and start the server. Run the server,
.smbd
Also, some things may work better by then running the NetBIOS name server (after running the Server Message Block server). So, after running
, runsmbd
.nmbd
The next steps may be to make sure that SMB user accounts and passwords are set as desired, and then getting the software to run automatically. To accompish the latter step:
- Newer samba installations
-
The following was seen in OpenBSD 4.9: The following was seen when installing Samba 3.5.6 in OpenBSD 4.9: FIX!!!
The following new rcscripts were installed:
/etc/rc.d/
nmbd/etc/rc.d/
samba/etc/rc.d/
smbd/etc/rc.d/
winbinddSee rc.d(8) for details.
- Older Samba installations
-
Some information is provided in OpenBSD when running “
”. Specifically, it notes to adjust a startup script to run:pkg_info
-M sambaif
[
-x/usr/local/libexec/
smbd];
then
echo
-n' smbd'
/usr/local/libexec/
smbdfi
if [ -x
]; then/usr/local/libexec/
nmbdecho
-n' nmbd'
/usr/local/libexec/
nmbdfi
The above command lines check if the file is executable. Details on the syntax may be obtained by reviewing documentation for the
and/or theif
commands, and these commands may be implemented internal to a command line shell (and so the most applicable documentation may be in documentation for the shell that is being used).test
Details about what files are run when the operating system is started may be covered by system startup processes and/or documentation that is more specific about specific operating systems (and/or groups of similar operating systems).
If the program is not acting as expected, check the operating system logs. If that is not providing enough detail, perhaps running
with the “smbd
-F -i -d
” may provide some more information. Note that the1
program may exit after a (failed) connection attempt by a client. Also note that this causes the program to run in the foreground, instead of running in the background.smbd
If still more information is desired, increase the debugging level, by using “
-d
” (or even higher, up to “3
-d
”) may provide more insight as to what is happening. Note that using these command line parameters may cause the program to output large amounts of data (so don't be afraid to pipe the results through to the10
command).tee
- Interacting with user accounts
-
For file sharing, the Samba software may have a local database.
- Creating user accounts in Samba's database
-
To set up an SMB password for an SMB username, the online HTML version of the manual page for the
command notes that the local system's user database needs to have a local system user with that username. Details about adding such users may be at: adding users to a network.smbpasswd
The SMB server will need to be running. Follow all of the steps noted in the section about setting up the SMB server, most especially the section about making sure that security openings/vulnerabilities do not occur.
Add the user to the database of smbdatabase users by running, as root, the command: “
”sudo
smbpasswd
-a -uusername
- Changing passwords of the user accounts handled by the SMB server
-
To add a user to the database, the user account needs to exist on the local system. So, a Unix user account may need to be created prior to creating the user account in the SMB server's database. (For details how to do this, see the section about adding a user.)
To modify the database on the local machine use: “
”sudo
smbpasswd
-a -Uusername
To request that a remote server changes the password for the user, try using “
” This may work if the remote server is using Samba, or an Active Directory Primary Domain Controller (“AD PDC”).sudo
smbpasswd
-a -r
-UmachName
username
- Other actions
-
The Samba suite of programs may
maintain user accounts stored in a Samba database. The Samba server accepts
requests using network traffic (either from a remote system, or from the
loopback interface that is looping traffic originating from the local system).
Samba 2.0 and newer support disabling the user account. A program to request
that this is disabled is to use “
”. The account may be re-enabled later by using “smbpasswd
-d -Uusername
”.smbpasswd
-e -Uusername
- Supporting LANMAN passwords
-
Realize the lower level of security that this offers. However, in cases of carefully controlled network traffic (e.g. traffic sent over an encrypted tunnel), this might be tolerable. Using this password scheme may help with compatability with some clients (e.g. the client built into Windows 98, or Sharity-Light for Unix type operating systems).
To enable this, there may be a requirement to use an older style user database. Using the “smbpasswd” file format may help to cause this to work, while the tbdsam file format may result in the LANMAN passwords being NULL. To enable the older style format, place the following line in the
[global]
section:passdb backend = smbpasswd
It is likely thatsecurity = user
is already set. Also include:lanman auth = yes
Note that specifying the passdb will cause the
andsmbpasswd
commands to use the specified credential format. Any credentials stored in any other format will remain on the server, but will be ignored/unused.smbd
- Using the SMB client
-
- Listing SMB file shares
-
To see a list of publicly-shown shared folders offered by a machine, use:
smbclient
-N -L192.0.2.65
The reason for the
-N
is to skip the password prompt. The following example output show an alternative to automate this: Using “
” is used to provide a blank password to theecho
|
prompt.Password:
Password:
Anonymous login successful
Domain=[
] OS=[myDom
Unix
Server=[Samba 3.0.31
]Sharename
Type
nbsp;
Comment
---------
----
nbsp;
-------
sharero
Disk
nbsp;
Unwritable (read-only)
diskmnt
Disk
nbsp;
More Files
IPC$
IPC
nbsp;
IPC Service (
)HostOSShare
Anonymous login successful
Domain=[
] OS=[myDom
Unix
Server=[Samba 3.0.31
]Server
Comment
---------
-------
Workgroup
Master
---------
-------
The text from the “Domain” field (shown twice, as
in the above example output) came from Unix's /etc/smb/smb.conf (on the line that starts says “myDom
workgroup =
”). For shared resources that act as a shared
, the text in the “Disk
column may be defined by a line that saysComment
comment =
on a Unix server's /etc/smb/smb.conf file. The “
” text came from Unix's /etc/smb/smb.conf (on the line that starts says “HostOSShare
server string =
”). - Dealing with problems
-
Try adding
“
-d3
” to increase the debugging level. This will show more output. - Other neat things to do with this software
-
A connection may be able to be made using:
smbclient
\\
\\
\192.0.2.65
\
sharename
One can probably test this from a Unix server sharing files, since a Unix server sharing files will likely also have the client software installed. This may be done with something like:
smbclient
\\
\\
\127.0.0.1
\
sharename
- SMBFS
-
This might be implemented via Fuse.
Note that this might not be an easily available option for all operating systems. (FUSE may not currently be widely supported on some operating platforms, such as BSD operating systems.)
- Sharity software
-
- [#shartylt]: Sharity-Light
-
This software was released for free, hoping that people would become familiar with it and then choose to pay for other software by the same organization.
This product has previously been released under the name “rumba”. Sharity-Light home page
- Requirements
-
- [#lmpwshyl]: Sharity-Light supports only LANMan-style passwords
-
One major requirement is that the server needs to accept LANMAN passwords, which are widely documented as having pitiful encryption. Due to the pitifulness of that encryption implementation, many newer servers have such support turned off by default.
Since Sharity-Light does not support newer styles of authentication, the ways to resolve this are:
- not use Sharity-Light (perhaps use Samba, FUSE, smbfs?)
-
make the remote server support older-style authentication
- For example, if the remote server is using Microsoft Windows, check out support for older software.
- Mounting a remote share
-
This documentation was made using sharing over IPv4.
If a private share is going to be used, the program will ask for the password of the private share. This password may be redirected to the program. The safer method is to store this password in a file, and then redirect the file's contents into the program that asks for a password. At least file permissions will then be used, and the password won't be shared to anybody with permission to see what is running on a server. The actual password can also avoid going into a command line history.
It will be helpful to know that the shared directory is successfully shared from the server, showing up in the list of shared resources. Determining this may be easier to do with the samba package using
.smbclient
First, store the password in a text file. It may be generally terrible advice to store a password in plaintext, but at least then file permission will be used.
On the other hand, redirecting the results of an
command doesn't create a file that may later be easily forgotten about.echo
This process may go easier/more-successful if the IPv4 address shows up in the
file. This is true even if the remote system is referenced later by numeric IPv4 address (rather than by name). If the remote system is at/etc/
hosts192.0.2.65
(which should not be the case, since192.0.2
is meant to only be used for example documentation), then back up the file that is about to be changed (the/24
file), and then run:/etc/
hostsecho
192.0.2.65
mysys
.mynet
mysys
>>
/etc/
hostsThen, run something like this:
cat
share1.pwd~
/|
/usr/local/sbin/
shlight//
/webmount192.0.2.65
/
-Umnt/sambadrv/webmount
shareusr
-C -S -w -iThere's quite a bit to customize above there. (Details are not provided at this time.) or maybe there are...
regardless, clean-up is currently needed here.-C : Allow lower-case. Removing it seemed to help once. -S : Allow safe -w : Allow writhe -i : Do not show prompt for password, but do wait for std input to give a pwd -W WORKGROUP -D0xff : enable debug mode 192.0.2.1: unknown host put an entry in /etc/hosts echo pwd | /usr/local/sbin/shlight //192.02.0.1/webmount /srv/mydir -U username -C -S -w -i
- Problems
-
- Not creating a connection
-
Using “
-D
” as a command line parameter may cause some more detailed output to show up. That may be helpful.0xff
If the system does, or can, have other software to verify the server is running as desired, try using that software. For example, although Samba's
won't mount a remote drive and make the remote drive act like a local filesystem, it can list remote resources and make connections (which may help verify that a password is expected).smbclient
If
works, strongly suspect the issue may be with encryption implementation. Namely: some newer servers may, by default, not be supporting the older-style NTLM-based credentials. This may be changable in the software. Sharity-Light may make a statement about the server requiring an NTLM password. Do not trust that statement: the server may be requiring a newer-style encryption.smbclient
Another option may be to get more information from the server. (For example, the section on Samba shows how the server may provide more debugging information.)
- Password/authentication issues
-
Sharity-Light may not support some of the newer additions to SMB-related code. See: Sharity-Light supports only LANMan-style passwords.
- Running during system startup
-
If the program fails to start as part of an automatic startup script, see if it can be started manually. If so, check problems running programs during startup.
The doc says: /usr/local/share/doc/Sharity-Light/README Sharity-Light will still be maintained because it's the only free alternative (except on Linux, where you can use smbmount if it compiles). This means that bugs will be fixed and I accept patches that are (if they are of general interest) incorporated into new versions. However, I won't add major enhancements such as support for encrypted passwords, character set mappings etc., unless patches are contributed. If you need these features, please consider using Sharity (not light) instead. Sharity is free for educational use. ... The more professional tool "Sharity" (not light) allows encrypted passwords, encrypted data transport (with a modified samba or sslproxy for NT) and is generally faster. /usr/local/share/doc/Sharity-Light/FAQ Whether you have enabled unencrypted passwords (Sharity-Light can't do password encryption). sudo /usr/local/libexec/smbd -i -d 10 | tee -a /tmp/logsmb shows: ntlm_password_check: Lanman passwords NOT PERMITTED for user smbuser ntlm_password_check: Lanman passwords NOT PERMITTED for user smbuser ntlm_password_check: Checking LMv2 password with domain WORKGROUP ntlm_password_check: Checking LMv2 password with upper-cased version of domain WORKGROUP ntlm_password_check: Checking LMv2 password without a domain ntlm_password_check: Checking NT MD4 password in LM field ntlm_password_check: LM password, NT MD4 password in LM field and LMv2 failed for user smbuser check_ntlm_password: sam authentication for user [smbuser] FAILED with error NT_STATUS_WRONG_PASSWORD check_ntlm_password: Authentication for user [smbuser] -> [smbuser] FAILED with error NT_STATUS_WRONG_PASSWORD The problem is that Samba needs to use unencrypted password http://www.mail-archive.com/sharity-talk@obdev.at/msg00096.html http://www.daemonforums.org/showthread.php?t=2756 www.samba.org/samba/history/samba-3.5.0.html The Using Samba HTML book has been removed from the Samba tarball. It is still available .. The Using Samba HTML book has been removed from the Samba tarball. It is still available at http://www.samba.org/samba/docs/using_samba/toc.html. maybe try: security = share lanman auth = no min protocol = NT1 http://lists.samba.org/archive/samba/2004-March/082705.html http://www.samba.org/samba/docs/man/Samba-Developers-Guide/pwencrypt.html refers to a mksmbpasswd.sh that does something like converting from passwd http://bugs.contribs.org/show_bug.cgi?id=6229
- Automatically starting the software
-
As remembered, starting Sharity-light from an automatically started script was a bit challenging. The software requried something like a normal terminal in order to really operate as desired. Otherwise, it might create a connection but then exit, and close any connection it makes. This behavior did not seem to occur when starting the program manually after the system started up.
This was effectively worked around by using a terminal multiplexer called
. (This process was implemented beforescreen
was an available option.) A working implementation has been made by going through the following process:tmux
Have a file, which is automatically started, run a custom script. (Details about this are related to the operating system's startup procedures, and are not duplicated here.) The script that got automatically ran was a simple text file consisting of two lines:
.
/etc/
profile
-c/usr/local/bin/
screen
-S/
scrnshar.rcshrltscn
-m -dThis will cause Sharity-light to be started in a screen session which will not exist if/when Sharity-light ends. The contents of the /scrnshar.rc configuration file looked like this: HUH???
screen
ksh
title
WinZero
screen
/
sharcmdtitle
shrltcmd
detach
The first two lines were done to waste window zero. Doing this is quite unnecessary, and was done simply as a personal preference. This causes any newly-created window(s) may be accessed using a key that is close on the keyboard: with a standard keyboard layout, the non-numpad number zero is far away from the number one.
Now, finally, create one last file. This file will actually run the commands, but first starts off by doing the following:
- Setting the path
-
One line
started with “
”. A later line also contained “PATH
=/
...
”.export
PATH
=/
...
- Changing directories
-
cd
/sbin
- Loading the system-wide user startup script
-
.
/etc/
profile - Show the mount command being used
-
.
/etc/
profileThis surely had no effect: it was probably done to help troubleshoot in case the
command didn't work.mount
The program would run the
command to report status, and mount a remote drive , and then report that the mounting was done, and then show the mounted partitions (by just runningecho
command), and repeat the process for another fileshare.mount
The program ended by running “
” and then running the shell of choice. (That was done by mentioning the shell by name, but probably could have been done by runningcd
$OLDPWD
.)$SHELL
- [#rumba]: rumba
- This is a name that was used for older versions of Sharity-Light. References are likely out of date if they seem to be referring to rumba as if it is recommended/current software. Check out Sharity-Light instead.
- Sharity
-
Kudos to the makers of this software for also releasing Sharity-Light.
This guide does not currently have details about actually using this software.
- Support in Microsoft Windows
-
- Multiple versions
-
- [#smblmswn]: Support for older software
-
With newer versions (probably by Windows 7, perhaps Vista, probably not XP), Microsoft Windows uses a newer version of SMB code. This may not work with some older implementations. To use the older code:
Sharity Light guide provides some details. They involve setting the registry values shown below. (The first two
QUERY
commands may commonly not show any pre-existing values on a default installation.)REG
QUERY HKLM\SYSTEM\CurrentControlSet\Control\LSA /v LmCompatibilityLevelREG
ADD HKLM\SYSTEM\CurrentControlSet\Control\LSA /v LmCompatibilityLevel /t REG_DWORD /d 1REG
QUERY HKLM\SYSTEM\CurrentControlSet\Control\LSA /v RequireSecuritySignatureREG
ADD HKLM\SYSTEM\CurrentControlSet\Control\LSA /v RequireSecuritySignature /t REG_DWORD /d 0REG
QUERY HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v RequireSecuritySignatureREG
ADD HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v RequireSecuritySignature /t REG_DWORD /d 0Sharity Light guide also recommends running:
GPUpdate
/forceAs a final step needed to support the older style authentication, Sharity Light guide suggests changing the password. The new password can even be the same as the old password, but the act of changing the password will make Microsoft “Windows create the missing Lanman Hashes.”
- Command line support
-
To see directories/folders being shared on the current system, use “
” ornet
share
.wmic
share get /allTo see directories/folders being shared on a remote system, use “
”.wmic
/namespace:\\
share get /all
\.ComputerName
- Accessing a remote folder
-
“
” shows mapped connections.net
useTo create a drive letter: “
”net
useZ
:\\
\svrName
dirname
optionalPassword
If you want to specify a username, but don't want to specify a password on the command line (so that the
command will prompt for a password, which won't result in the password being potentially visible to anyone who may be able to see the command line that gets run), use: “net
”net
useZ
:
* /USER:\\
\svrName
dirname
optionalDomainName
\userName
Other parameters of potential interest are
/PERSISTENT:YES
or/SAVECRED
(which saves the logon credentials, including a password).To remove a mapped drive: “
”net
use
/DELETEZ
:Note that shares may be usable with some commands that are built into
. (This might have started to be supported around the time of Windows XP?) For example:CMD.EXE
dir
\\
\sysName
C$\
copy
\\
\sysName
C$\Temp\
input.txt
\\
\sysName
C$\Temp\
output.txt
- Create/remove share that remote systems can access
-
To create a share: “
”net
shareshareName
="
"C:\ShareDir
/GRANT:
userName
,CHANGE
/REMARK:
"
comment
"To remove: “
”net
shareshareName
/DELETE - Dealing with a disconnected share
-
In the following example, a drive seems to have gone offline.
C:\>
net
useNew connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
Unavailable
\\L
:
\lengthysystemname
AShare
Microsoft Windows Network
Disconnected
\\P
:
\192.0.2.100
Microsoft Windows NetworkAShare
The command completed successfully.
C:\>
- Disabling autodisconnect
-
First of all, if temporary disconnections are a repeated issue, you may wish to try removing an auto-disconnect feature by making changes on the SMB server. If the server is running Microsoft Windows, there are a couple of approaches for doing that. MS KB 297684 suggets running:
Warren's answer to a SuperUser.com question by Stephen Jennings suggests changing the registry on the server, in an attempt to reduce the likelihood of this problem. (This approach would, of course, assume that the SMB server is using Microsoft Windows.) On the server, try:NET
config server /autodisconnect:-1
REG
QUERY HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v autodisconnectREG
ADD HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters /v autodisconnect /t REG_DWORD /d 0xffffffffThere are various ways around that. One of the more intrusive is to delete and re-create the network share. The downside to that approach is that if there is a problem with re-creating the network share, then the computer is left in a state where the network share is even more broken than it was before.
wfaulk's answer to a SuperUser.com question by Stephen Jennings suggests running “
”. That creates some sort of temporary drive letter, but after that works, usepushd
\\SMBserver
\
share
to reverse all of the changes other than the drive working properly again.popd
Another way is to go into Windows Explorer. (Run “
” to open Windows Explorer at the current directory). Find the drive, which will presumably have a “Disconnected” icon. Double-click on the drive, which will retry communication.start
.
If none of these answers seem to be working, try to verify IP-based communication is functioning as desired. (Is the server reachable with any other protocols, like ICMP?)
- Seeing what files are actively being used by remote systems
-
PsFile (by Sysinternals) says, “The "
" command shows you a list of the files that other computers have opened on the system upon which you execute the command, however it truncates long path names and doesn't let you see that information for remote systems.net
file
is a command-line utility that shows a list of files on a system that are opened remotely, and it also allows you to close opened files either by name or by a file identifier.” The advantage to using “PsFile
” is that it comes with the operating system, while PsFile is downloaded as part of a collection known as PsTools. PsTools.zip is freely downloadable.net
fileSimilarly, PsLoggedOn (by Sysinternals) is part of PsTools. The PsLoggedOn page says, “You can determine who is using resources on your local computer with the "
" command ("net
"), however, there is no built-in way to determine who is using the resources of a remote computer. In addition, NT comes with no tools to see who is logged onto a computer, either locally or remotely.” (Of course, the PsLoggedOn has listed the software as being able to run on Windows XP and Server 2003 and higher, so perhaps only an older version of PsLoggedOn works in WinNT.)net
sessionOn Windows XP and newer, there is an
command. It looks like using “OpenFiles
” may be helpful (and “OpenFiles
/Query
” may even provide additional helpful options).OpenFiles
/Query /?
- Using the graphical interface
-
- Seeing what files are used by remote systems
-
See Computer Management. In Windows XP and Windows Server 2003, Computer Management could be accessed by right-clicking on “Computer” or “My Computer” and then choosing “Manage”. This method does not work in newer operating systems, as that shortcut instead goes to “Server Manager”. However, the functionality is still available in Computer Management. Just select Computer Management from (Control Panel's) Administrative Tools.
For more information about listing shares (
,net
share
) and/or managing them, see CIFS/SMB file sharing, or perhaps file transfering.wmic
share get /all- Supporting LAN MAN
-
(Merge Details from the Samba and Sharity-Light
sections, about warnings/similar. Place in a common section that is linked to
from these various sections.
Google
Site: Probehouse: Mounting a Windows shared folder for Sharity-Light
HTML/CSS clean-up
suggests:
registry changes:
Adding
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\LmCompatibilityLevel and making it set
to dword:1 “to allow older Lan manager style messages”,
changing
NoLmHash (in the same Lsa folder) to dword:0
“to allow older LAN manager style messages”,
and in
HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters
changing RequireSecuritySignature to dword:0
“HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters”.
Then use
“to immediately force these settings to take effect.” Finally, get Windows to create any needed Lanman hashes by changing the users' passwords (even if to the same value).gpupdate
/force - [#wnsmbdsc]: Dealing with drive disconnections/unavailable drives
-
- Disconnected drives
-
First, it may make some sense to obtain some information about the current drive. As an example:
>C
:\net
useNew connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
Disconnected
&nsbp;X
:\\
\example.com
ShareDir
Microsoft Windows NetworkThe command completed successfully.
>C
:\net
useX
:Local name
X
:Remote name
\\
\example.com
ShareDir
Resource type Disk
Status
Disconnected
# Opens
25
# Connections
1
The command completed successfully.
>C
:\- Variations
-
The first command may show a “
” or “Status
”. In this case, the second command might not even report a line that says ““Unavailable
” or “Status
” or “# Opens
”.# Connections
If that is experienced, see: “
” drives.Unavailable
For a system administrator, some connectivity tests may be the best thing to check first. The main reason is that this can be done while making little changes. Running these commands might not fix the problem, but may provide helpful information.
If a short-term fix immediately is more desirable than information gathering, then some people might prefer to try skipping to the step of trying to fix this using the graphical user interface, as that might often be the best/quickest immediate fix.
- Checking related connectivity
-
One of the possible causes can be connectivity issues. Not only could this be caused by physical issues, such as a problem with a cable or a Wi-Fi signal, but this could also be caused by connectivity problems related to DNS settings or a VPN implementation. A bunch of these can be checked all at once by seeing if the remote server can be communicated with.
ping
example.com
echo
%ERRORLEVEL%
(The network name specified should be the name of the server that is providing the shares. If “command extensions” are enabled (and they usually are), then
%ERRORLEVEL%
should be set to zero after a successful
.)ping
If that works, then this does not seem to be the problem. If that does not work, before jumping to conclusions, check to see whether other machines on the network can reach the server with the same
command. (Some servers might not respond to ICMP Echo requests. If that is the cause ofping
failing, then that probably is not causing the issues with filesystem connectivity.)ping
- Possible name resolution issues
-
In some cases, trying to look up a name with
(e.g., “nslookup
”, where the first parameter is the name of the file server, and the second parameter is the IP address of the DNS server) may work, when other commands likenslookup
fileserv
10.0.0.1
fail.ping
Trying to connect by using the IP address of the server might be a temporary workaround. If
works with the IP address, but not the DNS name, see if flushing the local DNS Resolver cache helps (using “ping
”). Another option which might help to fix name resolution may be to restart the Workstation service (with “IPConfig
/FlushDNS
” followed by “sc
stop LanmanWorkstation
”).sc
start LanmanWorkstationIf that didn't fix things, and the end user is urgently waiting for the drive, then accessing the network share by using the IP address might be a usable temporary workaround. However, to prevent future problems, the name resolution ought to be fixed.
- Further troubleshooting
-
Optional: Running the following command might be slightly informative. The information gained is simply whether this message (including the prompt) shows up or not. Realize that if the prompt does not show up, this does proceed to delete the network drive.
>C
:\net
use
/DELETEX
:There are open files and/or incomplete directory searches pending on the connect
ion to
.X
:
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:
n
>C
:\An optional (and, really, rather useless) step: try to go directly to the shared folder, without using the local drive name. So, point the Explorer window to \\
\example.com
ShareDir
and see if that works. This might often fix nothing, but may feel informative, as further information is provided while making few changes. In some cases, that might work, but accessing the drive directly might annoyingly still not work. That does indicate that the SMB/CIFS communication is working, and the issue is just with the current status of the drive mapping.A similar step, which is also quite optional and may be informative (but might not be considered a satisfactory way to have the situation be fully resolved), but which can be performed on the command line, is to use “
pushd
\\
”. If using Microsoft's
\example.com
ShareDir
Cmd.exe
, this requires “Command Extensions
” (which is usually enabled by default, and so is usually not a problem), and the result may be a newly created drive letter (as noted further by “
”). If using JP Software's TCC/LE, this might not create a drive letter, but may work: the prompt may show the UNC instead of the prior drive letter. Then, usingpushd
/?
strives to reverse the effect(s) ofpopd
(including removing the drive letter if usingpushd
, as noted by Superuser post aboutCmd.exe
).pushd
Try to re-establish the connection, to see if that fixes the issue. This is one of the rare cases where the task can be accomplished from the command line, but using the graphical interface may actually provide some advantage.
- Re-establish the connection using the GUI
-
Go to Windows Explorer (or equivilent, such as an icon that is labelled “My Computer” or “Computer”, which may be on the desktop or the initial layer of the “Start Menu” (even before choosing “Programs”/“All Programs”).
Verify that the network drive does show up, but has a red icon (like a red circle with a white X over it). The window might report that the drive is disconnected (perhaps simply shown as part of the drive description, or perhaps shown in a tool tip when selecting the drive and/or hovering the mouse over the drive).
Double-click the drive, despite the claim that it shows being disconnected.
In many cases, this simply fixes the issue. The Explorer window will open up the contents of the new drive, and any other program that had troubles connecting to the drive will find that it is working fine.
(Read on for further troubleshooting: see recurring disconnected drives.)
- Re-establish the connection using the command line
-
First, make sure that the current mapping is sufficiently recorded. The steps to see the current mapping are shown in the top of this section about dealing with drive disconnections.
Next, delete the drive. Note that attempting to delete the drive will probably work, and if there are problems with re-creating the drive then the computer will have effectively forgotten the old settings. (That is why using the graphical interface can be nicer. For instance, when troubleshooting with the graphica interface, if things are not successful, but then the user travels to a different Internet access, the end user might try again to use the network drive, and may find that things are working just fine. However, after deleting the drive from the command line, things are left in a “more broken” state, so common end users will typically be unable to repair the issue on their own.)
Once that is understood, proceed with the drive deletion (of a drive which is not working well). One way, which may be fairly automated, may be to use a batch file (which has been documented to have a filename of refreshletters.cmd) which is documented by SuperUser post about mapped drives: section about Brian's refreshing script file. (That hasn't been heavily tested by the author of this text, but looks sensible.) Or, a more manual approach may be taken:
>C
:\net
use
/DELETEX
:There are open files and/or incomplete directory searches pending on the connect
ion to
.X
:
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:
y
was deleted successfully.X
:
>C
:\Then, re-make the connection.
>C
:\net
useX
:\\
\example.com
ShareDir
...
C
:\>echo
%ERRORLEVEL%
0
>C
:\net
useX
:\\
\example.com
ShareDir
Some people have recommended using “
/PERSISTENT:
” on the command line.YES
- [#wnsmbrds]: Dealing with a re-occurring issue (of disconnected drives)
-
There are some various approaches. At the time of this writing, full experimenting has not been performed well enough to fully recommend any one of these approaches over any of the others. Perhaps none will be fully satisfying. However, in case any of these does help, here are some possible ideas.
- Some adjustments
-
Connectivity issues are frequent, particularly when mobile users use VPNs. Obviously, the best solution for that is likely to be to fix the connectity issues. Other approach may be to have the drives be re-mapped whenever the VPN is created. If that is not feasible (because of how the VPN is used), a less ideal solution may be to provide an icon that fixes the issue. This is not considered as nice, because it involves training the user to run the icon when things aren't working well. However, at least in the short term, this may be better than having the drives be inaccessible.
See: MS KB 297684. Namely, the approach to that MS KB can be done by interacting with the registry in Microsoft Windows, by running the following:
-
On the client, run:
REG
QUERY HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /zREG
QUERY HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /z /v KeepConnREG
ADD HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v KeepConn /t REG_DWORD /d65535
REG
QUERY HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /z /v autodisconnectREG
ADD HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v autodisconnect /t REG_DWORD /d4294967295
-
On the server, the following might help. First, gather the current value (out of the habit of checking current settings before changing them):
net
CONFIG SERVERIf permission is denied, see: user account control (perhaps especially interacting with UAC from the command line).
Before changing this, know that this value is designed to try to reduce server load. Making this change on the server may affect every client that uses file sharing on this server. This may be undesirable, particularly if just one client is affected. (If multiple employees are having troubles, this might be simpler than trying to adjust the relevant client settings of multiple individual workstations. Trying both approaches (affecting the clients and affecting the server) might be worthwhile for troubleshooting.)
The default value for
might beIdle session time (min)
. Change the value for that setting:15
net
CONFIG SERVER /AUTODISCONNECT:-1
-
- Other approaches
-
Using the “EnableLinkedConnections” registry key, as described by UAC elevated command line section, might be helpful.
If that doesn't work, another solution was provided by Nektarios80's post about using RestoreConnection. (note: The hyperlink anchor may not work: search for RestoreConnection.) There, Nektarios80 recommended a registry entry which could delay having the computer trying to connect to the network drive until someone actually tries to access that. This might make the problem effectively disappear. Try:
REG
ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /t DWORD /d EnableLinkedConnections /v 1(It is unknown, by the author of this text, whether rebooting is necessary. However, since this affects behavior when a user logs in, testing to see if there is a change would involve a necessary logout anyway. If that's being done anyway, rebooting might not be a much more inconvenient step to take.)
There is some additional details on the same forum thread. Another discusses trying some other approach(es), like using third party software: forum post seems to recommend Zorn Software's MapDrive. TechNet article with posting by author of Zorn Software. The software has moved from its original location: Zorn Software download for MapDrive identifies the license as “Free (GNU General Public License)”, and source code for MapDrive has been (eventually) located. Zorn Softare MapDrive. e.g.,
"
MapDrive
"R
:"\\
server
\
"sharedir
20
”forum post about making a scheduled task shows somebody trying to make a scheduled task, which causes the network drives to be scheduled to occur after a logon.
- Yet other ideas/resources
-
http://superuser.com/a/53170 points out that “
” has a “net
use/SAVECRED
option to re-use the password credentials used” during the last successful connection.http://support.microsoft.com/kb/2512089 might describe Windows caching old results?
If using a computer that is connected to an Active Directory domain, then using “
” (and, quote specifically, “klist
”) has helped some people.klist
purge
-
[#wnsmbavl]: “
” drivesUnavailable
-
If “
” reports a status of “net
use
”, then that status can be notably different than some of the other reported statuses. Try opening up a brand new command prompt window.Unavailable
See if opening a new command window reports different results. If so, that typically indicates a temporary issue has been mostly fixed. In that case, the only results that remain might be what is simply lingering in any already-existing command prompt window. If that command prompt window is needed, then using that window to re-create the mapped drive might help. However, that is often more work than what the results are worth (if the window was just created for troubleshooting).
- Support in MS-DOS
-
Support for network shares was included in Microsoft's “Workgroups for MS-DOS” product. This might not have been a very common product.
Details about how to use the product are likely similar to the details about using the “
” command to handle shares from the command line of Microsoft Windows, although this may be some older/earlier code.net