“ LocalSystem”和Linux Samba网络共享访问,IOException:指定的服务器无法执行请求的操作

时间:2019-02-26 19:54:42

标签: linux dns samba smb network-share

using System;
using System.IO;
using System.Linq;

namespace CreateDirectoryTest {
    internal class Program {
        public static void Main(string[] args) {
            if (!args.Any()) {
                Console.WriteLine("Error: Usage: CreateDirectoryTest.exe {paths}");
            }
            foreach (var arg in args) {
                try {
                    Console.WriteLine("Need to create the folder? " + arg + " (y/n)");
                    var input = Console.ReadLine();
                    if (input != null && input.Equals("n")) {
                        continue;
                    }
                    Directory.CreateDirectory(arg);
                } catch (Exception e) {
                    Console.WriteLine("Error Creating directory: " + arg);
                    Console.WriteLine(e);
                }
            }
        }
    }
}

上面的代码创建一个可执行文件CreateDirectoryTest.exe,并分别在Win 2016服务器和Win 10台式机上进行了测试。 例如:CreateDirectoryTest.exe \\\ip-address\data\testFolder \\ ip-address \ data \ testFolder是Linux文件系统上的网络共享,并且使用SMB协议进行通信。

以上过程分别在两个操作系统上的管理员和系统(NT Authority / SYSTEM)用户下执行,但是对于系统用户执行方案,在Win 2016服务器上此操作失败,并出现以下错误:

Error Creating directory: \\ip-address\data\testFolder
System.IO.IOException: The specified server cannot perform the requested operation.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at System.IO.Directory.CreateDirectory(String path)
   at CreateDirectoryTest.Program.Main(String[] args)

有人可以建议解决方案以解决Win Server 2016上的此问题吗?

process in win server 2016

注意:Windows 2016服务器未在域中注册,而Windows 10已注册并具有域名

0 个答案:

没有答案