如何在没有模拟权限的情况下连接到远程目录?

发布于 2024-10-09 16:09:09 字数 322 浏览 0 评论 0原文

我有一个 .NET 服务需要与远程计算机上的文件进行交互。在配置中,用户指定他们需要访问的本地或远程(UNC)路径。用户还为有权访问这些目录的用户指定用户名和密码。当服务运行时,它会连接到每个路径并处理那里的文件。

我尝试过模拟,但客户对向服务授予该权限(通常作为本地系统运行)持怀疑态度。

我还找到了将远程目录映射为映射驱动器的代码(http://www.aejw.com/)并以这种方式访问​​它们。但是,这会导致某些版本的 Windows 抱怨多个连接。

任何建议将不胜感激。

I have a .NET service that needs to interact with files on remote machines. In the configuration, the user specifies the local or remote (UNC) paths they need to access. The user also specifies a username and password for a user that has access to those directories. When the service runs, it connects to each of these paths and processes the files there.

I tried impersonation, but customers are leery about granting that privilege to a service (usually runs as localsystem).

I also found code (http://www.aejw.com/) that mapped the remote directories as mapped drives and accessed them that way. However, this causes some versions of Windows to complain about multiple connections.

Any suggestions would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往昔成烟 2024-10-16 16:09:09

您有两种选择:

要么让您的服务访问其自己帐户下所需的文件......

要么允许模拟您的服务来执行此操作。我相信您可以理解为什么远程系统可以对不允许的事情执行操作会很糟糕。

我相信您也可以理解为什么人们不想向所有服务全权授予模拟特权。

我会认真研究你们的服务设计以及它想要做什么。如果您可以将服务移动到文件所在的位置或从客户端计算机执行代码,那么在这种情况下这可能会更好。

我正在尝试了解您的应用程序,但如果您只有一个用户名和密码,是否可以以该用户身份登录该服务?

You have two choices:

Either give your service access to the files it needs under it's own account.....

Or allow impersonation on your service to do this. I'm sure you can understand why it would be bad that a remote system could perform actions on things that it isn't allowed to.

I'm sure you can also understand why people wouldn't want to give the impersonation privilege carte blanche to all services.

I would have a serious look at the design of your service and what it is trying to do. If you can move the service where the files are or execute the code from the client machine then this might be better in this scenario.

I'm trying to understand your app, but if you have only one username and password, is it possible to log the service in as that user?

北陌 2024-10-16 16:09:09

你看过这个博客吗? http://blogs.msdn .com/b/jocole/archive/2009/09/21/impersonation-code-in-c.aspx

使用此类,您应该能够使用 using() 执行代码需要模拟的块,当您离开该块时,您将返回给普通用户。

Have you looked at this blog? http://blogs.msdn.com/b/joncole/archive/2009/09/21/impersonation-code-in-c.aspx

With this class you should be able to execute code withing a using() block that needs impersonation and when leaving the block your back to your normal user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文