Link to home
Start Free TrialLog in
Avatar of Boomtastic
Boomtastic

asked on

Login Name to DNS/IP Resolution on local network app?

I monitor a network (remotely). When I have to do remote access on their PCs, I need either the user's DNS name or IP address - something the user has no idea how to find, and frankly I'm tired of walking them through an IPCONFIG session. Without loading anything on their side, can a VB application be scripted that will allow me to put their login name into a prompt box (they all know their login names, or I have access to look it up) and have it poll our servers to resolve either their machine's DNS name or current IP address? I've seen VBS scripts that come close, and wouldn't be opposed to running one of those either. FYI - my network consists of Windows 95, NT amd 2000 users. I will adjust the points if necessary. Thanks in advance!
Avatar of nzjonboy
nzjonboy

try lookng at some of the apps here

http://www.mvps.org/vbnet/index.html?code/network/

nzjonboy
Avatar of inthedark
I have set up an IP address cache on a server. The client with thevariable IP address opens a url on the server. The server returns the public IP of the client.

Example:

http://www.gbcycles.co.uk/$ip.asp?SetIP=Fred

The site returns the current public IP of the client.  Unless you know the codes to gain acces to the IP cache you will receive a message database down.

So I created also a routine that picks up a chached address:

http://www.gbcycles.co.uk/$ip.asp?GetIP=Fred, so in this case it returns Fred's address.  In this way I can get 2 systems with variable public Ip addresses to sync. together at a predeterminted time and automatically connect.

The function $IP.asp uses code a bit like following:

<HTML><BODY>
<%
Response.Write Request.ServerVariables("REMOTE_ADDR")
%>
</BODY>
</HTML>

So in your case the users just clicks on a linkto your web-site which returns the ip address.

Hope this helps....






The problem with using Network API is that your system has no way of knowing its public IP address. In a corporate environment the packet may pass through a number translations which would be transparent to the local system.

e.g. You start with address 192.168.0.23, when your packet reaches the first router it turns your ip address into its public range, then it hits router 2 and turns again, etc.
Avatar of Boomtastic

ASKER

Here's a VB script that polls the server and returns information like I mentioned above. This is similar to what I am looking for, but with it returning the DNS name of the machine that the user is currently loged into.

' Get User Information gui.vbs
' Revision history
      
' Created 11-26-2001 by Ralph Montgomery - Firsthealth of the Carolinas (rmonty@myself.com)

' Initialize the variable farm
Dim objUserName, objUserDomain, oGroup, objUser, gList, WshShell, sMessage, sTitle
Dim objDomain, vDomain, vUserName

Dim objChangePwdTrue, objChangePwd, objUserProfile
Dim objPwdExpiresTrue, objFlags
Dim objAcctDisabled, intPwdExpired, objPwdExpiredTrue

' Set WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

' Pull Environment variables for domain/user
vdomain = WshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
vUserName = WshShell.ExpandEnvironmentStrings("%USERNAME%")

SysTest ' sub routine to check for Script Version/ADSI installed

GetInfo ' sub routing to get user information

on error resume Next

' Define user then retrieve and store groups in a list
For Each oGroup In objUser.Groups
      If gList = "" Then
            gList = oGroup.Name
      Else
            gList = gList & ", " & oGroup.Name
      End If
Next

'check for expired password
intPwdExpired = objUser.Get("PasswordExpired")

      If intPwdExpired = 1 Then
            objPwdExpiredTrue = "Yes"
            Else objPwdExpiredTrue = "No"
      End If
      
'Check for Must Change Password Flag
objFlags = objUser.Get("UserFlags")

      If (objFlags And &H00040) <> 0 Then
            objChangePwdTrue = "No"
            Else objChangePwdTrue = "Yes"
      End If

' Is password set to NEVER expire?
objPwdExpires = objUser.Get("UserFlags")

      If (objPwdExpires And &H10000) <> 0 Then
            objPwdExpiresTrue = "Yes"
            Else objPwdExpiresTrue = "No"
      End If
      
' Is the account disabled?
      If objUser.AccountDisabled = True Then
            objAccountDisabled = "Yes"
            Else objAccountDisabled = "No"
      End If
      
'How many wrong logins?
objBadLogins = objUser.BadLoginCount
      
' How old is the current password?
oPwdAge = objUser.Get("PasswordAge")
objPwdAge = FormatNumber(((oPwdAge/60)/60)/24, 0)

' Set Profile path to tabs if blank
      If objUserProfile = "" Then
            objUserProfile= "<None>" & vbTab
            Else objUserProfile = objUserProfile
      End If

' Set sMessage box variables to null      
sMessage =""

'popup user information: each line broken up for better reading
sMessage = sMessage & "Domain: " & objDomain & vbTab & "User Name: " & objUserName & _
vbTab & "Full Name: " & objUser.FullName & vbTab & vbTab & "Description: " & _
objUser.Description & vbCrLf & vbCrLf

sMessage = sMessage & "Password Expired: " & objPwdExpiredTrue & vbTab & _
"User can change Pwd: " & objChangePwdTrue &  vbTab & "Account Disabled: " & _
objAccountDisabled & vbTab & vbTab & "Account Locked Out: " & objUser.IsAccountLocked & _
vbTab & "Password Age: " & objPwdAge & vbCrLf & vbCrLf

sMessage = sMessage &  "Bad Logins: " & objBadLogins & vbTab & vbTab & "Last logon: " & _
objUser.LastLogin & vbTab & "Password Never Expires: " & objPwdExpiresTrue & _
vbTab & "Password Minimum Length: " & objUser.PasswordMinimumLength & vbCrLf & vbCrLf

sMessage = sMessage & "User Profile Path: " & objUserProfile & "Home Directory: " & _
objUser.HomeDirectory & vbTab & "Login Script: " & objUser.LoginScript & vbCrLf & vbCrLf

sMessage = sMessage & "User Groups: " & vbCrLf & vbCrLf & gList & vbCrLf

' Display User Information!
WshShell.Popup sMessage,0,"User Information for: " & objUserName & " in " & objDomain

Sub GetInfo()

' Retrieve Domain from user
sMessage = "Please enter the domain to search." & vbCrLf & vbCrLf & _
"Default is: " & vDomain & vbCrLf & vbCrLf
sMessage = sMessage & "Hit Cancel or enter a blank to quit"
sTitle = "Domain to Search"

      'get resource domain name, domain default
      objDomain = InputBox(sMessage, sTitle, vDomain)
      
      ' Evaluate the user input.
      If objDomain = "" Then    ' Cancelled by the user
          WScript.quit
      End If
      
' Set sMessage box variables to null      
ssMessage = ""
ssTitle = ""

on error resume Next

' Define username dialog box variables.
sMessage = "Please enter the USER Login ID" & vbCrLf & vbCrLf & _
"Default is: " & vUserName & vbCrLf & vbCrLf
sMessage = sMessage & "Hit Cancel or enter a blank to quit"
sTitle = "USER Login ID"

      'get resource domain name, domain default via input box
      objUserName = InputBox(sMessage, sTitle, vUserName)
      ' Evaluate the user input.
      If objUserName = "" Then    ' Cancelled by the user
          WScript.quit
      End If
      
      ' Display Just a minute!
      sMessage = "This may take a few seconds. . ."
      WshShell.Popup sMessage,2,"One moment please. . . "
      sMessage = ""
      
'Attempt to bind to the user
Set objUser = GetObject("WinNT://"& objDomain &"/"& objUserName & "",user)

If Err Then
      msgNoUser =  "Error: Could not bind to the following user: " & vbCrLf _
            & vbCrLf & "WinNT://" & objDomain &"/"& objUserName & vbCrLf & vbCrLf _
            & "Please verify your domain and user name and try again"
      WshShell.Popup msgNoUser,0,"Error retrieving information",vbCritical
      GetInfo
Else
      msgConnected = "Connected to user WinNT://" & objDomain &"/"& objUserName & vbCrLf
      WshShell.Popup msgConnected,0,"Connected To " & objUserName & " in " & objDomain, vbInformation
      
End If

End Sub

Sub SysTest()
on error resume Next

' WSH version tested
Major = (ScriptEngineMinorVersion())
Minor = (ScriptEngineMinorVersion())/10
Ver = major + minor
'Need version 5.5
      If err.number or ver = 5.6 then
      message = "You must load Version 5.5 (or later) of Windows Script Host" & vbCrLf &_
        vbCrLf & "Located at: \\servername\share\scr56en.exe"
        WScript.Quit
End If

'Test for ADSI
err.clear
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\version"
key2 = WshShell.RegRead (key)
if Err <> 0 then
        message = message & "ADSI 5.2  must be installed on local workstation to continue" & vbCrLf &_
        vbCrLf & "Located at: \\servername\share\adsi5.2.exe"
      WshShell.Popup message,0,"Workstation Setup Error",vbCritical
      WScript.Quit
End If

'Test whether the host is CScript.exe.
'G. Born code...

If IsBatch = "TRUE" Then
      If (Not IsCScript()) Then
    message = "You must set default host to cscript to run as a batch." &vbcrlf &_
      "Use the command wscript //h:cscript"      'popup closes to avoid desktop hell
      WshShell.Popup message,3,"Workstation Setup Error",vbCritical
    WScript.Quit            ' Terminate script.
      End If
End if
End Sub


Function IsCScript()
    ' Check whether CScript.exe is the host.
    If (InStr(UCase(WScript.FullName), "CSCRIPT") <> 0) Then
        IsCScript = True
    Else
        IsCScript = False
    End If
End Function
      
'**** Script Ends


Hi Boomtastic,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

Boomtastic, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
Actually, the question wasn't forgotten - it was never really answered. But now that I'm laid off, I no longer need this tool, so closing it would be best. Thank you!!
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial