Solved

Need to gather FQDN from users

Posted on 2015-02-20
17
32 Views
Last Modified: 2015-06-02
I need to collect from specific users FQDN. It is Intranet and we will set up the webpage, preferable in asp.net with vb
where the user will login and I will send to DB theirs FQDN
We collect it to prevent certain updates till it's time.
0
Comment
Question by:LessIsMore
  • 9
  • 7
17 Comments
 
LVL 17

Assisted Solution

by:OriNetworks
OriNetworks earned 500 total points
ID: 40622313
Do you mean fqdn of their computer? You could use UserHostName
https://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostname.aspx
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40622316
FQDN isn't all that reliable.  I say that because depending on the size of your company you can have NATs in the way which might prevent you from achieving what you're looking for.

Let's also say user1 logs in, performs an update from 1 computer, and the update happens.
User1 then travels to a different location, logs in, and performs the update.  The user experience will be different based on the user's location.

You're much better off tying the users to some kind of group, and driving your logic off the groups.
0
 

Author Comment

by:LessIsMore
ID: 40623099
OnNetworks,
Can you elaborate a little, give an example how to use it on page?
Kyle,
It's temporary measure until we will find better solution. We have a national operations and need a quick list of computer that needs to be protected from certain update.
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40625746
In VB.NET
Dim hostname as String = Server.HtmlEncode(Request.UserHostName)

Open in new window


In C#
String hostname = Server.HtmlEncode(Request.UserHostName);

Open in new window


As Kyle mentioned, this method(via web) of acquiring hostnames isn't that reliable, and can sometimes contain the IP address only.
0
 

Author Comment

by:LessIsMore
ID: 40625942
yes, I tried to do it and it has only IP address.
I am not sure what else can I do since I was told to get FQDN not IP address.
Not sure about Kyle's logic to say the honest.
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40626475
If all machines are internal you should be able to do lookup the name by DNS assuming they are registered/setup with DHCP although I would test this thoroughly. I think this is as close as you can get with a web form.

Public Function GetHostNameFromIP(ByRef IP As String) As String 
    Dim host As System.Net.IPHostEntry        
     host = System.Net.Dns.GetHostByAddress(IP)  
     return host.HostName  
End Function 

Open in new window

0
 

Author Comment

by:LessIsMore
ID: 40630891
OnNetwork, thanks for helping me. I cannot figure out how to gather the result to sql server. I cannot even see if I have results, I tried Response.Write, Console.Write and it does not display the result of the function.
Can you help with that?
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40631169
I've changed things around a bit. Since we know UserHostName is not reliable I've switched it to UserHostAddress since we only really need to resolve the ip address. If you pass that value to the function I gave you, it will return a string. If you use this code in your Page_Load, it should write to the top of the page "Resolved Hostname is:[ComputerName]". If it only writes "Resolved Hostname is:" then you're out of luck because not even resolving the name works in your situation


'put this in Page_Load
Response.Write("Resolved Hostname is:" & GetHostName())


'put this with the rest of your functions
Public Function GetHostName() As String 
    String ipAddress = Server.HtmlEncode(Request.UserHostAddress)
    Dim host As System.Net.IPHostEntry        
     host = System.Net.Dns.GetHostEntry(ipAddress )  
     return host.HostName  
End Function 

Open in new window

0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:LessIsMore
ID: 40631408
I get BC30109: 'String' is a class type and cannot be used as an expression.
on line 7
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40632124
I corrected my declaration of string. That's what i get for working c# and vb.net at the same time.

'put this in Page_Load
Response.Write("Resolved Hostname is:" & GetHostName())


'put this with the rest of your functions
Public Function GetHostName() As String 
    Dim ipAddress As String = Server.HtmlEncode(Request.UserHostAddress)
    Dim host As System.Net.IPHostEntry        
     host = System.Net.Dns.GetHostEntry(ipAddress )  
     return host.HostName  
End Function 

Open in new window

0
 

Author Comment

by:LessIsMore
ID: 40633255
Sorry, I get blank page, nothing, nada.

Below is what I get response for. Unfortunately Computer name is the name of my server.
I will go with IP address and will match it to DNS. It complicates things since we do not have static IP addresses.
FQDN would be better.
Dim hostname As String = Server.HtmlEncode(Request.UserHostName)
   
    Response.Write("IP Address is " & hostname & " ")
       
Dim IPAddress As String

    IPAddress = Dns.GetHostName()
   
    Response.Write("ComputerName is " & IPAddress)
     
Dim ip As String = Request.ServerVariables("REMOTE_ADDR")
    Response.Write("IP address " & ip)
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40633263
If FQDN is absolutely required would deploying some kind of small application or script be a better solution?
0
 

Author Comment

by:LessIsMore
ID: 40633686
sure, I thought this is what we are doing, script?
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40634207
What you requested was a web page. What i an suggesting is either a .net application or some other scripting method where the person loggin onto the computer knows where to get the script and then runs it. Would this be useful in your scenario?
0
 
LVL 17

Expert Comment

by:OriNetworks
ID: 40634221
As an example if you had a .net console application that runs everytime a user logs in you could get the local computer name by
Dim computername as string = My.Computer.Name & "." & System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName

Open in new window

0
 

Author Comment

by:LessIsMore
ID: 40634238
Can I create this .net console app? It's over my head.
0
 
LVL 17

Accepted Solution

by:
OriNetworks earned 500 total points
ID: 40634513
a .net console app is just a different project type in visual studio. Its still .net but it is a program that you run on each computer, not from a website.

Your official answer for this question is no, you cannot reliably collect a fqdn or even hostname of a client computer from a webpage using .net or javascript.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Class Library Dynamics For Connectstring Information 2 17
Sending Attachment via CDO 3 57
How to access a DataBinder.Eval variable using C# ? 4 27
Server Error 11 47
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 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

6 Experts available now in Live!

Get 1:1 Help Now