仅为此进程登录到 Windows 网络共享 (SMB) [英] Log in to a windows network share (SMB) for this process only

查看:34
本文介绍了仅为此进程登录到 Windows 网络共享 (SMB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为整个用户会话(例如 net useWNetAddConnection2() 等)登录 Windows 网络共享 (SMB) 很容易.

It's easy to log into a Windows network share (SMB) for the whole user session (e.g. net use, WNetAddConnection2() etc).

是否有任何类似的方式只会影响我当前的流程?

Is there any similar way that will only impact my current process?

某种令牌系统,也许?

如果真的别无选择,整个会话身份验证是可以的,但我宁愿避免局部问题的全局解决方案".

Whole session auth is okay if there's really no alternative, but I would rather avoid a "global solution to a local problem".

推荐答案

网络会话由 Windows 内核作为 smb 客户端驱动程序的一部分处理,因此它们是按 Windows 工作站(实际上不是用户)管理的,这意味着您无法使用两个不同的凭据访问相同的共享,并且您实际上无法根据 windows smb 客户端施加的限制.限制的原因是微软实现了共享访问作为过滤器驱动程序,每个共享访问的UNC路径(\share\test)都存储为共享资源,使您作为开发人员和用户的生活更轻松.(使共享访问无缝)

Network sessions are handled by the windows kernel as part of the smb client driver, as such they are managed per windows workstation (not the user actually), meaning that you can't access the same share with two different credentials, and you can't actually create a new network connection per process as per the limitation imposed by the windows smb client. the reason for the limitation is that Microsoft implemented share access as a filter driver, each UNC path (\share\test) to share access is stored as a shared resource to make your live as a developer and user easier. (makes share access seamless)  

一个简单的例子是在提升的(以管理员身份运行)命令提示符下运行 net use 并尝试在未提升的上下文中访问它.

a quick example of it is running net use in an elevated (run as administrator) command prompt and trying to access it in an unelevated context.

你可以选择任何一种方式:

you can go either way:

  1. 使用samba/another userland smb implementation(有一些基于python的)在您的软件中
  2. 创建一个新的winstation 对于您的每个流程(这有很大的开销)
  1. use samba/another userland smb implementation (there are some python based) in your software
  2. create a new winstation for each of your processes (this has a big overhead)

这篇关于仅为此进程登录到 Windows 网络共享 (SMB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆