Solved

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

Posted on 2002-03-24
7
161 Views
Last Modified: 2010-05-02
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!
0
Comment
Question by:Boomtastic
7 Comments
 
LVL 3

Expert Comment

by:nzjonboy
ID: 6893036
try lookng at some of the apps here

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

nzjonboy
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6893046
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....






0
 
LVL 17

Expert Comment

by:inthedark
ID: 6893054
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.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Boomtastic
ID: 6926075
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


0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7637805
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
0
 

Author Comment

by:Boomtastic
ID: 7638026
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!!
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7753626
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now