[python-win32] win32net.NetUseAdd buglet (or doc buglet)
Scott Prive
scottprive at earthlink.net
Fri Apr 18 17:55:21 EDT 2003
Hi all,
I replied to Mark/All, but I think anyone could jump in with an answer.
The example code is ready to run and I included output from the debugger.
Please someone try it out and tell me if my results were reproducible.
Basically NetUseAdd() -- on my system at least -- seems to require the key
['passwd'] and fails with ['password']. Mark says the reverse condition
should be true, which leads me to wonder... what am I doing wrong? Should I
ditch ActiveState and use python.org + win32all? I'll do that if necessary
and is the source of my problem.
thanks a bunch,
Scott
----- Original Message -----
From: "Scott Prive" <scottprive at earthlink.net>
To: "Mark Hammond" <mhammond at skippinet.com.au>; <python-win32 at python.org>
Sent: Wednesday, April 16, 2003 11:36 PM
Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet)
>
> ----- Original Message -----
> From: "Mark Hammond" <mhammond at skippinet.com.au>
> To: "'Scott Prive'" <scottprive at earthlink.net>
> Sent: Wednesday, April 16, 2003 7:10 PM
> Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet)
>
>
> > > that share info is passed to the function in the form of a dictionary.
> > > There's no example usage [sorry to complain, wish there
> > > were...] but it does
> > > point me to MSDN for more info.
> >
> > I think you will find examples in the Python Programming on Win32 book.
>
> Actually I -have- your book :-)
> Until I finish Lutz' Programming Python, your Win32 is serving as a
> reference (it's next tho!).
>
> Searching the index, I did not see win32net.NetUseAdd (other win32net
> relatives are listed).
> ... It could be an index omission, in which case I'll see it eventually.
>
> >
> > >
> > > The problem?
> > >
> > > The MSDN documentation has example usage (share path, user,
> > > password etc.).
> > > But in their example they call password, "password".... the
> > > Pythin win32
> > > wrapper doesn't understand ['password'] (and does not raise
> > > an exception on
> > > its use), but it DOES understand ['passwd'].
> > >
> > > So either MSDN is wrong or the wrapper's got a buglet. :-)
> >
> > None of these wrappers raise an exception on a bad attribute name - they
> > should. But in this case, the attribute is certainly named "password".
I
> > expect that simply the underlying Win32 call is failing for you.
> >
> > Mark.
>
> I'm certain it appears only to work with 'passwd', but if something's
going
> on under the hood it's quite interesting. Below is an interactive
session,
> followed by the actual code.
>
> You can see the difference between the two functions is the password
entry.
> I've tried this with other accounts. The same credentials were tested
under
> CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which
is
> the same server I'm mounting the share from. Each time I tested, I started
> from a clean slate and verified nothing (at all) is listed under plain
'net
> use'
>
> When I get a mount from my function (under 'passwd'), I validate it by
> echoing text to a file on Z:\test.txt.
> If the 'password' function ran, which never provided a mount, this step
> yields a "system cannot find the path specified."
>
> Any thoughts? Thanks.
> -Scott
>
> ---------- interactive ------------
> E:\scott\Komodo\ntlm_cifs>dir z:
> The system cannot find the path specified.
>
> E:\scott\Komodo\ntlm_cifs>python
> ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
> Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from testmap import *
> >>> mountShare
> <function mountShare at 0x008B63E8>
> >>> mountShare()
> This drive letter was in use, so I'll unmount it
> Good. Verified drive letter is not already mounted.
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "testmap.py", line 20, in mountShare
> win32net.NetUseAdd(None,1,data)
> pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user
name
> or b
> ad password.')
> >>> mountShare2()
> This drive letter was in use, so I'll unmount it
> Good. Verified drive letter is not already mounted.
> >>>
>
> ----------------code---------------
> #!/usr/bin/python
>
> import string, sys, win32file, win32net
>
> def mountShare():
> """A CIFS mount interface, wraps win32 API call NetUseAdd"""
> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd
> try:
> print "This drive letter was in use, so I'll unmount it"
> unmountShare()
> except:
> print 'Good. Verified drive letter is not already mounted. '
> data = {
> 'remote' : r'\\rogue.scottprive.com\account1',
> 'local' : 'Z:',
> 'password' : 'foo',
> 'user' : 'foo',
> 'asg_type' : 0,
> }
> win32net.NetUseAdd(None,1,data)
>
> def mountShare2():
> """A CIFS mount interface, wraps win32 API call NetUseAdd"""
> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd
> try:
> print "This drive letter was in use, so I'll unmount it"
> unmountShare()
> except:
> print 'Good. Verified drive letter is not already mounted. '
> data = {
> 'remote' : r'\\rogue.scottprive.com\account1',
> 'local' : 'Z:',
> 'passwd' : 'foo',
> 'user' : 'foo',
> 'asg_type' : 0,
> }
> win32net.NetUseAdd(None,1,data)
>
> def unmountShare():
> win32net.NetUseDel(None,'Z:',0)
>
>
> def main():
> mountShare()
> mountShare2()
>
> if __name__ == '__main__': main()
>
>
>
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
More information about the Python-win32
mailing list