How can i get the computer client computer name not the IP address

I have been trying to get the client computer name and ip address. For the IP address i can get it. For the computer name i a gain get the IP address. Is there some thing i have to do in order to get the computer name not the IP. My application runs on a server in the company's intranet. Below is my sample code.

I also want to get the "timea" just in hour/minutes format. At the moment timea is bringing to much details(I dont if there seconds or millisecoinds, but just to much figures)

Dim username As String = HttpContext.Current.User.Identity.Name

Dim timea As String = DateTime.Now.TimeOfDay.ToString

 

Dim myconnection_string As SqlConnection

myconnection_string =

New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\safetydata.mdf;Integrated Security=True;User Instance=True")

Const sql As String = "INSERT INTO Tracker(date,incident_description,immediate_action,reported_by,person_involved,computer_name,ip_address,time,loggedin_windows_account) values (@date,@incident_description,@immediate_action,@reported_by,@person_involved,@computer_name,@ip_address,@time,@loggedin_windows_account)"

Dim mycomand As New SqlCommand(sql, myconnection_string)

mycomand.Parameters.AddWithValue(

"@date", DateTime.Now.Date)

mycomand.Parameters.AddWithValue(

"@incident_description", description.Text)

mycomand.Parameters.AddWithValue(

"@immediate_action", immediateaction.Text)

mycomand.Parameters.AddWithValue(

"@reported_by", raiser.Text)

mycomand.Parameters.AddWithValue(

"@person_involved", involved.Text)

mycomand.Parameters.AddWithValue(

"@computer_name", Context.Request.UserHostName)

mycomand.Parameters.AddWithValue(

"@ip_address", Context.Request.UserHostAddress)

mycomand.Parameters.AddWithValue(

"@loggedin_windows_account", username)

mycomand.Parameters.AddWithValue(

"@time", timea)

myconnection_string.Open()

mycomand.ExecuteNonQuery()

myconnection_string.Close()


--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
0
Nick
4/17/2007 2:04:40 PM
asp.net.security 27051 articles. 1 followers. Follow

10 Replies
925 Views

Similar Articles

[PageSpeed] 4

If the clients are not using a proxy or nat you can use the dns.gethostbyaddress to get the host info.

 

 

0
Villain
4/17/2007 4:56:35 PM
No i dont want to get the Host info. What i need to get is the client information.
--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
0
Nick
4/18/2007 5:42:23 AM

Use

Environment.MachineName


Everything is possible!
0
atsofttech
4/18/2007 6:11:20 AM

By using Environment.MachineName you will get Server Name. Because the script runs in the Context of server.

Try this: 

Dim host As System.Net.IPHostEntry 
host = System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST")) 
mycomand.Parameters.AddWithValue("@computer_name", host.HostName) 

Retrieve the IP address of the Client and then access its name.

0
omerkamal
4/18/2007 6:16:38 AM

This may help you

http://www.visualbasicscript.com/m_2393/tm.htm


Everything is possible!
0
atsofttech
4/18/2007 6:36:48 AM

Ok thanks very much for all the replies, i can now get the computer name. But what about the windows User Name of the person logged in. Since my page is accessed by any one with a computer on our intranet, it would make good sense if i got the loged_In windows User Name for security purposes because computers at times are shared by employees. so going by the computer name may not be enough in an environment where computers are shared by diffrent people with different windows login accounts.


--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
0
Nick
4/18/2007 7:41:06 AM

There is an issue in OS implementation of DNS with System.Net utilizes. (this why the method is now obsolete)

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=97815

One more thing: 

you are getting the correct Computer name when you are running the Code locally.

If you run the Code after uploading to the server you will get the External Router Name (my guess) instead.

Why?

Because your Local IP is not a Static rather Virtually assigned from the ISP Router (Gateway). 

The code will resolve values for your External IP (Router IP) but not of the actuall EndPoint.

0
omerkamal
4/18/2007 7:45:11 AM
Thanks. I now wont waste too much time on some thing that wont work at the end olf it all.
--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
0
Nick
4/18/2007 8:27:01 AM

It would be nice if you paste your final working code here to help others

thanks


Everything is possible!
0
atsofttech
4/18/2007 12:53:17 PM

Ok this is the code. 

Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs)

 Dim username As String = HttpContext.Current.User.Identity.Name Dim timea As String = DateTime.Now.TimeOfDay.ToString Dim host As System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(Request.ServerVariables.Item("REMOTE_HOST")) Dim myconnection_string As SqlConnection

myconnection_string = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\safetydata.mdf;Integrated Security=True;User Instance=True")

Const sql As String = "INSERT INTO Tracker(date,incident_description,immediate_action,reported_by,person_involved,computer_name,ip_address,time) values (@date,@incident_description,@immediate_action,@reported_by,@person_involved,@computer_name,@ip_address,@time)"

Dim mycomand As New SqlCommand(sql, myconnection_string)

mycomand.Parameters.AddWithValue("@date", DateTime.Now.Date)

mycomand.Parameters.AddWithValue("@incident_description", description.Text)

mycomand.Parameters.AddWithValue("@immediate_action", immediateaction.Text)

mycomand.Parameters.AddWithValue("@reported_by", raiser.Text)

 mycomand.Parameters.AddWithValue("@person_involved", involved.Text)

 mycomand.Parameters.AddWithValue("@computer_name", host.HostName)

mycomand.Parameters.AddWithValue("@ip_address", Context.Request.UserHostAddress)

 mycomand.Parameters.AddWithValue("@time", timea)

myconnection_string.Open()

 mycomand.ExecuteNonQuery()

myconnection_string.Close()

 End Sub


--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
0
Nick
4/19/2007 6:59:27 AM
Reply:

Similar Artilces:

How to get IP address from the client computer
Dear All, Please send me a code to explain how to get client IP address when he/she visited my webpage? Regards LGT You can use the Request object: Request.UserHostAddress Stanley Tan theSpoke Blog Or this code will work.... Dim sIPAddress sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If sIPAddress = "" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR") Zath In the United Kingdom at least, getting the IP address is usually not much use, as temporary IP numbers are assigned to the client compute...

Change the Computer Name and IP of my computer and then eas can not start
I shutdowned my eas 3.6.1 and changed the computer ,on which this eas is installed, of the computer name and ip address. Then, when the eas was started again, the error promped that the eas is finding the old "ServerName" and can not be started. Whant am I supposed to do with eas configurations or other settings about my computer to start the eas again? Best Regards. I did this as well and had to rename my computer back to the old name and reboot ( good ole microsoft! ), change the listners to 'Localhost' and then change the machine name and reboot and then g...

How can the PB get the local IP address of the computer?
Is there any function call to get the IP of the PB Client itself? THX Take a look at this site http://eric.aling.tripod.com/PB/tips/pbtip14.htm Good luck Sree > Is there any function call to get the IP of the PB Client > itself? > THX There is an example on my website http://www.topwizprogramming.com/freecode.html which does this without using an external dll. Download the example titled 'Ping'. Roland <Tom> wrote in message news:43018053.1d28.1681692777@sybase.com... > Is there any function call to get the IP of the PB Client > itse...

How can the PB get the local IP address of the computer?
As titled THX Tom wrote: > As titled > THX PB Client or Web Client? PB Client Is there any function call to get the IP of the PB Client itself? > Tom wrote: > > As titled > > THX > > PB Client or Web Client? There are some code samples that show how to do this. Perhaps you might repost the question in a non-web app section (i.e., general) and we'll follow up there. On 12 Aug 2005 03:03:11 -0700, Tom wrote: >PB Client >Is there any function call to get the IP of the PB Client >itself? > >> Tom wrote: >> &g...

Getting 'real' IP address from client computer
Hello, I created (with help from my last post, thanks!!) a set of download links via ASP.NET and VB.NET. Now, I would like to log the IP address and any other user information I can get from the client computer. I always got this information from my FTP server (Serv-U), but now I can't seem to capture it. My server is behind a firewall, so it appears when I get the IP address it is always my own address. Here is the code I was using to get the IP: 'Get Client IP Address Public Function GetHostIP() As IPAddress() Dim iphe As IPHostEntry = Dns.GetHostByName(Dns.GetHos...

How to get the computer name by given IP address or vice versa
Hi, All How to get any computer name that connected through router by given IP address or vice versa, e.g. by given "192.128.1.103', it can return 'VCS', by given '192.168.1.100', it can return 'WILLIAM', or by given 'VCS', it can return '192.168.1.103'? Thanks William William Yu wrote: > Hi, All > > How to get any computer name that connected through router by given > IP address or vice versa, e.g. by given "192.128.1.103', it can > return 'VCS', by given '192.168.1.100', it can r...

Get Client Computer Name
I'm attempting to retrieve the client computer name from my ASP.NET web application. I'm using System.Net.Dns.GetHostName(). This is returning the computer name of the web server. The application is being used an a Windows 2000 Active Directory Intranet. How do I get the name of the client computer, not the web server name? Thank you. Try either Request.ServerVariables["REMOTE_HOST"] for the client computername or Request.ServerVariables["REMOTE_ADDR"] for the client ip address Regards Fredr!k Close... Request.ServerVariables("remote_a...

How can I get a computer name
Hi! How can I get a computer name, which is running my application? Sancho Sandris The platform service of the PFC has an of_GetComputerName() function. Good Luck Michael Walker Cascadia Software Sandris wrote: > Hi! > How can I get a computer name, which is running my application? > > Sancho > > > ...

How can I get the computer name?
hi, somebody there can help me please? I'm new in ASP.NET, I'm working in something where I need get the client computer name....how can i do that?........I think it could be possible with some script. Ask the user. there's no easy way to just get this automatically.RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadableJason Brown - MVP, IIS...

Computer Name and IP Address
I'd link to get the computer name and the IP Address for the machine -- --- Thanks... Osama Diab i-o@link.net diab98@hotmail.com IP Address have a look at=20 http://eric.aling.tripod.com/PB/tips/pbtip14.htm Computer name , you need an api=20 Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"=20 (ByVal lpBuffer As String, nSize As Long) As Long =B7 lpBuffer Points to a buffer to receive the null-terminated character string=20 containing the computer name. =B7 nSize Points to a variab...

Getting the computer name of the client user
Is it possible to get the client's computer name?ez Ez416:Is it possible to get the client's computer name? I dont think so.I do not think a post/get request will send such information. It can be done using an ActiveX object, but the client computer's setting has to be set to a ridiculously low level.When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.My latest ASP.NET AJAX blog entries. Probably it is enough to use Request.UserHostName and Request.UserHostAddress (on server-side). no?[MCPD: WEB]...

Problems with ip address/computer name
 Hello all, I hope I am posting this in the right section, if not please forgive me.I have created a web based application using Visual Web Designer 2005 along with Sql Server 2005 Express. All is working well with the mechanics of the site but I have a problem that keeps happening and is odd. The application runs on our intranet and is using Windows Authentication. The problem is this: sometimes users can connect to the protected part of the site that needs users to login with their network credentials  using  the computer name that is hosting  the site (ie. http://...

How I can get Ip address of a Client?
What are the most easy way for get the Ip address of a Client that wish connect to Jaguar? > What are the most easy way for get the Ip address of a Client that wish > connect to Jaguar? From a PB or Java Component, see http://www.rgagnon.com/pbdetails/pb-0138.html From a JSP, see http://www.rgagnon.com/javadetails/java-0363.html Bye. -- Real Gagnon from Quebec, Canada * Looking for Java or PB snippets ? Visit Real's How-to * http://www.rgagnon.com/howto.html Thanks "Real Gagnon", I have read the article but there is a problem, I'd...

Network scanner for IP addresses and computer names
--____VBEHHYQVGIAZUJOKPYVV____ Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; modification-date="Wed, 27 Jul 2010 03:00:48 -0400" Good morning. Unfortunately, I have let the IP address assignments in my small (80 node = or so) network get a little messy. I have 192.168.1.150 - 192.168.1.200 = set for DHCP. The balance of the nodes are statically assigned. =20 I would like to keep the low range for my equipment (servers, routers, apc = management equipment, etc) and then use higher numbers f...

Web resources about - How can i get the computer client computer name not the IP address - asp.net.security

Computer - Wikipedia, the free encyclopedia
"Computer technology" and "Computer system" redirect here. For the company, see Computer Technology Limited . For other uses, see Computer (disambiguation) ...

Computer - Wikipedia, the free encyclopedia
"Computer technology" and "Computer system" redirect here. For the company, see Computer Technology Limited . For other uses, see Computer (disambiguation) ...

Computer Show
The first episode premiered at XOXO last month, and it brought the house down. I think you’re best off going in cold — just grab a beverage and ...

Facebook is giving away a powerful new technology for building smart computers
... new fields in tech: machine learning and artificial intelligence. Facebook is giving away for free some hardware designs that make computers ...

Most Americans would not give up the steering wheel to a computer
... "Despite the hype around driverless cars, it seems that it's actually a minority of us who want to surrender the steering wheel to a computer," ...

Google’s mind-bending quantum computer actually works
... sci-fi nerds lose sleep in fear of the robot apocalypse. The breakthrough sounds simple, but it has massive implications: The quantum computer ...

Google: We have proof that our quantum computer really works
Google announced a breakthrough in the field of quantum computing Wednesday. The company thinks it's found a quantum algorithm that solves problems ...

Janam's XM70 Rugged Mobile Enterprise Computer Has Dual OS Support
The XM70 handheld lets businesses use one operating system to start and then move to a different OS in the future, if desired.

Google: Our quantum computer is 100 million times faster than a conventional system
Google has been working with its quantum computer for several years now, and finally has results that prove the D-Wave 2 can perform certain ...

Facebook Says Its New AI Research Computers Are Twice As Powerful As Anything Before
Code-named "Big Sur," the new computing architecture is the result of 18 months of design work with partners like Quanta and Nvidia. Facebook ...

Resources last updated: 12/11/2015 4:51:07 AM