You might be able to tell if the computer is joined to a domain by checking
a value in the registry. You might also be able to retrieve the name of
the
domain. But at some point you must connect to the domain and that will
involve a timeout if it is not available.
The wshShell and wshNetwork objects are local and so there is no timeout
when you retrieve values from them. With these you can tell if the
computer
has authenticated to a domain, and determine the name of the domain. The
standard method I know of to check for the availability of a domain (and
retrieve the name) is with the RootDSE object, but there is a timeout if
no
domain is available. It sounds like you will be using the credentials of
the
local computer object. This object can bind to local objects. The RootDSE
object accepts any credentials.
I have not used the GetComputerDomain method, but if it is a method of a
domain object, you won't have a reference to that unless you bind to it
(with a timeout if it is not available).
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
"Rich Armstrong" <RichA24@[EMAIL PROTECTED]
> wrote in message
news:57621680-A3C8-4DDE-B609-42E5A9DC35AD@[EMAIL PROTECTED]
> Thanks, Richard. The user's identity isn't an issue for me; it will
always
> be either Local System or Network Service. All I care about is whether
the
> machine itself is joined to a domain, as its credentialls would be the
> ones presented to AD. I did manage to dig up this, though:
> System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain(). It
> may do the job, but I'm unsure of a couple of things:
>
> If the computer is joined to a domain, but is running offline, the docs
> say it will throw an exception. That's fine with me, but what sort of
> timeout might I expect, and is there a way to minimize that timeout?
>
> If it becomes an issue, I can always just cache the (boolean) result. If
> the machine's domain member****p changes while the app is running (highly
> unlikely), the consequences are minimal.
>
> --Rich Armstrong
>
>
> "Richard Mueller [MVP]" <rlmueller-nospam@[EMAIL PROTECTED]
> wrote in
> message news:%239CbTIR4IHA.2332@[EMAIL PROTECTED]
>>
>> "Rich Armstrong" <RichA24@[EMAIL PROTECTED]
> wrote in message
>> news:D076CE49-DDF8-4096-8257-1ED53934E464@[EMAIL PROTECTED]
>>> With .NET, what's the quickest, reliable way of determining if the
>>> machine on which the process is running is registered in an AD domain?
>>> This seems like a simple enough task, but the solution eludes me.
>>>
>>> TIA...
>>
>> As far as I can tell, .NET has no special features for this. I attempt
to
>> bind to the ADSystemInfo object. If this fails, the user/computer are
not
>> authenicated to a domain. However, there is a timeout involved. Another
>> idea would be to retrieve the value of the userdomain environment
>> variable and compare this to the ComputerName property of the
wshNetwork
>> object. If they match, the user is logged in locally. If they do not
>> match, then userdomain is the name of the domain. Instead of the
>> userdomain environment variable you can use the UserDomain property of
>> the wshNetwork object, which is the same. You could also attempt to
bind
>> to the RootDSE object, but this would also involve a timeout if a
domain
>> is not found.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>>
>


|