linux - “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上解决此问题的解决方案吗?
注意:Windows 2016 server 没有在域中注册,而 Windows 10 已经注册并且有域名
解决方案
推荐阅读
- haskell - 如何解决模棱两可的“发现”?
- firebase - 如何在云功能上使用 aria2c?
- json - JOLT 转换以根据数组类型过滤联系人类型
- nginx - 使用 Certbot 续订 SSL 证书,无需使用不需要的域
- ffmpeg-php - 如何让这些水印缩放以适应视频参数?
- custom-controls - WPF自定义数据网格幻像标题重叠
- java - Spinner OnItemSelected 事件未被调用
- java - 从android中的Java main获取(String [] args)
- jquery - 如何使用 Knockout/jQuery/Bootstrap 正确验证和提交表单
- c - 如何从 C 中的 .txt 文件中读取数据?