Hallo !
I am using IIS-Windows-Authentication in my intranet
(web.config <authentication mode="Windows" /> <identity
impersonate="true" />
How can I get the users (client) IP-Address ?
I think the username can be read with user.identity.name.
Thanks
aaapaul 7 3176
<lv****@gmx.net> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com... I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" />
How can I get the users (client) IP-Address ?
HttpContext.Current.Request.UserHostAddress
However, as has been mentioned countless times before, this is not 100%
reliable.
Hi Mark !
Your statement gives back 127.0.0.1.
This isn´t the IP of the client.
Any suggestions.
<lv****@gmx.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
1) Create a new WebForm called debug.aspx
2) Drop the code at the end of this post into it, and deploy it on your web
server
3) Browse to it from a client machine
<%@ Page language="c#" %>
<%@ Import Namespace="System" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Debug for ASP.NET</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script>
function toggleTable(pstrTable)
{
if(document.getElementById("tbl" + pstrTable).style.display =="none")
{
document.getElementById("tbl" + pstrTable).style.display="block";
document.getElementById("cmd" + pstrTable).value="Hide";
}
else
{
document.getElementById("tbl" + pstrTable).style.display="none";
document.getElementById("cmd" + pstrTable).value="Show";
}
}
</script>
</head>
<body><form>
<input type=button id=cmdCurrentIISContext value="Show"
onclick=toggleTable("CurrentIISContext"); style=width:32pt>
<b>Current server context running IIS (Environment)</b>
<table id="tblCurrentIISContext" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<!--
<tr>
<td>System.Security.Principal.WindowsIdentity.GetC urrent().Name</td>
<td><%// = System.Security.Principal.WindowsIdentity.GetCurre nt().Name
%></td>
</tr>
-->
<tr>
<td>System.Environment.CurrentDirectory</td>
<td><% = System.Environment.CurrentDirectory.ToString() %></td>
</tr>
<tr>
<td>System.Environment.MachineName</td>
<td><% = System.Environment.MachineName.ToString() %></td>
</tr>
<tr>
<td>System.Environment.OSVersion</td>
<td>
<%
/*
4.00.1381 Windows NT 4.0
4.00.1381 Windows NT 4.0 Service Pack 6a 1999-11-30
5.00.2195 Windows 2000 (Windows NT 5.0)
5.00.2195 Windows 2000 (Windows NT 5.0) Service Pack 4 2003-06-26
5.1.2600 Windows XP (Windows NT 5.1)
5.1.2600.2096 Windows XP (Windows NT 5.1) Service Pack 2 RC1 2004-03-11
5.1.2600.2149 Windows XP (Windows NT 5.1) Service Pack 2 RC2 2004-06-10
5.2.3663 Windows Server 2003 RC1
5.2.3718 Windows Server 2003 RC2
5.2.3790 Windows Server 2003 RTM (Windows NT 5.2) 2003-04
6.0.4051 Windows "Longhorn" Client Preview 1 2003-11-02
6.0.4074 Windows "Longhorn" Client Preview 2 2004-05-04
*/
Response.Write(System.Environment.OSVersion.ToStri ng());
System.OperatingSystem osInfo = System.Environment.OSVersion;
switch(osInfo.Platform) // determine the platform
{
case System.PlatformID.Win32Windows: // Win95, Win98, Win98SE, WinMe
{
switch (osInfo.Version.Minor)
{
case 0:
{
Response.Write(" (Windows 95)");
break;
}
case 10:
{
if(osInfo.Version.Revision.ToString() == "2222A")
{
Response.Write(" (Windows 98 Second Edition)");
}
else
{
Response.Write(" (Windows 98)");
}
break;
}
case 90:
{
Response.Write(" (Windows Me)");
break;
}
}
break;
}
case System.PlatformID.Win32NT: // WinNT Win2k, WinXP, Win2k3
{
switch(osInfo.Version.Major)
{
case 3:
{
Response.Write(" (Windows NT 3.51)");
break;
}
case 4:
{
Response.Write(" (Windows NT 4.0)");
break;
}
case 5:
{
switch(osInfo.Version.Minor)
{
case 0:
{
Response.Write(" (Windows 2000)");
break;
}
case 1:
{
Response.Write(" (Windows XP)");
break;
}
case 2:
{
switch(osInfo.Version.Build)
{
case 3663:
{
Response.Write(" (Windows Server 2003 RC1)");
break;
}
case 3718:
{
Response.Write(" (Windows Server 2003 RC2)");
break;
}
case 3790:
{
Response.Write(" (Windows Server 2003)");
break;
}
}
break;
}
}
break;
}
case 6:
{
switch(osInfo.Version.Build)
{
case 4051:
{
Response.Write(" (Windows \"Longhorn\" Client Preview 1)");
break;
}
case 4074:
{
Response.Write(" (Windows \"Longhorn\" Client Preview 2)");
break;
}
}
break;
}
default :
{
Response.Write(" (Unknown)");
break;
}
}
break;
}
}
%>
</td>
</tr>
<tr>
<td>System.Environment.SystemDirectory</td>
<td><% = System.Environment.SystemDirectory.ToString() %></td>
</tr>
<tr>
<td>System.Environment.UserDomainName</td>
<td><% = System.Environment.UserDomainName.ToString() %></td>
</tr>
<tr>
<td>System.Environment.UserName</td>
<td><% = System.Environment.UserName.ToString() %></td>
</tr>
<tr>
<td>System.Environment.Version</td>
<td>
<%
Response.Write(System.Environment.Version.ToString ());
switch(System.Environment.Version.ToString())
{
case "1.0.3705.000" :
{
Response.Write(" (.NET 1.0)");
break;
}
case "1.0.3705.209" :
{
Response.Write(" (.NET 1.0 SP1)");
break;
}
case "1.0.3705.288" :
{
Response.Write(" (.NET 1.0 SP2)");
break;
}
case "1.0.3705.6018" :
{
Response.Write(" (.NET 1.0 SP3)");
break;
}
case "1.1.4322.573" :
{
Response.Write(" (.NET 1.1)");
break;
}
case "1.1.4322.2032" :
{
Response.Write(" (.NET 1.1 SP1)");
break;
}
}
%>
</td>
</tr>
<tr>
<td>System.Environment.WorkingSet</td>
<td><% = (System.Environment.WorkingSet / (1000 *
1024)).ToString("#,###0") + "Mb (" +
System.Environment.WorkingSet.ToString("#,###0") + ")" %></td>
</tr>
</table>
<hr>
<input type=button id=cmdEnvironment value="Show"
onclick=toggleTable("Environment"); style=width:32pt>
<b>Environment Variables (Environment.GetEnvironmentVariables())</b><br>
<table id="tblEnvironment" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<%foreach (DictionaryEntry de in Environment.GetEnvironmentVariables()) {%>
<tr>
<td>
<%= de.Key %>
</td>
<td>
<%= de.Value %>
</td>
</tr>
<% } %>
</table>
<hr>
<input type=button id=cmdRequest value="Show"
onclick=toggleTable("Request"); style=width:32pt>
<b>Request Object (HttpContext.Current.Request)</b><br>
<table id="tblRequest" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<tr>
<td>
.UserHostAddress
</td>
<td>
<%= Request.UserHostAddress %>
</td>
</tr>
<tr>
<td>
.UserHostName
</td>
<td>
<%= Request.UserHostName %>
</td>
</tr>
</table>
<hr>
<input type=button id=cmdRequestServerVariables value="Show"
onclick=toggleTable("RequestServerVariables"); style=width:32pt>
<b>Server Variables (HttpContext.Current.Request.ServerVariables)</b><br>
<table id="tblRequestServerVariables" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<%foreach (string name in HttpContext.Current.Request.ServerVariables) {%>
<tr>
<td>
<%= name %>
</td>
<td>
<%
if (Request.ServerVariables[name] != "")
{
Response.Write(Request.ServerVariables[name]);
}
else
{
Response.Write(" ");
}
%>
</td>
</tr>
<% } %>
</table>
<hr>
<input type=button id=cmdApplication value="Show"
onclick=toggleTable("Application"); style=width:32pt>
<b>Application Variables (HttpContext.Current.Application)</b><br>
<table id="tblApplication" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<%foreach (string name in HttpContext.Current.Application) {%>
<tr>
<td>
<%= name %>
</td>
<td>
<%= Application[name] %>
</td>
</tr>
<% } %>
</table>
<hr>
<input type=button id=cmdSession value="Show"
onclick=toggleTable("Session"); style=width:32pt>
<b>Session Variables (HttpContext.Current.Session)</b><br>
<table id="tblSession" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<%foreach (string name in HttpContext.Current.Session) {%>
<tr>
<td>
<%= name %>
</td>
<td>
<%= Session[name] %>
</td>
</tr>
<% } %>
</table>
<hr>
<input type=button id=cmdRequestCookies value="Show"
onclick=toggleTable("RequestCookies"); style=width:32pt>
<b>Cookies (HttpContext.Current.Request.Cookies)</b><br>
<table id="tblRequestCookies" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<%foreach (string name in HttpContext.Current.Request.Cookies) {%>
<tr>
<td>
<%= name %>
</td>
<td>
<%= Request.Cookies[name] %>
</td>
</tr>
<% } %>
</table>
<hr>
<%
/*
'System.Web.HttpBrowserCapabilities' does not contain a definition for
'GetEnumerator'
*/
%>
<input type=button id=cmdRequestBrowser value="Show"
onclick=toggleTable("RequestBrowser"); style=width:32pt>
<b>Browser (HttpContext.Current.Request.Browser)</b><br>
<table id="tblRequestBrowser" border=1 style=display:none>
<tr>
<td><b>Key</b></td>
<td><b>Value</b></td>
</tr>
<tr>
<td>.ActiveXControls</td>
<td><%= HttpContext.Current.Request.Browser.ActiveXControl s %></td>
</tr>
<tr>
<td>.AOL</td>
<td><%= HttpContext.Current.Request.Browser.AOL %></td>
</tr>
<tr>
<td>.BackgroundSounds</td>
<td><%= HttpContext.Current.Request.Browser.BackgroundSoun ds %></td>
</tr>
<tr>
<td>.Beta</td>
<td><%= HttpContext.Current.Request.Browser.Beta %></td>
</tr>
<tr>
<td>.Browser</td>
<td><%= HttpContext.Current.Request.Browser.Browser %></td>
</tr>
<tr>
<td>.CDF</td>
<td><%= HttpContext.Current.Request.Browser.CDF %></td>
</tr>
<tr>
<td>.ClrVersion</td>
<td><%= HttpContext.Current.Request.Browser.ClrVersion %></td>
</tr>
<tr>
<td>.Cookies</td>
<td><%= HttpContext.Current.Request.Browser.Cookies %></td>
</tr>
<tr>
<td>.Crawler</td>
<td><%= HttpContext.Current.Request.Browser.Crawler %></td>
</tr>
<tr>
<td>.EcmaScriptVersion</td>
<td><%= HttpContext.Current.Request.Browser.EcmaScriptVers ion %></td>
</tr>
<tr>
<td>.Frames</td>
<td><%= HttpContext.Current.Request.Browser.Frames %></td>
</tr>
<tr>
<td>.JavaApplets</td>
<td><%= HttpContext.Current.Request.Browser.JavaApplets %></td>
</tr>
<tr>
<td>.JavaScript</td>
<td><%= HttpContext.Current.Request.Browser.JavaScript %></td>
</tr>
<tr>
<td>.MajorVersion</td>
<td><%= HttpContext.Current.Request.Browser.MajorVersion %></td>
</tr>
<tr>
<td>.MinorVersion</td>
<td><%= HttpContext.Current.Request.Browser.MinorVersion %></td>
</tr>
<tr>
<td>.MSDomVersion</td>
<td><%= HttpContext.Current.Request.Browser.MSDomVersion %></td>
</tr>
<tr>
<td>.Platform</td>
<td><%= HttpContext.Current.Request.Browser.Platform %></td>
</tr>
<tr>
<td>.Tables</td>
<td><%= HttpContext.Current.Request.Browser.Tables %></td>
</tr>
<tr>
<td>.Type</td>
<td><%= HttpContext.Current.Request.Browser.Type %></td>
</tr>
<tr>
<td>.VBScript</td>
<td><%= HttpContext.Current.Request.Browser.VBScript %></td>
</tr>
<tr>
<td>.Version</td>
<td><%= HttpContext.Current.Request.Browser.Version %></td>
</tr>
<tr>
<td>.W3CDomVersion</td>
<td><%= HttpContext.Current.Request.Browser.W3CDomVersion %></td>
</tr>
<tr>
<td>.Win16</td>
<td><%= HttpContext.Current.Request.Browser.Win16 %></td>
</tr>
<tr>
<td>.Win32</td>
<td><%= HttpContext.Current.Request.Browser.Win32 %></td>
</tr>
</table>
<hr>
<input type=button id=cmdNavigator value="Show"
onclick=toggleTable("Navigator"); style=width:32pt>
<b>Navigator Properties (javascript:navigator)</b><br>
<table id="tblNavigator" border=1 style=display:none>
<tr>
<td><b>Property</b></td>
<td><b>Value</b></td>
</tr>
<tr>
<td>appCodeName</td>
<td><script>document.write(navigator.appCodeName); </script></td>
</tr>
<tr>
<td>appMinorVersion</td> <!--appMajorVersion doesn't exist, for some
reason!-->
<td><script>document.write(navigator.appMinorVersi on);</script></td>
</tr>
<tr>
<td>appName</td>
<td><script>document.write(navigator.appName);</script></td>
</tr>
<tr>
<td>appVersion</td>
<td><script>document.write(navigator.appVersion) ;</script></td>
</tr>
<tr>
<td>browserLanguage</td>
<td><script>document.write(navigator.browserLangua ge);</script></td>
</tr>
<tr>
<td>constructor</td>
<td><script>document.write(navigator.constructor); </script></td>
</tr>
<tr>
<td>cookieEnabled</td>
<td><script>document.write(navigator.cookieEnabled );</script></td>
</tr>
<tr>
<td>cpuClass</td>
<td><script>document.write(navigator.cpuClass);</script></td>
</tr>
<tr>
<td>javaEnabled()</td>
<td><script>document.write(navigator.javaEnabled() );</script></td>
</tr>
<tr>
<td>language</td>
<td><script>document.write(navigator.language);</script></td>
</tr>
<tr>
<td>onLine</td>
<td><script>document.write(navigator.onLine);</script></td>
</tr>
<tr>
<td>opsProfile</td>
<td><script>document.write(navigator.opsProfile) ;</script></td>
</tr>
<tr>
<td>platform</td>
<td><script>document.write(navigator.platform);</script></td>
</tr>
<tr>
<td>securityPolicy</td>
<td><script>document.write(navigator.securityPolic y);</script></td>
</tr>
<tr>
<td>systemLanguage</td>
<td><script>document.write(navigator.systemLanguag e);</script></td>
</tr>
<tr>
<td>taintEnabled()</td>
<td><script>document.write(navigator.taintEnabled( ));</script></td>
</tr>
<tr>
<td>userAgent</td>
<td><script>document.write(navigator.userAgent); </script></td>
</tr>
<tr>
<td>userLanguage</td>
<td><script>document.write(navigator.userLanguage) ;</script></td>
</tr>
<tr>
<td>userProfile</td>
<td><script>document.write(navigator.userProfile); </script></td>
</tr>
</table>
<hr>
<input type=button id=cmdScreen value="Show" onclick=toggleTable("Screen");
style=width:32pt>
<b>Screen Properties (javascript:screen)</b><br>
<table id="tblScreen" border=1 style=display:none>
<tr>
<td><b>Property</b></td>
<td><b>Value</b></td>
</tr>
<tr>
<td>availHeight</td>
<td><script>document.write(screen.availHeight);</script></td>
</tr>
<tr>
<td>availLeft</td>
<td><script>document.write(screen.availLeft);</script></td>
</tr>
<tr>
<td>availTop</td>
<td><script>document.write(screen.availTop);</script></td>
</tr>
<tr>
<td>availWidth</td>
<td><script>document.write(screen.availWidth);</script></td>
</tr>
<tr>
<td>colorDepth</td>
<td><script>document.write(screen.colorDepth);</script></td>
</tr>
<tr>
<td>height</td>
<td><script>document.write(screen.height);</script></td>
</tr>
<tr>
<td>pixelDepth</td>
<td><script>document.write(screen.pixelDepth);</script></td>
</tr>
<tr>
<td>width</td>
<td><script>document.write(screen.width);</script></td>
</tr>
</table>
</form></body>
</html>
Thanks Mark !
Your script runs well. I can see many variables and value.
But what I need is the Windows-IP of the client. It isn´t shown.
Is this possible at all to get this value?
I need something like this:
Dim hostaddresses() As IPAddress
hostaddresses = Dns.GetHostByName(Dns.GetHostName).AddressList
Dim i As Integer
For i = 0 To hostaddresses.GetLength(0) - 1
Response.Write(hostaddresses(i).ToString & "<br>")
Next
<lv****@gmx.net> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... But what I need is the Windows-IP of the client. It isn´t shown.
You've got pretty much all of the possibilities in that script.
When I run it locally, several of the variables contain my machine's
internal IP address i.e. 192.168.0.4
When I browse to it on my public website, they correctly show my cable
modem's external IP address.
I can only think that there's something on your network which is
interfering... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: StinkFinger |
last post by:
All,
There are certain scripts that I have that only I want to run, both from
home and sometimes work. If I add something like this (below) to the
scripts, will this keep out unauthorized use (if...
|
by: Alexander N. Spitzer |
last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how
can I start 3 instances of the same RMI application (each started with
different properties/configs), each listening on the port...
|
by: YAN |
last post by:
Hi,
I want to get the mac address from a machine, which i have the IP address of
that machine, how can i do that?
I know how to get the mac address of the local machine from the following
code:
...
|
by: Rob |
last post by:
I am trying to write a program with VC++ 6.0 to read a txt file which
looks like this:
Network Destination Netmask Gateway Interface
Metric
0.0.0.0 0.0.0.0 ...
|
by: Abby |
last post by:
I'm writing a code to send/receive udp packet. I'll receive ip address
from user (this is the starting ip), then I'll ask user how many ip he
wants to connect to. For examples:
Please enter 1st...
|
by: Ricky Chan |
last post by:
I am using DNSQuery API to get computer name from IP address.
However, by below sample code, I don't know how to specify the DNS Address
for the field (ByVal aipServers As Integer).
any idea?...
|
by: rlc |
last post by:
I am using a toolkit, part of which creates TCP/IP connections using a
function 'Connect(<local IP>,<local Port>,<Remote IP>,<Remote Port>)'. This
function's signiture looks very similar to the...
|
by: kyle.tk |
last post by:
I am trying to write a function to convert an ipv4 address that is held
in the string char *ip to its long value equivalent. Here is what I
have right now, but I can't seem to get it to work.
...
|
by: Terry Olsen |
last post by:
I'm writing an app that communicates with computers both inside and outside
my router. So I need to determine by the remote host's IP address if I need
to send them my LAN IP or my Internet IP. ...
|
by: hhlebanon |
last post by:
I want to be able to access my trendnet ip camera from the internet without having a static IP assigned from my ISP Provider.
I have a DSL Connection at home, connected to a router (trendnet) and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |