Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if connected to a domain - no lag time?

Status
Not open for further replies.
Feb 11, 2005
153
0
0
US
Okay I need to come up with a real time way to check to see if a machine is connected to a very complex domain.

Currently I was thinking of using -

Set objADSystemInfo = CreateObject("ADSystemInfo")
strDomain = objADSystemInfo.DomainDNSName
wscript.Echo strDomain

The problem is this takes about 2-5 minutes to time out and return an error if the PC is removed from the network. I need a solution that is a little more "real-time".

I don't want to use a IfAlive function where it pings a machine because I want to ensure this is not dependant upon another machine to be up and running. E.G we have multiple Domain servers so if I point it to a Domain server they retire this will screw up for everyone that gets this script.

Is there a better more accurate way of seeing real time if the machine is on the network or not? I know the machines will still be on their own internal network so I can't check NIC connection states.

The situation is this - We have users that VPN in and their shutdowns run over 7 minutes + due to login scripts that are trying to run off network connections they no longer have. I want use a local VBS shutdown script to see if the computer is not connected to the domain (the part I am trying to accomplish here) and hence remove the AD startup and shutdown scripts from running (by doing some registry modifications).
 
to see if the computer is not connected to the domain
Testing the LOGONSERVER, USERDNSDOMAIN and/or USERDOMAIN environment variables doesn't suffice ?
You may also inspect the output of the ipconfig /all command.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No those don't work either the problem is alot of people disconnect from the VPN and then go to shut down their computers pretty quickly.

All of these variables either stay in memory or flush out only after minutes of being disconnect both don't work in the quick shutdown method.

As far as getting the IP information how would I code it to get any IP and know its internal vrs external? This to me to be way to big a variable to code.

Basically we have users connected via VPN then disconnecting vpn then shutting down but I need to know the status of the PC being disconnected as its shutting down be it 30 seconds or 2 hours after disconnected from the VPN.



 
I think I figured it out - An LDAP query

On error resume next
Set objRootDSE = GetObject("LDAP://RootDSE")
If Err.number <> 0 Then
wscript.quit
Else
regedit
End If
On Error Goto 0

All users no matter their security settings or just being a user and non admin should be able to get the RootDSE right?

The second I disconnect the network cable this query returns errors I can then script against.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top