Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

python - Read Remote File with Access Permissions

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

Right now, I have to write a program that reads the file off the server and returns some results on my PC.

The problem that I'm facing is that the login name on my PC does not have a login account on the server. As a result, I am unable to read the file on the server when I tried:

f = open(r'\serverpathofile', 'r')

I know that I can fix this by adding a user account to the server or to my PC, but short of those solutions, is there a way for me to pass login credentials to the server?

I am running Windows XP on my PC and some flavor of Linux on the server

Thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...