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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting domain/user/computer through VPN tunnel/connection 1

Status
Not open for further replies.

EgilHansen

IS-IT--Management
Jan 3, 2006
16
0
0
Hi

The logon script we use at work works great when users are at the office. But when at home and connected to our network through a VPN tunnel (Netscreen Remote tunnel), the script is unable to detect the domain name, the current user and the current computer. Currently we detect those using the following VBScript code (cleaned up to save space):

--------------------------------------

Dim strDomain
Dim objADSystemInfo
Set objADSystemInfo = CreateObject("ADSystemInfo")

' AD info
strDomain = objADSystemInfo.DomainDNSName

' User account
Set objUser = GetObject("LDAP://" & strDomain & "/" & objADSystemInfo.UserName)

' Computer account
Set objComputer = GetObject("LDAP://" & strDomain & "/" & objADSystemInfo.ComputerName)

--------------------------------------

Is there another way to detect these things?

Best regards,
Egil.
 
Straight from the help file:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
WScript.Echo "Computer Name = " & WshNetwork.ComputerName
WScript.Echo "User Name = " & WshNetwork.UserName


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
slightly off topic and on top of what PHV has said i think i used to check %logonserver% to see if user had logged onto a domain or logged onto their machine
i like to expandenvironmentstrings...i think i am old fashioned
 
Hi PHV

I'm afraid it's not that simple. My problem lies in actually getting in contact with the PDC and performing LDAP queries.

Even if I hard code the distinguished name I'm still turned down:

Set objUser = GetObject("LDAP://CN=Administrator,CN=Users,DC=xxxxxxx,DC=yyy")
WScript.Echo "sAMAccountName = " & objUser.sAMAccountName

If I run the above code, I get a "The specified domain either does not exist or could not be contacted."

I have updated my lmhost in accordance to - and indeed I'm able to ping my PDC on both ip and dns name/hostname.

Is there any other tricks I haven't tried that might work?

Best regards, Egil.
 
What if you specified a specific DC.

i.e.

LDAP://Server01/CN=Administrator,CN=Users,DC=xxxxxxx,DC=yyy

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks dm4ever, the basic hard coded example works now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top