Listing all machines in a domain

Discussion in 'Python' started by Dirk Hagemann, Oct 15, 2003.

  1. 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
     
    Dirk Hagemann, Oct 15, 2003
    #1
    1. Advertising

  2. Dirk Hagemann

    Colin Brown Guest

    "Dirk Hagemann" <> wrote in message
    news:...
    > 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
     
    Colin Brown, Oct 15, 2003
    #2
    1. Advertising

  3. Dirk Hagemann

    Tim Golden Guest

    (Dirk Hagemann) wrote in message news:<>...
    > 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
     
    Tim Golden, Oct 16, 2003
    #3
  4. "Tim Golden" <> schrieb im Newsbeitrag
    news:...
    > (Dirk Hagemann) wrote in message

    news:<>...
    > > 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
     
    Dirk Hagemann, Oct 16, 2003
    #4
  5. Dirk Hagemann

    Tim Golden Guest

    "Dirk Hagemann" <> wrote in message news:<bmmrh6$h1n$04$-online.com>...
    > "Tim Golden" <> schrieb im Newsbeitrag
    > news:...
    > > (Dirk Hagemann) wrote in message

    > news:<>...
    > > > 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 Golden, Oct 17, 2003
    #5
  6. Dirk Hagemann

    Tim Howarth Guest

    In message <>
    (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 ----
     
    Tim Howarth, Oct 17, 2003
    #6
  7. Tim Howarth <> wrote in message news:<>...
    > In message <>
    > (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
     
    Dirk Hagemann, Oct 30, 2003
    #7
  8. (Tim Golden) wrote in message news:<>...
    > "Dirk Hagemann" <> wrote in message news:<bmmrh6$h1n$04$-online.com>...
    > > "Tim Golden" <> schrieb im Newsbeitrag
    > > news:...
    > > > (Dirk Hagemann) wrote in message

    > news:<>...
    > > > > 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


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

    Dirk
     
    Dirk Hagemann, Oct 30, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dirk Hagemann

    Listing computers of a WinNT-Domain

    Dirk Hagemann, Nov 6, 2003, in forum: Python
    Replies:
    2
    Views:
    398
    Dirk Hagemann
    Nov 6, 2003
  2. yoda
    Replies:
    0
    Views:
    322
  3. George Flaherty
    Replies:
    1
    Views:
    384
  4. Felix_WafyTech

    Listing domain users

    Felix_WafyTech, Feb 18, 2006, in forum: ASP .Net Security
    Replies:
    11
    Views:
    241
    MikeS
    Feb 21, 2006
  5. c676228
    Replies:
    5
    Views:
    175
    p byers
    Dec 31, 2007
Loading...

Share This Page