简体   繁体   English

如何从UWP应用程序中运行物联网核心的Raspberry Pi访问网络共享

[英]How to access Network Share from Raspberry Pi running IoT Core in UWP app

I have ac# UWP app that I'm intending to run on a Raspberry PI with Windows 10 IoT Core. 我有一个ac#UWP应用程序,我打算在带有Windows 10 IoT核心的Raspberry PI上运行。 The problem I have is when I try to connect to a UNC share to copy some files. 我遇到的问题是当我尝试连接到UNC共享来复制某些文件时。

The network is just a home network with local user credentials, share is on another computer on the same network. 网络只是具有本地用户凭据的家庭网络,共享位于同一网络上的另一台计算机上。

When running the app locally I can just use await StorageFolder.GetFolderFromPathAsync(@"\\\\share\\folder"); 在本地运行应用程序时,我可以使用await StorageFolder.GetFolderFromPathAsync(@"\\\\share\\folder"); to connect to the share and this works fine, I'm assuming this is because the credentials I'm using are saved on the local machine. 连接到共享,这工作正常,我假设这是因为我正在使用的凭据保存在本地计算机上。 When ran on the RPi the error received is: "The system cannot find the file specified." 在RPi上运行时,收到的错误是:“系统找不到指定的文件。”

Does anyone have any ideas on how I would connect to this drive, I'm game for anything at this stage to get it to work... 有没有人对我如何连接到这个驱动器有任何想法,我在这个阶段的任何事情的游戏,让它工作...

What I've tried: 我尝试过的:

  1. Share has permissions for everyone and can be accessed without credentials 共享拥有每个人的权限,无需凭据即可访问
  2. Network share computer firewall is off. 网络共享计算机防火墙已关闭。
  3. manifest has the private networks, enterprise auth, and Internet (both) setup (assuming okay as works locally). manifest具有私有网络,企业认证和Internet(两者)设置(假设在本地工作正常)。
  4. await StorageFolder.GetFolderFromPathAsync(@"\\\\share\\folder"); ("The system cannot find the file specified.") (“该系统找不到指定的文件。”)
  5. using powershell with net use "\\\\share\\folder" "password" /USER:"user" works and unc can be browsed 使用PowerShell与net use "\\\\share\\folder" "password" /USER:"user"工作,unc可以浏览
  6. Tried using WNetAddConnection2 as in Prevent WNetAddConnection2 class which allows prohibited user to access shared folder 尝试使用WNetAddConnection2如在Prevent WNetAddConnection2类中允许禁止用户访问共享文件夹
  7. Tried using WNetUseConnection with both user prompt and without (neither works) 尝试使用WNetUseConnection同时提供用户提示和不使用( WNetUseConnection
  8. FolderPicker or FileOpenPicker but these seem to be disabled for IoT Core ( https://ms-iot.github.io/content/en-US/win10/UnavailableApis.htm ). FolderPicker或FileOpenPicker但这些似乎被禁用了IoT Core( https://ms-iot.github.io/content/en-US/win10/UnavailableApis.htm )。

Thanks in advance, 提前致谢,

Paul. 保罗。

Have you tried impersonation yet? 你有没有尝试过冒充吗? Here is what I use in one of my projects: 以下是我在其中一个项目中使用的内容:

[DllImport("advapi32.dll", SetLastError = true)]            
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

private void Impersonate(Enum domainName, string userName, string password)
{
    IntPtr _tokenHandle = IntPtr.Zero;
    int Logon32_Provider_Default = 0;
    int Logon32_Logon_Interactive = 2;

    bool userSuccess = LogonUser(userName, domainName.ToString(), password, Logon32_Logon_Interactive, Logon32_Provider_Default, ref _tokenHandle);

    if (!userSuccess)
    {
        throw new Win32Exception(Marshal.GetLastWin32Error());
    }

    WindowsImpersonationContext _impersonatedUser = new WindowsIdentity(_tokenHandle).Impersonate();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Raspberry PI 3的Windows 10 IoT核心版中从ASP.NET Core 2.1调用UWP函数 - How to call UWP function from ASP.NET Core 2.1 in Windows 10 IoT Core for Raspberry PI 3 如何检测连接到运行Windows 10 IoT核心版的Raspberry Pi的USB上的文件? (C#UWP) - How can I detect a file on a USB connected to a Raspberry Pi running Windows 10 IoT Core? (C# UWP) async await in UWP windows 10 IOT core running in Raspberry Pi 3B and memory leak - async await in UWP windows 10 IOT core running in Raspberry Pi 3B and memory leak 语音识别在使用UWP的raspberry pi 3(Windows IoT核心版)中不起作用 - speech recognition not working in raspberry pi 3(windows iot core) using UWP StreamSocketListener在Raspberry Pi 3(IoT Core UWP)上从客户端随机接收到空 - StreamSocketListener randomly receive empty from client on Raspberry Pi 3 (IoT Core UWP) .NET Core应用程序远程部署到Raspberry Pi上的Windows IoT Core - .NET Core app remote deployment to Windows IoT Core on Raspberry Pi UART Raspberry Pi Windows IoT核心版Arduino - UART Raspberry pi Windows IoT Core Arduino 如何使用Windows 10 IoT(UWP)为Raspberry Pi 3创建可移植代码(.net标准2.0)? - How to create portable code (.net standard 2.0) for a Raspberry Pi 3 using Windows 10 IoT (UWP)? 无法将UWP应用部署到Raspberry Pi 3 - Cannot deploy UWP app to raspberry pi 3 如何在抬头的UWP IoT核心应用中调用IHost的Run() - How to call IHost's Run() in a headed UWP IoT Core app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM