网络文件夹安全
我有一个树视图控件,用于浏览用户系统驱动器上的各个文件夹。 还可以将其设置为使用 UNC 路径(例如“\server\files”)连接网络文件夹。 目前,我正在使用 My.Computer.FileSystem.GetDirectories 获取目录列表,但是当文件夹受密码保护时,这显然会失败。
有没有一种方法可以让 Windows 打开凭据对话框,就像您在 Windows 资源管理器中看到的那样,并处理凭据方面,然后输入用户名和密码。 密码也被缓存了吗?
顺便说一句,我不允许物理映射驱动器。
谢谢你的帮助。
抢
I have a treeview control which is being used to browse various folder on the users system drive. It can also be set up to connect network folders using UNC paths e.g "\server\files". At the moment I'm getting a list of Directories by using My.Computer.FileSystem.GetDirectories however this obviously fails when the folder is password protected.
Is there a way that I can get Windows to open the credentials dialog as you would see in Windows Explorer and deal with the credentials side so then the user name & password is cached as well?
I'm not allowed to physically map drives by the way.
Thanks for any help.
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要使用 P/Invoke 来调用 Windows API 函数,特别是 WNetAddConnection3。
请在此处查看我的问题的答案:我可以强制使用 Windows挑战用户进行身份验证?
You will need to use P/Invoke to call a Windows API function, specifically WNetAddConnection3.
See the answer to my question here: Can I force windows to challenge a user for authentication?
我认为你应该使用十六进制值
Private Const CONNECT_INTERACTIVE As Integer = &H8
私有常量 CONNECT_PROMPT As Integer = &H10
I think you should be using Hex values
Private Const CONNECT_INTERACTIVE As Integer = &H8
Private Const CONNECT_PROMPT As Integer = &H10