Du kan sagtens lave en funktion, der kalder DK Hostmasters whois-database. Jeg har selv lavet én der kører på
http://www.discountdomains.dk/domaenetester.aspx// *******************************************************************
// TestDomain() - Tester et domæne hos whois-authority
// *******************************************************************
public static bool TestDomain(string domain)
{
bool available = false;
TcpClient tcpClient = null;
NetworkStream networkStream = null; ;
try
{
// Split domænenavn og domæne-endelse så domæne-endelse kan benyttes
string[] domainParts = new string[1];
char[] splitter = { '.' };
domainParts = domain.Split(splitter);
// Forbind til whois-serveren
tcpClient = new TcpClient(GetWhoisAuthority(domainParts[1]), 43);
networkStream = tcpClient.GetStream();
// Send domænet til whois-serveren
byte[] buffer = Encoding.ASCII.GetBytes(domain + "\r\n");
networkStream.Write(buffer, 0, buffer.Length);
// Læs resultatet fra hostmaster
StreamReader streamReader = new StreamReader(tcpClient.GetStream(), Encoding.ASCII);
string strServerResponse = streamReader.ReadToEnd();
// Sæt available til true hvis response matcher
if (strServerResponse.Contains(GetWhoisResponse(domainParts[1])))
available = true;
}
catch (Exception ex)
{
throw new Exception("Der opstod en uventet fejl!<br>" + ex.Message);
}
finally
{
networkStream.Close();
tcpClient.Close();
}
return available;
}
// *******************************************************************
// GetWhoisAuthority() - Henter whois-authority for valgt domæne
// *******************************************************************
private static string GetWhoisAuthority(string domainExtensions)
{
Hashtable hashtable_Authorities = new Hashtable();
hashtable_Authorities.Add("dk", "whois.dk-hostmaster.dk");
hashtable_Authorities.Add("com", "whois.crsnic.net");
hashtable_Authorities.Add("net", "whois.crsnic.net");
hashtable_Authorities.Add("org", "whois.crsnic.net");
hashtable_Authorities.Add("biz", "whois.neulevel.biz");
hashtable_Authorities.Add("info", "whois.afilias.info");
hashtable_Authorities.Add("name", "whois.nic.name");
hashtable_Authorities.Add("eu", "whois.eu");
hashtable_Authorities.Add("cc", "whois.nic.cc");
hashtable_Authorities.Add("cn", "whois.cnnic.net.cn");
hashtable_Authorities.Add("tw", "whois.twnic.net.tw");
hashtable_Authorities.Add("us", "whois.nic.us");
hashtable_Authorities.Add("hk", "whois.hkirc.net.hk");
hashtable_Authorities.Add("as", "whois.nic.as");
hashtable_Authorities.Add("at", "whois.nic.at");
hashtable_Authorities.Add("be", "whois.dns.be");
hashtable_Authorities.Add("ch", "whois.nic.ch");
hashtable_Authorities.Add("de", "whois.denic.de");
hashtable_Authorities.Add("gl", "whois.ripe.net");
hashtable_Authorities.Add("it", "whois.nic.it");
hashtable_Authorities.Add("li", "whois.nic.li");
hashtable_Authorities.Add("pl", "whois.dns.pl");
//hashtable_Authorities.Add("se", "whois.nic-se.se");
hashtable_Authorities.Add("nu", "whois.nic.nu");
if (hashtable_Authorities.Contains(domainExtensions))
return hashtable_Authorities[domainExtensions].ToString();
else
return "whois.crsnic.net";
}
// *******************************************************************
// GetWhoisResponse() - Henter respons for valgt top-level domæne
// *******************************************************************
private static string GetWhoisResponse(string domainExtensions)
{
Hashtable hashtable_Responses = new Hashtable();
hashtable_Responses.Add("dk", "No entries found for the selected source.");
hashtable_Responses.Add("com", "No match for");
hashtable_Responses.Add("net", "No match for");
hashtable_Responses.Add("org", "NOT FOUND");
hashtable_Responses.Add("biz", "Not found:");
hashtable_Responses.Add("info", "NOT FOUND");
hashtable_Responses.Add("name", "No match.");
hashtable_Responses.Add("eu", "Status: FREE");
hashtable_Responses.Add("cc", "No match for");
hashtable_Responses.Add("cn", "no matching record");
hashtable_Responses.Add("tw", "No Found");
hashtable_Responses.Add("us", "Not found:");
hashtable_Responses.Add("hk", "Domain Not Found");
hashtable_Responses.Add("as", "Domain Not Found");
hashtable_Responses.Add("at", "nothing found");
hashtable_Responses.Add("be", "Status: FREE");
hashtable_Responses.Add("ch", "We do not have an entry in our database matching your query");
hashtable_Responses.Add("de", "Status: free");
hashtable_Responses.Add("gl", "No entries found in the selected source(s)");
hashtable_Responses.Add("it", "No entries found");
hashtable_Responses.Add("li", "We do not have an entry in our database matching your query");
hashtable_Responses.Add("pl", "No information about domain");
//hashtable_Responses.Add("se", "No data found");
hashtable_Responses.Add("nu", "NO MATCH for domain");
if (hashtable_Responses.Contains(domainExtensions))
return hashtable_Responses[domainExtensions].ToString();
else
return "";
}
Here you go :)