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

NetGetAnyDCName() - get PDC of a foreign WinNT-domain

28 views
Skip to first unread message

Dirk Hagemann

unread,
Jan 22, 2004, 8:50:58 AM1/22/04
to
Hi!

I'm trying to get the PDC-Computername of a foreign WinNT-domain, but
I only managed to get the PDC of my own domain with this code:
pdc=win32net.NetGetAnyDCName()

I think it should be possible to get the PDC of a foreign domain
(which is a trusted domain) with this code. If I'm right with this
assumption, could anyone give me an example-code?
Or tell me that I'm wrong, then I can concentrate on something else...

Thanks!
Dirk

Tim Golden

unread,
Jan 22, 2004, 8:54:25 AM1/22/04
to use...@mail-2-me.com, pytho...@python.org
>Hi!
>
>I'm trying to get the PDC-Computername of a foreign WinNT-domain, but
>I only managed to get the PDC of my own domain with this code:
>pdc=win32net.NetGetAnyDCName()

If you don't specify any params to that call, win32net will assume
you're looking at your own domain. It can take two params: server & domain.

If you do this:

pdc = win32net.NetGetAnyDCName (None, "name_of_other_domain")

it should work.

TJG


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Dirk Hagemann

unread,
Jan 27, 2004, 4:44:48 AM1/27/04
to
Thanks for your help, but that does not work. I get an error message
which sais it can't reach the domain.
But I'm sure did not make an syntax-error, because if I enter my own
domain it works.

Any other idea?

Dirk


Tim Golden <tim.g...@viacom-outdoor.co.uk> wrote in message news:<mailman.642.10747801...@python.org>...

Tim Golden

unread,
Jan 27, 2004, 5:13:28 AM1/27/04
to pytho...@python.org
[... snip my suggestion of pdc = win32net.NetGetAnyDCName (None,
"name_of_other_domain") ...]

>From: use...@mail-2-me.com [mailto:use...@mail-2-me.com]
>
>Thanks for your help, but that does not work. I get an error message
>which sais it can't reach the domain.
>But I'm sure did not make an syntax-error, because if I enter my own
>domain it works.
>
>Any other idea?
>
>Dirk
>
>

To ask the obvious question: do you definitely have all
the necessary security / connectivity in place to reach
the domain controller on that domain?

Can you log onto it normally with whatever name you're
running under now?

(I don't have more than one domain here, so it's difficult
for me to test)

Dirk Hagemann

unread,
Jan 30, 2004, 7:44:50 AM1/30/04
to
Tim Golden <tim.g...@viacom-outdoor.co.uk> wrote in message news:<mailman.844.10751988...@python.org>...

> [... snip my suggestion of pdc = win32net.NetGetAnyDCName (None,
> "name_of_other_domain") ...]
>
> >From: use...@mail-2-me.com [mailto:use...@mail-2-me.com]
> >
> >Thanks for your help, but that does not work. I get an error message
> >which sais it can't reach the domain.
> >But I'm sure did not make an syntax-error, because if I enter my own
> >domain it works.
> >
> >Any other idea?
> >
> >Dirk
> >
> >
>
> To ask the obvious question: do you definitely have all
> the necessary security / connectivity in place to reach
> the domain controller on that domain?
>
> Can you log onto it normally with whatever name you're
> running under now?
>
> (I don't have more than one domain here, so it's difficult
> for me to test)
> TJG
>


I can reach the other domains and I have all rights. That's no the problem.

Dirk

Tim Golden

unread,
Jan 30, 2004, 9:27:47 AM1/30/04
to use...@mail-2-me.com, pytho...@python.org
>-----Original Message-----
>From: use...@mail-2-me.com [mailto:use...@mail-2-me.com]
>Sent: 30 January 2004 12:45
>To: pytho...@python.org
>Subject: Re: NetGetAnyDCName() - get PDC of a foreign WinNT-domain
>
>
>Tim Golden <tim.g...@viacom-outdoor.co.uk> wrote in message
>news:<mailman.844.10751988...@python.org>...
>> [... snip my suggestion of pdc = win32net.NetGetAnyDCName (None,
>> "name_of_other_domain") ...]
>>
>> >From: use...@mail-2-me.com [mailto:use...@mail-2-me.com]
>> >
>> >Thanks for your help, but that does not work. I get an error message
>> >which sais it can't reach the domain.
>> >But I'm sure did not make an syntax-error, because if I enter my own
>> >domain it works.
>> >
>> >Any other idea?
>> >
>> >Dirk
>> >
>> >
>>
>> To ask the obvious question: do you definitely have all
>> the necessary security / connectivity in place to reach
>> the domain controller on that domain?
>
>
>I can reach the other domains and I have all rights. That's no
>the problem.
>
>Dirk

Could you dump a cut-and-paste of the interpreter, so
we can see what's happening? This is what I get, altho'
as I say, I don't have another domain. Is yours the same?

<dump>

ActivePython 2.2.3 Build 227 (ActiveState Corp.) based on
Python 2.2.3 (#42, Nov 13 2003, 09:57:55) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32net
>>> win32net.NetGetAnyDCName ()
u'\\\\VOBDC1'
>>> win32net.NetGetAnyDCName (None, "VOUK")
u'\\\\VOBDC1'
>>> win32net.NetGetAnyDCName (None, "non-existent")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.error: (1355, 'NetGetAnyDCName', 'The specified domain either
does not exist or could not be contacted.')
>>>

</dump>

0 new messages