Creating a session in windows to auth to remote machines

ericwoodworth at gmail.com ericwoodworth at gmail.com
Sun Apr 5 15:55:59 EDT 2009


On Apr 5, 9:09 am, ericwoodwo... at gmail.com wrote:
> On Apr 5, 2:11 am, Tim Golden <m... at timgolden.me.uk> wrote:
>
>
>
>
>
> > ericwoodwo... at gmail.com wrote:
> > > Hi,
> > >      I'm trying to auth to remote machines so I can plunder WMI to get
> > > logs and settings and the like.  My script works for most of my
> > > machines because they're all in the same domain and I run the script
> > > as somebody who has enough access to get at this stuff but for
> > > machines off the domain I'm stuck.
>
> > Unless I'm missing something here, you can already specify
> > username etc. with WMI. Just Dispatch on "WbemScripting.SWbemLocator"
> > and call .ConnectServer. Just in case you haven't already, I
> > (naturally :) ) recommend my wmi module [1] which wraps a fair bit
> > of the plumbing for you, including this. Eg,
>
> > <code>
> > import wmi
>
> > c = wmi.WMI ("some-machine", user="tim", password="password")
>
> > for log in c.Win32_NTLogEvent (
> >   Logfile="Application",
> >   Type="error"
> > ):
> >   print log.RecordNumber, log.SourceName, log.Message
>
> > </code>
>
> > [1]http://timgolden.me.uk/python/wmi.html
>
> > TJG
>
> That's very cool.  I was using win32com.client but I'll check this
> out.  Thanks!- Hide quoted text -
>
> - Show quoted text -

Thanks Tim.  I looked thru your code and you pointed me at just what I
need: SWbemLocator.ConnectServer Method which is awesome.  I already
have the WMI portion of my program working so I was using SWbemLocator
already...I just didn't know about that specific method.  That's a big
help.  I've bookmarked that page...lot of good stuff there.



More information about the Python-list mailing list