[英]How to call UWP function from ASP.NET Core 2.1 in Windows 10 IoT Core for Raspberry PI 3
[英]How to access Network Share from Raspberry Pi running IoT Core in UWP app
我有一個ac#UWP應用程序,我打算在帶有Windows 10 IoT核心的Raspberry PI上運行。 我遇到的問題是當我嘗試連接到UNC共享來復制某些文件時。
網絡只是具有本地用戶憑據的家庭網絡,共享位於同一網絡上的另一台計算機上。
在本地運行應用程序時,我可以使用await StorageFolder.GetFolderFromPathAsync(@"\\\\share\\folder");
連接到共享,這工作正常,我假設這是因為我正在使用的憑據保存在本地計算機上。 在RPi上運行時,收到的錯誤是:“系統找不到指定的文件。”
有沒有人對我如何連接到這個驅動器有任何想法,我在這個階段的任何事情的游戲,讓它工作...
我嘗試過的:
await StorageFolder.GetFolderFromPathAsync(@"\\\\share\\folder");
(“該系統找不到指定的文件。”) net use "\\\\share\\folder" "password" /USER:"user"
工作,unc可以瀏覽 WNetAddConnection2
如在Prevent WNetAddConnection2類中允許禁止用戶訪問共享文件夾 WNetUseConnection
同時提供用戶提示和不使用( WNetUseConnection
) 提前致謝,
保羅。
你有沒有嘗試過冒充嗎? 以下是我在其中一個項目中使用的內容:
[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.