Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Listing all machines in a domain

4 views
Skip to first unread message

Dirk Hagemann

unread,
Oct 15, 2003, 7:54:16 AM10/15/03
to
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

Colin Brown

unread,
Oct 15, 2003, 4:21:55 PM10/15/03
to

"Dirk Hagemann" <dirkha...@firemail.de> wrote in message
news:41cb194b.03101...@posting.google.com...

> 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

Tim Golden

unread,
Oct 16, 2003, 4:19:17 AM10/16/03
to
dirkha...@firemail.de (Dirk Hagemann) wrote in message news:<41cb194b.03101...@posting.google.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

Dirk Hagemann

unread,
Oct 16, 2003, 3:28:01 PM10/16/03
to
"Tim Golden" <tim.g...@viacom-outdoor.co.uk> schrieb im Newsbeitrag
news:8360efcd.03101...@posting.google.com...


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


Tim Golden

unread,
Oct 17, 2003, 4:12:55 AM10/17/03
to
"Dirk Hagemann" <use...@mail-2-me.com> wrote in message news:<bmmrh6$h1n$04$1...@news.t-online.com>...

> "Tim Golden" <tim.g...@viacom-outdoor.co.uk> schrieb im Newsbeitrag
> news:8360efcd.03101...@posting.google.com...
> > dirkha...@firemail.de (Dirk Hagemann) wrote in message
> news:<41cb194b.03101...@posting.google.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/Mail/Message/Python-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

Tim Howarth

unread,
Oct 17, 2003, 2:41:32 PM10/17/03
to
In message <41cb194b.03101...@posting.google.com>
dirkha...@firemail.de (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 ----

Dirk Hagemann

unread,
Oct 30, 2003, 7:06:07 AM10/30/03
to
Tim Howarth <t...@worthy.demon.co.uk> wrote in message news:<2f3cef4...@worthy.demon.co.uk>...

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

Dirk

Dirk Hagemann

unread,
Oct 30, 2003, 7:08:29 AM10/30/03
to
tim.g...@viacom-outdoor.co.uk (Tim Golden) wrote in message news:<8360efcd.03101...@posting.google.com>...

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

Dirk

0 new messages