Re:



On 6/15/07, Wiley Thomas <WThomas@xxxxxxxx> wrote:
I'm trying to write a script to open a file on our (windows) network. The
file is located on a machine that is not part of the domain and requires a
separate user id and password to access. I tried using urllib2 and the
password_manager to authenticate but as some point urllib2 sees I'm trying
to access a local file and passes it off to os. The error message I get is:

"WindowsError: [Error 1326] Logon failure: unknown user name or bad
password: <file path.

Does anyone know of a better approach.

Urllib2 is used for making HTTP/FTP requests. When you open a file on
a network share, the networking is handled by Windows; as far as
Python is concerned, it's treated the same as a local file.

You could try something like this (untested):

os.system(r"NET USE \\computer\share password /USER:username")
# do something with file
os.system(r"NET USE \\computer\share /DELETE")

That should authenticate and de-authenticate you properly, but it
seems like a fragile way of doing it -- for one thing, I think it
would grant access to any other program running under your login
session. There may be a better way of doing this using the Windows
API. Alternatively, depending on your application, you might want to
consider using a simple web or FTP server.

-- David
.



Relevant Pages

  • Re: single sign on for windows applications or windows services
    ... currently logged onto the network". ... Given a user name I want my windows application or service to ... For windows applications, you already have a single sign on, and that's ... user credentials from logging into windows to authenticate the user ...
    (microsoft.public.dotnet.languages.csharp)
  • Need to set a prefferred Domain Controller
    ... Due to some constraints in our IP addressing on the network, ... some of the Windows XP systems try to authenticate through the Domain ... How can we set the preffreed domain controller and the preference order to ... I remeber Windows NT had a tool for this. ...
    (microsoft.public.windowsxp.network_web)
  • Dial up to WINDOWS 2003
    ... I have a user in the company who cant seem to dialin on our Windows 2003 ... server and authenticate. ... He can get to the shares on the network when plugged into our network, ... just using dial-up doesnt work. ...
    (microsoft.public.macintosh.general)
  • Windows 98 client connecting to windows 2003 domain
    ... I am concerned that when I upgrade a network to Windows ... to authenticate onto the domain. ... being a Windows 2003 DS client as well as 2000 version ...
    (microsoft.public.windows.server.general)
  • Re: PID 1212 slowly maxing out?
    ... Windows 2003 servers, but could it affect Windows XP as well? ... I'm on a home network running on wireless. ... Logical Disk Manager service ...
    (microsoft.public.windowsxp.help_and_support)