首页 > 解决方案 > “LocalSystem”和Linux Samba网络共享访问,IOException: The specified server cannot perform the requested operation

问题描述

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上解决此问题的解决方案吗?

win server 2016中的进程

注意:Windows 2016 server 没有在域中注册,而 Windows 10 已经注册并且有域名

标签: linuxdnssambasmbnetwork-share

解决方案


推荐阅读