Read Remote File with Access Permissions

故事扮演 提交于 2019-11-28 13:13:38

You say it's a Samba share - have a look at PySmbClient. That way, you can do something like this:

client = smbclient.SambaClient(server="servername", share="sharename",
    username="foo", password="bar", domain="baz")
f = smb.open('/path/to/file')
data = f.read()
f.close()

Alernatives are available, such as PySamba.

Impersonation using the win32 modules might work for you. See this ActiveState Recipe

I have used the Technet Runas command line tool manually before. In a pinch you could use that with a subprocess call to copy the file to a local temp file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!