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

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

用C#操縱IIS

2024-07-15 01:59:25
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(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>
/// 這個(gè)類(lèi)是靜態(tài)類(lèi)。用來(lái)實(shí)現(xiàn)管理IIS的基本操作。
/// 管理IIS有兩種方式,一是ADSI,一是WMI。由于系統(tǒng)限制的原因,只好選擇使用ADSI實(shí)現(xiàn)功能。
/// 這是一個(gè)遺憾。只有等到只有使用IIS 6的時(shí)候,才有可能使用WMI來(lái)管理系統(tǒng)
/// 不過(guò)有一個(gè)問(wèn)題就是,我現(xiàn)在也覺(jué)得這樣的一個(gè)方法在本地執(zhí)行會(huì)比較的好。最好不要遠(yuǎn)程執(zhí)行。
/// 因?yàn)槟菢有枰加孟喈?dāng)數(shù)量的帶寬,即使要遠(yuǎn)程執(zhí)行,也是推薦在同一個(gè)網(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("還沒(méi)有指定好用戶(hù)名。請(qǐng)先指定用戶(hù)名");
}


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ù)是否有用戶(hù)名來(lái)判斷是否是遠(yuǎn)程服務(wù)器。
/// 然后再構(gòu)造出不同的DirectoryEntry出來(lái)
/// </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)建一個(gè)新的網(wǎng)站。根據(jù)傳過(guò)來(lái)的信息進(jìn)行配置
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 来安县| 鹰潭市| 桂平市| 山东| 定襄县| 大安市| 龙井市| 萍乡市| 苏州市| 临澧县| 隆回县| 阿图什市| 全州县| 当涂县| 普洱| 和平县| 奈曼旗| 广饶县| 关岭| 景谷| 云和县| 凤台县| 华亭县| 泌阳县| 乌拉特后旗| 河东区| 镇康县| 洱源县| 新沂市| 延长县| 青海省| 隆昌县| 积石山| 大英县| 建平县| 玉溪市| 康保县| 弥渡县| 葵青区| 临桂县| 澄江县|