fetching domain whois information using asp.net

There are several domain whois checking websites available today. For example, who.is and domaintools.com are broadly used. It is very easy to develop such web application of your own. All you need to query the whois server for a domain in question. Here is the sample code, that fetches the whois information associated with the domain provided in the query.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string domainname = Request.QueryString["domain"].ToString();
        TcpClient objTCPC = new TcpClient();
        objTCPC.Connect("whois.enom.com", 43);
        string strDomain = domainname;// +"\\r\\n";
        byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain);
        Stream objStream = objTCPC.GetStream();
        objStream.Write(arrDomain, 0, strDomain.Length);
        StreamReader objSr = new StreamReader(objTCPC.GetStream(),Encoding.ASCII);
        string strServerResponse = objSr.ReadToEnd();
        strServerResponse = Regex.Replace(strServerResponse, "\n", "<br>");
        Response.Write(strServerResponse);
        objTCPC.Close();


    }
}

Above code will query the whois server whois.enom.com to get the whois information of ask4asp.net. You can use any whois servers. I am listing some of them below.
whois.arin.net
whois.ripe.net
whois.apnic.net
whois.lacnic.net
whois.afrinic.net
whois.enom.com, etc.
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Disadvantages Of Asp.Net Full Trust Security Level

Why shouldn’t we allow any domain to run Asp.Net application under the Full Trust level? Below are the reasons:

If the Asp.Net application is allowed to run under Full Trust level then it can:

    1. Browse(create/edit and delete too) files in the Windows directory using the System.IO namespace.
    2. Browse(create/edit and delete too) folders in the Program Files directory using the System.IO namespace.
    3. Browse(create/edit and delete too) files in the System32 directory using the System.IO namespace.
    4. Output of the OS name and version number using the System.Environment class.
    5. Output of the server's local IP address using server variables, etc.

In short, full trust Asp.Net application can do anything with the server since it gains the full access of the server when run under the Full Trust.

Therefore, do not ever offer any domain a full trust level in the shared server if your are a shared hosting provider. :)


Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

add update windows users windows user management

Sometimes, we may need to add/update the windows user management functionality in our windows application or windows service. In such cases, we can just use the 'net user' functionality of the windows operating system. Refer the below command to perform user operations.

NET USER
[username [password | *] [options]] [/
         username {password | *} /ADD
         username [/DELETE] [/DOMAIN]

We can easily fire these commands using Process .NET class. Refer the examples in C# below

Process p = System.Diagnostics.Process.Start("c:\\windows\\system32\\net","user username newpassword".
//This will update the user username with the password newpassword

Process p = System.Diagnostics.Process.Start("c:\\windows\\system32\\net","user username newpassword /ADD".
//This will add a new user wth username username and password newpassword

The second arcument of above start function are the arguments to the command "net"

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList






Quality & Affordable Web Development | About the Author | Hosted By Windows Hosting | Discuss With Experts At Webmaster Forums