JWColby
jwcolby at colbyconsulting.com
Thu Mar 22 14:38:48 CDT 2007
Yea, I need to get the MACHINE'S IP address on the internal network.
My application (the framework) logs the user logging in and logging out of
the database. I use some code I found somewhere that looks at the lock file
and says "who is in the database", with the machine name in it. I use that
for a simple form that th4e administrators can use to see who is in the
database. The admin wants to see the user's name (easy, I log that as they
log in/out) and the IP address. In order to get the IP address, I need to
log that when the user logs in.
John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
Sent: Thursday, March 22, 2007 3:27 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Obtaining IP Address
Here is an alternate method of getting IP address.
Public Sub GrabIPAddress()
'retrieves users IP address from website dyndns.org ' looking back at
machine from outside firewall ' uses XPath to parse returned html page
'website has been up 5 years.
'page returned is html text
Dim objHTTP As New MSXML2.XMLHTTP
'need to set reference to xml 4.0 or late bind Dim strWebPage As String
On Error Resume Next
'Retrieve Web Page URL
strWebPage = "http://checkip.dyndns.org/"
objHTTP.Open "POST", strWebPage, False
objHTTP.setRequestHeader "Content-Type", _
"application/x-www-form-urlencoded "
objHTTP.send
'check for http errors
If Err.Number Or objHTTP.status <> "200" Then
'errors include 501 500 and (404 page not found)
MsgBox Err.Number & Err.Description
MsgBox objHTTP.status
MsgBox "Cannot retrieve page!"
Debug.Print Err.Number & Err.Description
Exit Sub
End If
' look at the response
Debug.Print objHTTP.getAllResponseHeaders
Debug.Print objHTTP.statusText
Debug.Print objHTTP.responseText 'Pass Response back from Server
Debug.Print objHTTP.responseText 'Now parse the returned xml for specific
nodes via XPath Dim xmlDoc As New MSXML2.DOMDocument
Dim objNodeList As IXMLDOMNodeList
Dim objNode As MSXML2.IXMLDOMNode
xmlDoc.async = False
xmlDoc.loadXML objHTTP.responseText
'error check dom load here and use XPath method for node selection
xmlDoc.setProperty "SelectionLanguage", "XPath"
Set objNodeList = xmlDoc.documentElement.selectNodes("//body")
Debug.Print objNodeList.length
For Each objNode In objNodeList
Debug.Print objNode.Text
Next
End Sub
>
>
>>>>jwcolby at colbyconsulting.com 22-03-2007 14:59 >>>
>>>>
>>>>
>Is there VBA code out there to obtain the IP address of the current
>workstation? I found code that goes through the registry, and it
>ALMOST works, in fact it does work in many instances but...
>
>John W. Colby
>Colby Consulting
>www.ColbyConsulting.com
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com