Client User and Computer Name in ASP.NET

Discussion in 'Domain names / DNS' started by stockarisec, Dec 4, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,

    How do i get Client username,client Comptername and client IPAddress in Asp.net. I used request object but it i recieve server username aspnet--
    Please help

    Thanks
     
  2. Username: HttpContext.Current.User.Identity.Name
    IP Address: Request.UserHostAddress
    Computer Name: This is impossible over the internet. You might be able to get close by attempting to resolve the IP address to a hostname via DNS but this will only get you as far as determining an ISP host name and not an end users' client host name. In an intranet application, DNS IP resolution can be made to work to successfully resolve to an end users' computer host name.
     
  3. i used IP Address: Request.UserHostAddress and Request.ServerVariables("REMOTE_ADDR"), but they all return aspnet server IPaddress 50...... in any computer
    Is there anyother way, I am desparate need of it please

    Thanks
     
  4. After I used the above Infor then following results were gotten:
    HttpContext.Current.Request.UserHostAddress = 50.15.142.33
    HttpContext.Current.User.Identity.Name =
    HttpContext.Current.Request.LogonUserIdentity.Name = WEB704\aspnet_852983
    If anyone know what to do Please tell me
    Thanks
     
  5. The results you've seen with Request.UserHostAddress returning an IP address means it's working. Explain in detail what you're expecting / hoping to achieve and I'll try and help again.
     
  6. Hi,
    check out this code...

    HttpContext.Current.Request.UserHostAddress;
    or
    HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

    To get the IP address of the machine and not the proxy use the following code

    HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

    It might be useful for you.
     
  7. Hi GauravYadav

    I used HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FOR"),but it return nothing
    I used HttpContext.Current.Request.UserHostAddress and HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
    but they all return Client Server IP Address not Client Machine IP Address

    I need to Get Client machine UserName and Client Machine IP Address in my ASP.NET WEB Page. Maybe i am doing something wrong, can I have complete code if possible or Is there any setting that is needed to be done in the web.config file

    Please Help I am new in web hosting

    Thanks for your help
     
  8. Hi CrystalCMS
    Joe

    I want to know the computer Username and IP Address of any one who logged on to the website as to know duplicate logon-Fraud activitties, I need especially the IPAddress that Uniquely Identifies a particular computer used to log on to the web site

    Thanks for your help
    Ike
     
  9. UserName
    User.Identity.Name will be populated with an authenticated users' username if your application implements regular authentication. Either Windows or Forms authentication works this way but since you've tried this and this property is returning an empty string, I have to assume that your application does not implement a standard authentication mechanism.

    IP Address
    You mentioned that Request.UserHostAddress is returning 50.15.142.33 but you advised that you need to capture the IP address of the client making the request. This means I have to assume that 50.15.142.33 is not the IP address you're hoping to capture. I expect that 50.15.142.33 is actually the IP address for the WAN side of a public facing router or firewall and not the client behind it.

    There's a real problem attempting to use IP addresses as the unique identifying attribute for connected clients and is in my opinion not a very good idea for these reasons:
    1. IP addresses can be spoofed by someone who intentionally wants to prevent their real IP address being transmitted. In fact all of the IP address related headers for a web request can be edited / blanked / mangled prior to a request being made.
    2. Clients behind firewalls / routers that implement NAT can be effectively hidden from the internet meaning that in many cases the best you could hope to achieve is to capture the IP address of the network gateway. This could be the gateway to hundreds of internet connected clients. Not being able to identify an individual computer may or may not be an issue for your application.
    3. Clients connected using an anonymizing service (think Tor) are completely concealed from an IP address determination perspective.
    4. Clients connected using a remote proxy or filter will have an undetectable IP address.
    I've no statistics on the general question about how reliable IP addresses can possibly be for identification purposes but one thing is certain: you can never be sure that the IP address you capture is the real IP address of a client.

    Another method I've seen implemented to attempt to determine uniqueness involved using a cookie that contained a system generated unique identifier. This isn't ideal either since cookies can be removed / blocked or modified (if not encrypted in some way).

    It's a problem that needs a solution but unfortunately the W3C doesn't lay down the law for the http protocol with respect to this problem, so we're on our own trying to solve this one.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page