windows Vista UAC - 映射网络驱动器的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1267085/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:58:40  来源:igfitidea点击:

Vista UAC - Trouble Mapping Network Drives

windowsuacwindows-vistafile-sharingnet-use

提问by jonathanpeppers

We have an application that programmatically maps network drives. On Vista with UAC on, we get some strange issues.

我们有一个以编程方式映射网络驱动器的应用程序。在开启 UAC 的 Vista 上,我们会遇到一些奇怪的问题。

Our application maps the drive non-elevated, so if the user browses explorer and double clicks to run an exe, it prompts for UAC. So when they approve it, it prompts for a username/password for the share... Strange since the credentials are saved.

我们的应用程序映射驱动器未提升,因此如果用户浏览资源管理器并双击运行 exe,它会提示 UAC。因此,当他们批准它时,它会提示输入用户名/密码以进行共享...奇怪,因为凭据已保存。

It turns out, an elevated process cannot access a mapped drive that was mapped from a non-elevated process.

事实证明,提升的进程无法访问从非提升的进程映射的映射驱动器。

To see this issue in action, do the following steps:

要查看此问题的实际效果,请执行以下步骤:

  • Run cmd.exe with no UAC
  • Run "net use w: \yourHostname\yourShare /user:yourUser yourPassword /persistent:yes"
  • Run cmd.exe as Administrator
  • Type "w:", and see the error message
  • 在没有 UAC 的情况下运行 cmd.exe
  • 运行“net use w:\yourHostname\yourShare /user:yourUser yourPassword /persistent:yes”
  • 以管理员身份运行 cmd.exe
  • 输入“w:”,查看错误信息

At this point you can run plain "net use" and see the connection on the elevated cmd is Unavailable but the other non-elevated cmd sees it as OK.

此时,您可以运行简单的“net use”并看到提升的 cmd 上的连接不可用,但其他非提升的 cmd 认为它正常。

Does anyone know a workaround to fix this issue? or maybe a way to map a network drive to "All Users"?

有谁知道解决此问题的解决方法?或者可能是一种将网络驱动器映射到“所有用户”的方法?

采纳答案by jonathanpeppers

Check out this link: Regedit Link

查看此链接:Regedit 链接

They describe a registry key that allows elevated users to access mapped drives and vice versa. This solves all my issues and was exactly what I was looking for.

它们描述了一个注册表项,允许提升的用户访问映射的驱动器,反之亦然。这解决了我所有的问题,正是我正在寻找的。

EDIT:

编辑:

The original link is dead, but here's the text as copied from the Jan 24, 2009 snapshot at www.archive.org:

原始链接已失效,但以下是从www.archive.org 上的2009 年 1 月 24 日快照复制的文本:



If you are finding that you don't have access to mapped drives from your admin token try the following. When running as a protected admin you have two tokens and this key will maintain the connection for both tokes (that is my understanding anyway). It can also help to clear up issues with Login scripts.

如果您发现无法通过管理员令牌访问映射驱动器,请尝试以下操作。作为受保护的管理员运行时,您有两个令牌,此密钥将维护两个令牌的连接(无论如何,这是我的理解)。它还可以帮助解决登录脚本的问题。

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System EnableLinkedConnections =(dword)1

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System EnableLinkedConnections =(dword)1

Also of use is the "'Group Policy Scripts can fail due to User Account Control" section of this doc.

同样有用的是本文档的“'组策略脚本可能因用户帐户控制而失败”部分。

http://technet2.microsoft.com/WindowsVista/en/library/5ae8da2a-878e-48db-a3c1-4be6ac7cf7631033.mspx?mfr=true

http://technet2.microsoft.com/WindowsVista/en/library/5ae8da2a-878e-48db-a3c1-4be6ac7cf7631033.mspx?mfr=true

I will be posting more information on this soon.

我将很快发布有关此的更多信息。

回答by Michael

This is by design.

这是设计使然。

Even though the user account is the same, with the elevated version having a token with membership in the administrator group and addition privileges, the tokens are created independently and thus have different LUID's and appear to the kernel to be from different user logons. Since they are from different logons, mapped drives are not shared between them.

尽管用户帐户是相同的,但由于提升版本具有具有管理员组成员身份和附加权限的令牌,这些令牌是独立创建的,因此具有不同的 LUID,并且在内核看来来自不同的用户登录。由于它们来自不同的登录,映射驱动器不会在它们之间共享。

http://blogs.msdn.com/cHymans/archive/2007/02/19/mapped-network-drives-with-uac-on-windows-vista.aspxdiscusses this in additional detail.

http://blogs.msdn.com/cHymans/archive/2007/02/19/mapped-network-drives-with-uac-on-windows-vista.aspx更详细地讨论了这一点。