Entries from September 2007

September 25, 2007

Chak de India!

Kudos to Team India for bringing home the Twenty20 World cup.

Hats off to M S Dhoni and his boys for this feat.

Photo courtesy: http://worldtwenty20.yahoo.com/

September 21, 2007

How to find the NetBIOS name of a domain

Following is the C# code needed to find the NetBIOS name of a domain from Active Directory:
using System;
using System.DirectoryServices;
void PrintNetBIOSName()
{
    string netBIOSName = null;
    DirectoryEntry rootDSE = new DirectoryEntry(
        ”LDAP://<server address>/rootDSE”,
        ”<username>”, “<password>”);
    string domain = (string)rootDSE.Properties[
        "defaultNamingContext"][0];
    if (!String.IsNullOrEmpty(domain))
    {
        DirectoryEntry parts = new DirectoryEntry(
            ”LDAP://<server address>/CN=Partitions
            ,CN=Configuration,” + domain,
            ”<username>”, “<password>”);
        foreach (DirectoryEntry part in parts.Children)
        {
            if ((string)part.Properties[
                "nCName"][0] == domain)
            {
                netBIOSName = (string)part.Properties[
                    "NetBIOSName"][0];
                break;
            }
        }
        Console.WriteLine(netBIOSName);
    }
}
REFERENCES:

http://home.hot.rr.com/graye/CodeSnippets.htm
Binding to Active Directory Domain Services [...]

September 13, 2007

Exposing events from custom controls in .NET

Recently, one of my very good friends asked me to help him with a problem. I noticed that he was using a custom control. To solve the problem, I needed to expose an event from the control. This was something I had never bothered about before. I stumbled upon this wonderful article in my quest [...]