读取C#中的隐藏共享
因此,我有一个小型 C# 应用程序,需要定期检查网络上多台计算机上的目录内容。 我以为我可以将 \hostname\C$ 读取为目录路径,但对于普通的 Directory 类,似乎没有一种方法可以对其他服务器进行身份验证,以便您可以访问隐藏的共享。 我确信有一种简单的方法可以做到这一点,但我忽略了,但目前我有点困惑。
So I have a small C# app that needs to periodically check the contents of directories on multiple machines on the network. I thought I could just read \hostname\C$ as a directory path, but with the normal Directory class there doesn't seem to be a way to authenticate against the other servers so you can access the hidden share.
I'm sure there's an easy way to do this that I've overlooked, but at the moment I'm a bit stumpted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 http://bytes.com/forum/thread689145.html:
最简单的方法似乎是授予当前用户在其他计算机上的适当权限。
From http://bytes.com/forum/thread689145.html:
The easiest way seems to be to give the current user appropriate rights on the other machines.
要对运行进程的用户没有权限的共享进行身份验证(管理共享通常是这种情况),请尝试运行 net use 命令:
尝试在实际尝试访问该进程的代码之前在单独的进程中运行此命令共享,例如:
如果不适合为运行进程的用户帐户授予共享权限,则这很有用,例如对于最终用户应用程序需要访问用户自己应该访问的共享上的数据的安全模型无法直接访问。
To authenticate with a share to which the user running the process does not have permission (which is often the case for administrative shares), try running the net use command:
Try running this in a separate process before the code which actually tries to access the share, e.g.:
This is useful if it is not appropriate to give permission to the share for the user account running the process, e.g. for a security model where an end-user application needs to access data on a share to which the user herself should not have direct access.
您是否正在寻找一种在运行时设置当前用户的方法?
如果没有,只要运行该进程的用户可以访问这些机器,这对您有用:
Are you looking for a way to set the current user at run-time?
If not, as long as the user running the process has access to those machines, this will work for you: