Last post Feb 01, 2013 10:10 AM by Rion Williams
Feb 01, 2013 05:33 AM|Yavuz B.|LINK
i need to get some information about users from the active directory. But before i do that the user must specify a domain name.
Which is the fastest way to check if the provided domain name is valid and a connection to the ad is possible?
Feb 01, 2013 10:10 AM|Rion Williams|LINK
You may want to consider making a quick HttpRequest just using the HEAD method
(to avoid pulling all of the content) and checking the Response to see if it was valid :
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(yourUrl);
request.Timeout = 15000; //Allow 15 seconds to process the Request otherwise timeout
request.Method = "HEAD";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
return response.StatusCode == HttpStatusCode.OK;
as per the C# Wizard Jon Skeet's suggestion.