1

The code I am using

net use K: \\<ServerName>\C$\Share /user:<domain>\<userName> '<password>'

K: is the mounted drive

Share is the folder name in server that is shared with userName and password

There error I get is

System error 5 has occurred.
Access is denied.

I think the error is because the port 445 is closed in the remote server. Since I am sure I am giving right credentials.

Vikram Shetty
  • 127
  • 1
  • 1
  • 5

5 Answers5

2

If you have control of the remote server and it is a windows server, then try running the following from an elevated (run as administrator) command prompt on the remote server:

netsh a s a state off

Do not leave it in this state as it will turn off the firewall completely to allow you to test. Then try your net use command again on the client. If this works, then it is a firewall problem. Turn the firewall back on:

netsh a s a state on

Then resolve the firewall issue by adding an appropriate rule (for TCP 445), or change the profile of the network.

Other answers suggest TCP port 139, but for SMB this is only needed if you will access the machine by its NETBIOS name. It is used for name resolution even when SMB protocol is used. In fact, in that case you made need TCP ports 137-139 open. The actual share access is done via TCP port 445 (since Windows 2000!) and if you will only access the machine via IP then that is the only port that will be used.

However, temporarily turning off the firewall as I suggest will tell you if it is a port/firewall issue.

bao7uo
  • 1,664
  • 11
  • 24
1

It may have something to do with SID compression on Windows 2012 servers in connection with older NASes - but if thats what hurts you depends on your particular configuration. I stumbled upon it after specific update was installed on DCs (2012R2), after which I couldn't access SMB shares on older Thecus NAS. There was no kerberos authentication (checked with klist command). Here is the solution: https://support.microsoft.com/en-us/help/2774190/resource-sid-compression-in-windows-server-2012-may-cause-authorization-problems-on-devices-that-do-not-support-resource-sid-compression

Tomek
  • 11
  • 1
0

If you get an access denied error, this means the remote server has explicitly refused to grant you access. But for this to happen, the network connection definitely needs to be established first.

This is not a networking issue.

Massimo
  • 68,714
  • 56
  • 196
  • 319
0

AS net use is using the SMB or Netbios or WebDAV protocol on port 445 or 139 or 80 respectively according Network Provider Order, I don't see any option How you could run net use a different port.

Also nothing about on Technet : https://technet.microsoft.com/en-us/library/gg651155(v=ws.11).aspx

As you are getting Access is denied I recommend you to check the set permission of the CIFS according to the user you try to access with.

Alexandre Roux
  • 460
  • 6
  • 19
  • Is the the TCP port that I need to open? – Vikram Shetty Dec 30 '16 at 09:52
  • Yes I guess as net use should use 139 and 445. – Alexandre Roux Dec 30 '16 at 10:07
  • In order to verify if both of these port are open I recommend you to use : **telnet hostname 139** and **telnet hostname 445** – Alexandre Roux Dec 30 '16 at 10:08
  • Surprisingly both server is connected via 139 and 445 from Source and Destination and visa-versa – Vikram Shetty Dec 30 '16 at 10:29
  • Humm ok. Now what about your user NTFS permission on the CIFS that you try to access? – Alexandre Roux Dec 30 '16 at 10:35
  • Ok I guess I got this, Do you mean http://www.ntfs.com/ntfs-permissions-setting.htm then the user has full rights to the folder – Vikram Shetty Dec 30 '16 at 10:55
  • Access to a folder on a file server can be determined through two sets of permission entries: the share permissions set on a folder and the NTFS permissions set on the folder. You have to make sure that your user is come from a group that have permission to browse the CIFS or the user have permission directly on the CIFS however you will have access denied. – Alexandre Roux Dec 30 '16 at 11:02
  • I updated my response with the set of permission if it's help you Vikram. – Alexandre Roux Dec 30 '16 at 11:05
  • I got your answer and I see both share and security have permission to the user. However I still got the issue and I am little clueless about CIFS. :-( – Vikram Shetty Dec 30 '16 at 11:35
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/50938/discussion-between-vikram-shetty-and-alexandre-roux). – Vikram Shetty Dec 30 '16 at 11:52
0
\\<ServerName>\IPC$\Share /user:<domain>\<userName> '<password>'

The key was to use IP before the C$ I got the help from https://klyavlin.wordpress.com/2012/09/19/robocopy-network-usernamepassword/ There is a note mentioned in the the article that you need to share the folder on both server. However if you are running the robocopy on source server then you don't have to share the folder. Example given below.

robocopy C:\Source \\<ServerName>\Foldername /E /MIR /XA:H /R:1 /W:1
Vikram Shetty
  • 127
  • 1
  • 1
  • 5