Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Listing all machines in a domain

Reply
Thread Tools

Listing all machines in a domain

 
 
Dirk Hagemann
Guest
Posts: n/a
 
      10-15-2003
Hello!

I need to get a list of all machines in a (Windows-)domain. So I used
as described in the ActiveState Python Documentation
win32net.NetServerEnum('',100,win32netcon.SV_TYPE_ ALL,'domain-x') to
get this list from the PDC. But the result is only a list of all
machines which are logged-in. What I really need is a list of ALL
machines - taht means also the machines which belong to this domain,
but are logged-off (or simply switched-off).

A colleague did it in Perl with this code:
Win32::AdminMisc::GetMachines( $dc, UF_WORKSTATION_TRUST_ACCOUNT,
\%wkslist, "" );
This retrieves a whole list of the machines of a domain.
How can I do this in Python???

Thanks a lot for your response!

Dirk
 
Reply With Quote
 
 
 
 
Colin Brown
Guest
Posts: n/a
 
      10-15-2003

"Dirk Hagemann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hello!
>
> I need to get a list of all machines in a (Windows-)domain.


Using wmi is a possibility (maybe Win32_GroupUser). Search
for my recent posting in c.l.p "Tip: Windows internals using wmi".

Colin Brown
PyNZ



 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      10-16-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Dirk Hagemann) wrote in message news:<(E-Mail Removed). com>...
> I need to get a list of all machines in a (Windows-)domain. So I used
> as described in the ActiveState Python Documentation
> win32net.NetServerEnum('',100,win32netcon.SV_TYPE_ ALL,'domain-x') to
> get this list from the PDC. But the result is only a list of all
> machines which are logged-in. What I really need is a list of ALL
> machines - taht means also the machines which belong to this domain,
> but are logged-off (or simply switched-off).


I'm a little surprised to find that this call returns only machine
logged-on (and do you, by the way, mean "switched on" or really
"logged on" - ie with someone's username active on the machine?).
However, see if this thread from the Python win32 group is of any use
to you.

http://aspn.activestate.com/ASPN/Mail/Message/1785767

TJG
 
Reply With Quote
 
Dirk Hagemann
Guest
Posts: n/a
 
      10-16-2003
"Tim Golden" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> (E-Mail Removed) (Dirk Hagemann) wrote in message

news:<(E-Mail Removed). com>...
> > I need to get a list of all machines in a (Windows-)domain. So I used
> > as described in the ActiveState Python Documentation
> > win32net.NetServerEnum('',100,win32netcon.SV_TYPE_ ALL,'domain-x') to
> > get this list from the PDC. But the result is only a list of all
> > machines which are logged-in. What I really need is a list of ALL
> > machines - taht means also the machines which belong to this domain,
> > but are logged-off (or simply switched-off).

>
> I'm a little surprised to find that this call returns only machine
> logged-on (and do you, by the way, mean "switched on" or really
> "logged on" - ie with someone's username active on the machine?).
> However, see if this thread from the Python win32 group is of any use
> to you.
>
> http://aspn.activestate.com/ASPN/Mail/Message/1785767
>
> TJG



Thanks for the link! I tried this code once before, but I got an error
because of this
"WinNT:" in the code. But on tuesday I will try again.I don't know if I also
got machines which are only switched on - but that'spossible (I will test
this as well on tuesday. Now I start into myextra-long weekend - yet ).
Dirk


 
Reply With Quote
 
Tim Golden
Guest
Posts: n/a
 
      10-17-2003
"Dirk Hagemann" <(E-Mail Removed)> wrote in message news:<bmmrh6$h1n$04$(E-Mail Removed)-online.com>...
> "Tim Golden" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed) om...
> > (E-Mail Removed) (Dirk Hagemann) wrote in message

> news:<(E-Mail Removed). com>...
> > > I need to get a list of all machines in a (Windows-)domain.

> >
> > [...] see if this thread from the Python win32 group is of any use
> > to you.
> >
> > http://aspn.activestate.com/ASPN/Mail/Message/1785767
> >
> > TJG

>
>
> Thanks for the link! I tried this code once before, but I got an error
> because of this
> "WinNT:" in the code. But on tuesday I will try again.I don't know if I also
> got machines which are only switched on - but that'spossible (I will test
> this as well on tuesday. Now I start into myextra-long weekend - yet ).
> Dirk


Just in case it helps, there was a follow-up discussion which somehow
became detached from its thread:

http://aspn.activestate.com/ASPN/Mai...-win32/1786718

although that doesn't address problems with WinNT: which should work,
I think, on anything from NT upwards (not on Win9x). We don't use AD
here, and it works on my Win2K machine.

TJG
 
Reply With Quote
 
Tim Howarth
Guest
Posts: n/a
 
      10-17-2003
In message <(E-Mail Removed) >
(E-Mail Removed) (Dirk Hagemann) wrote:

> I need to get a list of all machines in a (Windows-)domain.


If an Active Directory domain then you could use;


import win32com.client

def do_onecontainer(Container):
for oneobject in Container:
if oneobject.Class.lower()=='computer':
print oneobject.cn

if oneobject.Class.lower()=="organizationalunit" or \
oneobject.Class.lower()== "container":
do_onecontainer(oneobject)

startContainer=win32com.client.GetObject("LDAP://DC=mydomain,DC=local")

do_onecontainer(startContainer)




--
___
|im ---- ARM Powered ----
 
Reply With Quote
 
Dirk Hagemann
Guest
Posts: n/a
 
      10-30-2003
Tim Howarth <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> In message <(E-Mail Removed) >
> (E-Mail Removed) (Dirk Hagemann) wrote:
>
> > I need to get a list of all machines in a (Windows-)domain.

>
> If an Active Directory domain then you could use;
>
>
> import win32com.client
>
> def do_onecontainer(Container):
> for oneobject in Container:
> if oneobject.Class.lower()=='computer':
> print oneobject.cn
>
> if oneobject.Class.lower()=="organizationalunit" or \
> oneobject.Class.lower()== "container":
> do_onecontainer(oneobject)
>
> startContainer=win32com.client.GetObject("LDAP://DC=mydomain,DC=local")
>
> do_onecontainer(startContainer)


No, thank you. It's not an AD-domain - that's what we are preparing...

Dirk
 
Reply With Quote
 
Dirk Hagemann
Guest
Posts: n/a
 
      10-30-2003
(E-Mail Removed) (Tim Golden) wrote in message news:<(E-Mail Removed). com>...
> "Dirk Hagemann" <(E-Mail Removed)> wrote in message news:<bmmrh6$h1n$04$(E-Mail Removed)-online.com>...
> > "Tim Golden" <(E-Mail Removed)> schrieb im Newsbeitrag
> > news:(E-Mail Removed) om...
> > > (E-Mail Removed) (Dirk Hagemann) wrote in message

> news:<(E-Mail Removed). com>...
> > > > I need to get a list of all machines in a (Windows-)domain.
> > >
> > > [...] see if this thread from the Python win32 group is of any use
> > > to you.
> > >
> > > http://aspn.activestate.com/ASPN/Mail/Message/1785767
> > >
> > > TJG

> >
> >
> > Thanks for the link! I tried this code once before, but I got an error
> > because of this
> > "WinNT:" in the code. But on tuesday I will try again.I don't know if I also
> > got machines which are only switched on - but that'spossible (I will test
> > this as well on tuesday. Now I start into myextra-long weekend - yet ).
> > Dirk

>
> Just in case it helps, there was a follow-up discussion which somehow
> became detached from its thread:
>
> http://aspn.activestate.com/ASPN/Mai...-win32/1786718
>
> although that doesn't address problems with WinNT: which should work,
> I think, on anything from NT upwards (not on Win9x). We don't use AD
> here, and it works on my Win2K machine.
>
> TJG


Thank you!!! That works
Now I can care about the coming up next problems...

Dirk
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Listing Processes Running on Remote Machines George Flaherty Python 1 08-01-2005 05:43 PM
Listing Processes Running on Remote Machines yoda Python 0 07-21-2005 01:22 PM



Advertisments