国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 應(yīng)用 > 軟件技巧 > 正文

用C#操縱IIS

2024-07-16 17:44:52
字體:
供稿:網(wǎng)友
using System;
using System.DirectoryServices;
using System.Collections;
using System.Text.RegularExpressions;
using System.Text;


/**
* @author 吳海燕
* @email wuhy80-usual@yahoo.com
* 2004-6-25 第一版
*/
namespace Wuhy.ToolBox
{
/// <summary>
/// 這個類是靜態(tài)類。用來實(shí)現(xiàn)管理IIS的基本操作。
/// 管理IIS有兩種方式,一是ADSI,一是WMI。由于系統(tǒng)限制的原因,只好選擇使用ADSI實(shí)現(xiàn)功能。
/// 這是一個遺憾。只有等到只有使用IIS 6的時候,才有可能使用WMI來管理系統(tǒng)
/// 不過有一個問題就是,我現(xiàn)在也覺得這樣的一個方法在本地執(zhí)行會比較的好。最好不要遠(yuǎn)程執(zhí)行。
/// 因?yàn)槟菢有枰加孟喈?dāng)數(shù)量的帶寬,即使要遠(yuǎn)程執(zhí)行,也是推薦在同一個網(wǎng)段里面執(zhí)行
/// </summary>
public class IISAdminLib
{
#region UserName,Password,HostName的定義
public static string HostName
{
get
{
return hostName;
}
set
{
hostName = value;
}
}


public static string UserName
{
get
{
return userName;
}
set
{
userName = value;
}
}


public static string Password
{
get
{
return password;
}
set
{
if(UserName.Length <= 1)
{
throw new ArgumentException("還沒有指定好用戶名。請先指定用戶名");
}


password = value;
}
}


public static void RemoteConfig(string hostName, string userName, string password)
{
HostName = hostName;
UserName = userName;
Password = password;
}


private static string hostName = "localhost";
private static string userName;
private static string password;
#endregion


#region 根據(jù)路徑構(gòu)造Entry的方法
/// <summary>
/// 根據(jù)是否有用戶名來判斷是否是遠(yuǎn)程服務(wù)器。
/// 然后再構(gòu)造出不同的DirectoryEntry出來
/// </summary>
/// <param name="entPath">DirectoryEntry的路徑</param>
/// <returns>返回的是DirectoryEntry實(shí)例</returns>
public static DirectoryEntry GetDirectoryEntry(string entPath)
{
DirectoryEntry ent;


if(UserName == null)
{
ent = new DirectoryEntry(entPath);
}
else
{
// ent = new DirectoryEntry(entPath, HostName+"//"+UserName, Password, AuthenticationTypes.Secure);
ent = new DirectoryEntry(entPath, UserName, Password, AuthenticationTypes.Secure);
}


return ent;
}
#endregion


#region 添加,刪除網(wǎng)站的方法
/// <summary>
/// 創(chuàng)建一個新的網(wǎng)站。根據(jù)傳過來的信息進(jìn)行配置
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 巴塘县| 佛学| 眉山市| 华亭县| 马公市| 称多县| 寿阳县| 大宁县| 巴青县| 大田县| 肃北| 崇信县| 聂拉木县| 彩票| 广饶县| 谢通门县| 柳林县| 榕江县| 烟台市| 唐海县| 察隅县| 文登市| 增城市| 西林县| 通辽市| 城步| 宜黄县| 八宿县| 托里县| 樟树市| 青川县| 康定县| 大荔县| 莱阳市| 乌拉特中旗| 瑞安市| 黄大仙区| 隆昌县| 浦县| 隆昌县| 双峰县|