If a user navigates to my webpage how can I programmatically determine they are accessing my page from within the Intranet? (Not interested in NTLM or Windows forms authentication. Need a programmatic method.)
+1
A:
You can read the IP address out of the Http request and then check that address against the range that is the local intranet.
Shiraz Bhaiji
2009-06-30 20:41:27
Is there a method of checking using the domain name?
2009-06-30 20:43:52
Checking the domain name checks who he is and that he is authenticated, not where he is.
Shiraz Bhaiji
2009-06-30 21:07:30
A:
Consider these two snippets for obtaining the client's IP address:
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]
or
//this is a wrapper for REMOTE_ADDR:
HttpContext.Current.Request.UserHostAddress
If it falls within 10.x.x.x, or 192.168.x.x, then you know your visit is from the inside.
Otherwise, you could check the URL for a known good server name or alias:
HttpContext.Current.Request.ServerVariables["SERVER_NAME"]
p.campbell
2009-06-30 20:51:43