tags:

views:

156

answers:

0

I am using DirectoryEntry my question is how can i use DirectoryEntry to get information of remote iis. I have passed it through constructor but its seems to fail.

DirectoryEntry deServer = new DirectoryEntry("IIS://server/W3SVC", "username", "password", AuthenticationTypes.Secure | AuthenticationTypes.Encryption);            

try
{
    string siteid = null;
    foreach (DirectoryEntry bb in deServer.Children)
    {
        if (bb.SchemaClassName == "IIsWebServer")
        {
            if (websitename == bb.Properties["ServerComment"].Value.ToString()) siteid = bb.Name;
        }
    }
    if (siteid == null) return null;
    return siteid;
}
catch
{
    return null;
}

Thanks inadvance, Bharat