Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 01, 2013 02:10 PM by Rion Williams
Feb 01, 2013 09:33 AM|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 02:10 PM|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.