Read Remote File with Access Permissions

前端 未结 2 350
清歌不尽
清歌不尽 2020-12-11 14:09

I am trying to read a file on a network server (from a Windows XP machine), which I would normally access by asking for \\\\ServerName\\dirPath\\ in the run dia

相关标签:
2条回答
  • 2020-12-11 14:19

    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.

    0 讨论(0)
  • 2020-12-11 14:20

    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.

    0 讨论(0)
提交回复
热议问题