IIS虚拟目录控制类

None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.DirectoryServices;
None.gif
using  System.Collections;
None.gif
using  System.IO;
None.gif
None.gif
namespace  IISControl
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// CreateWebDir 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class IISManager
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
//定义需要使用的
InBlock.gif
        private string _server,_website,_AnonymousUserPass,_AnonymousUserName;
InBlock.gif        
private VirtualDirectories _virdirs;
InBlock.gif        
protected System.DirectoryServices.DirectoryEntry rootfolder;
InBlock.gif        
private bool _batchflag;
InBlock.gif        
public IISManager()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//默认情况下使用localhost,即访问本地机
InBlock.gif
            _server = "localhost";
InBlock.gif            _website 
= "1";
InBlock.gif            _batchflag 
= false;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public IISManager(string strServer)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _server 
= strServer;
InBlock.gif            _website 
= "1"
InBlock.gif            _batchflag 
= false;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 定义公共属性
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif
InBlock.gif        
public void get_AnonymousUser()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _AnonymousUserPass
="IUSR_DEVE-SERVER"
InBlock.gif            _AnonymousUserName
="IUSR_DEVE-SERVER";
InBlock.gif            VirtualDirectory vDir;
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Hashtable myList 
= (Hashtable)_virdirs;
InBlock.gif                IDictionaryEnumerator myEnumerator 
= myList.GetEnumerator();
InBlock.gif                
while ( myEnumerator.MoveNext() )
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    vDir 
= (VirtualDirectory)myEnumerator.Value;
InBlock.gif                    
if (vDir.AnonymousUserName!="" && vDir.AnonymousUserPass != "")
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        _AnonymousUserName
=vDir.AnonymousUserName;
InBlock.gif                        _AnonymousUserPass
=vDir.AnonymousUserPass;
InBlock.gif                        
break;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                _AnonymousUserPass
="IUSR_DEVE-SERVER"
InBlock.gif                _AnonymousUserName
="IUSR_DEVE-SERVER";
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string AnonymousUserName
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _AnonymousUserName;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _AnonymousUserName = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string AnonymousUserPass
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _AnonymousUserPass;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _AnonymousUserPass = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//Server属性定义访问机器的名字,可以是IP与计算名
InBlock.gif
        public string Server
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _server;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _server = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//WebSite属性定义,为一数字,为方便,使用string 
InBlock.gif        
//一般来说第一台主机为1,第二台主机为2,依次类推
InBlock.gif
        public string WebSite
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _website; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _website = value; }
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//虚拟目录的名字
InBlock.gif
        public VirtualDirectories VirDirs
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _virdirs; }
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _virdirs = value;}
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**////<summary>
InBlock.gif        
///定义公共方法
ExpandedSubBlockEnd.gif        
///</summary>

InBlock.gif
InBlock.gif        
//连接服务器
InBlock.gif
        public void Connect()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            ConnectToServer();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//为方便重载
InBlock.gif
        public void Connect(string strServer)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _server 
= strServer;
InBlock.gif            ConnectToServer();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//为方便重载
InBlock.gif
        public void Connect(string strServer,string strWebSite)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _server 
= strServer;
InBlock.gif            _website 
= strWebSite;
InBlock.gif            ConnectToServer();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//判断是否存这个虚拟目录
InBlock.gif
        public bool Exists(string strVirdir)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return _virdirs.Contains(strVirdir);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//添加一个虚拟目录
InBlock.gif
        public bool Create(VirtualDirectory newdir) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string strPath = "IIS://" + _server + "/W3SVC/" + _website + "/ROOT/" + newdir.Name;
InBlock.gif            
if(!_virdirs.Contains(newdir.Name) || _batchflag )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
//加入到ROOT的Children集合中去
InBlock.gif
                    DirectoryEntry newVirDir = rootfolder.Children.Add(newdir.Name,"IIsWebVirtualDir");
InBlock.gif                    newVirDir.Invoke(
"AppCreate",true);
InBlock.gif                    newVirDir.CommitChanges();
InBlock.gif                    rootfolder.CommitChanges();
InBlock.gif                    
//然后更新数据
InBlock.gif
                    UpdateDirInfo(newVirDir,newdir);
InBlock.gif                    
return true;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
//throw new Exception(ee.ToString());
InBlock.gif
                    return false;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return true;
InBlock.gif                
//throw new Exception("This virtual directory is already exist.");
ExpandedSubBlockEnd.gif
            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
//得到一个虚拟目录
InBlock.gif
        public VirtualDirectory GetVirDir(string strVirdir)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            VirtualDirectory tmp 
= null;
InBlock.gif            
if(_virdirs.Contains(strVirdir))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                tmp 
= _virdirs.Find(strVirdir);
InBlock.gif                ((VirtualDirectory)_virdirs[strVirdir]).flag 
= 2;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
//throw new Exception("This virtual directory is not exists");
ExpandedSubBlockEnd.gif
            }

InBlock.gif            
return tmp;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//更新一个虚拟目录
InBlock.gif
        public void Update(VirtualDirectory dir)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//判断需要更改的虚拟目录是否存在
InBlock.gif
            if(_virdirs.Contains(dir.Name))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                DirectoryEntry ode 
= rootfolder.Children.Find(dir.Name,"IIsWebVirtualDir");
InBlock.gif                UpdateDirInfo(ode,dir);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
//throw new Exception("This virtual directory is not exists.");
ExpandedSubBlockEnd.gif
            }

ExpandedSubBlockEnd.gif        }

InBlock.gif 
InBlock.gif        
//删除一个虚拟目录
InBlock.gif
        public void Delete(string strVirdir)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(_virdirs.Contains(strVirdir))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
object[] paras = new object[2];
InBlock.gif                paras[
0= "IIsWebVirtualDir"//表示操作的是虚拟目录
InBlock.gif
                paras[1= strVirdir;
InBlock.gif                rootfolder.Invoke(
"Delete",paras);
InBlock.gif                rootfolder.CommitChanges();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
//throw new Exception("Can''t delete " + strVirdir + ",because it isn''t exists.");
ExpandedSubBlockEnd.gif
            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
//批量更新
InBlock.gif
        public void UpdateBatch()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            BatchUpdate(_virdirs);
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//重载一个:-)
InBlock.gif
        public void UpdateBatch(VirtualDirectories vds)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            BatchUpdate(vds);
ExpandedSubBlockEnd.gif        }

InBlock.gif 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**////<summary>
InBlock.gif        
///私有方法
ExpandedSubBlockEnd.gif        
///</summary>

InBlock.gif
InBlock.gif        
public void Close()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _virdirs.Clear();
InBlock.gif            _virdirs 
= null;
InBlock.gif            rootfolder.Dispose();
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//连接服务器
InBlock.gif
        private void ConnectToServer()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
string strPath = "IIS://" + _server + "/W3SVC/" + _website +"/ROOT";
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.rootfolder = new DirectoryEntry(strPath);
InBlock.gif                _virdirs 
= GetVirDirs(this.rootfolder.Children);
ExpandedSubBlockEnd.gif            }
 
InBlock.gif            
catch(Exception e)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
throw new Exception("Can''t connect to the server ["+ _server +"dot.gif",e);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
//执行批量更新
InBlock.gif
        private void BatchUpdate(VirtualDirectories vds)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _batchflag 
= true;
InBlock.gif            
foreach(object item in vds.Values)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                VirtualDirectory vd 
= (VirtualDirectory)item;
InBlock.gif                
switch(vd.flag)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
case 0:
InBlock.gif                        
break;
InBlock.gif                    
case 1:
InBlock.gif                        Create(vd);
InBlock.gif                        
break;
InBlock.gif                    
case 2:
InBlock.gif                        Update(vd);
InBlock.gif                        
break;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            _batchflag 
= false;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//更新东东
InBlock.gif
        private void UpdateDirInfo(DirectoryEntry de,VirtualDirectory vd)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            de.Properties[
"AnonymousUserName"][0= vd.AnonymousUserName;
InBlock.gif            de.Properties[
"AnonymousUserPass"][0= vd.AnonymousUserPass;
InBlock.gif            de.Properties[
"AccessRead"][0= vd.AccessRead;
InBlock.gif            de.Properties[
"AccessExecute"][0= vd.AccessExecute;
InBlock.gif            de.Properties[
"AccessWrite"][0= vd.AccessWrite;
InBlock.gif            de.Properties[
"AuthBasic"][0= vd.AuthBasic;
InBlock.gif            de.Properties[
"AuthNTLM"][0= vd.AuthNTLM;
InBlock.gif            de.Properties[
"ContentIndexed"][0= vd.ContentIndexed;
InBlock.gif            de.Properties[
"EnableDefaultDoc"][0= vd.EnableDefaultDoc;
InBlock.gif            de.Properties[
"EnableDirBrowsing"][0= vd.EnableDirBrowsing;
InBlock.gif            de.Properties[
"AccessSSL"][0= vd.AccessSSL;
InBlock.gif            de.Properties[
"AccessScript"][0= vd.AccessScript;
InBlock.gif            de.Properties[
"DefaultDoc"][0= vd.DefaultDoc;
InBlock.gif            de.Properties[
"Path"][0= vd.Path;
InBlock.gif            de.CommitChanges();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//获取虚拟目录集合
InBlock.gif
        private VirtualDirectories GetVirDirs(DirectoryEntries des)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            VirtualDirectories tmpdirs 
= new VirtualDirectories();
InBlock.gif            
foreach(DirectoryEntry de in des)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(de.SchemaClassName == "IIsWebVirtualDir")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    VirtualDirectory vd 
= new VirtualDirectory();
InBlock.gif                    vd.Name 
= de.Name;
InBlock.gif                    vd.AccessRead 
= (bool)de.Properties["AccessRead"][0];
InBlock.gif                    vd.AccessExecute 
= (bool)de.Properties["AccessExecute"][0];
InBlock.gif                    vd.AccessWrite 
= (bool)de.Properties["AccessWrite"][0];
InBlock.gif                    vd.AnonymousUserName 
= (string)de.Properties["AnonymousUserName"][0];
InBlock.gif                    vd.AnonymousUserPass 
= (string)de.Properties["AnonymousUserPass"][0];
InBlock.gif                    vd.AuthBasic 
= (bool)de.Properties["AuthBasic"][0];
InBlock.gif                    vd.AuthNTLM 
= (bool)de.Properties["AuthNTLM"][0];
InBlock.gif                    vd.ContentIndexed 
= (bool)de.Properties["ContentIndexed"][0];
InBlock.gif                    vd.EnableDefaultDoc 
= (bool)de.Properties["EnableDefaultDoc"][0];
InBlock.gif                    vd.EnableDirBrowsing 
= (bool)de.Properties["EnableDirBrowsing"][0];
InBlock.gif                    vd.AccessSSL 
= (bool)de.Properties["AccessSSL"][0];
InBlock.gif                    vd.AccessScript 
= (bool)de.Properties["AccessScript"][0];
InBlock.gif                    vd.Path 
= (string)de.Properties["Path"][0];
InBlock.gif                    vd.flag 
= 0;
InBlock.gif                    vd.DefaultDoc 
= (string)de.Properties["DefaultDoc"][0];
InBlock.gif                    tmpdirs.Add(vd.Name,vd);
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return tmpdirs;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// VirtualDirectory类
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class VirtualDirectory
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private bool _read,_execute,_script,_ssl,_write,_authbasic,_authntlm, _indexed,_endirbrow,_endefaultdoc;
InBlock.gif        
private string _ausername,_auserpass,_name,_path;
InBlock.gif        
private int _flag;
InBlock.gif        
private string _defaultdoc;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 构造函数
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        public VirtualDirectory()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            SetValue();
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public VirtualDirectory(string sVirDirName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            SetValue();
InBlock.gif            _name 
= sVirDirName;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
// sVirDirName:虚拟路径; 
InBlock.gif        
// strPhyPath: 物理路径( physics Path)
InBlock.gif
        public VirtualDirectory(string sVirDirName,string strPhyPath,string[] AnonymousUser)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            SetValue();
InBlock.gif            _name 
= sVirDirName;
InBlock.gif            _path 
= strPhyPath;
InBlock.gif            _ausername 
= AnonymousUser[0];
InBlock.gif            _auserpass 
= AnonymousUser[1];
ExpandedSubBlockEnd.gif        }

InBlock.gif        
private void SetValue()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            _read 
= true;_execute = false;_script = true;_ssl= false;_write=false;_authbasic=false;
InBlock.gif            _authntlm
=true;_indexed = true;_endirbrow=false;_endefaultdoc = true;
InBlock.gif            _flag 
= 1;
InBlock.gif            _defaultdoc 
= "default.htm,default.aspx,default.asp,index.htm";
InBlock.gif            _path 
= "C:\\";
InBlock.gif            _ausername 
= "IUSR_DEVE-SERVER";_auserpass ="IUSR_DEVE-SERVER";_name="";
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**////<summary>
InBlock.gif        
///定义属性,IISVirtualDir太多属性了
InBlock.gif        
///我只搞了比较重要的一些,其它的大伙需要的自个加吧。
ExpandedSubBlockEnd.gif        
///</summary>

InBlock.gif
InBlock.gif        
public int flag
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _flag;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _flag = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AccessRead
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _read;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _read = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AccessWrite
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _write;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _write = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AccessExecute
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _execute;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _execute = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AccessSSL
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _ssl;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _ssl = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AccessScript
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _script;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _script = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AuthBasic
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _authbasic;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _authbasic = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool AuthNTLM
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _authntlm;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _authntlm = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool ContentIndexed
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _indexed;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _indexed = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool EnableDirBrowsing
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _endirbrow;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _endirbrow = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public bool EnableDefaultDoc
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _endefaultdoc;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _endefaultdoc = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string Name
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _name;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _name = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string Path
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _path;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _path = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string DefaultDoc
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _defaultdoc;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _defaultdoc = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string AnonymousUserName
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _ausername;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _ausername = value;}
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public string AnonymousUserPass
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gifreturn _auserpass;}
ExpandedSubBlockStart.gifContractedSubBlock.gif            
setdot.gif{ _auserpass = value;}
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 集合VirtualDirectories
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif
InBlock.gif    
public class VirtualDirectories : System.Collections.Hashtable
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
public VirtualDirectories()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//添加新的方法 
InBlock.gif
        public VirtualDirectory Find(string strName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return (VirtualDirectory)this[strName];
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif    
public class DirectoryInfos : System.Collections.CollectionBase
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
public int Add(DirectoryInfo di)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return this.List.Add(di);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public DirectoryInfo this[int index]
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif            
getdot.gif{return (DirectoryInfo)List[index];}
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public void AddCollection(DirectoryInfo[] dirs)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
foreach(DirectoryInfo dir in dirs)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                List.Add(dir);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
public enum LogState
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        Success,
InBlock.gif        Failed,
InBlock.gif        Message
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif
InBlock.gif
ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/iyond/archive/2006/03/18/352527.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: IIS(Internet Information Services)是一个用于在Windows操作系统上托管Web应用程序的服务。虚拟目录是指在IIS中用来代表Web站点中的一个目录,但其实际上可能位于其他位置,比如不同的磁盘驱动器或网络共享。 反向代理是一种服务器管理技术,它将客户端的请求发送到不同的服务器,然后将服务器的响应返回给客户端。在IIS中实现反向代理,可以通过将请求重定向到不同的虚拟目录来实现。 要配置IIS虚拟目录反向代理,可以按照以下步骤进行: 1. 打开IIS管理器,在“站点”节点下选择要配置反向代理的站点。 2. 如果尚未创建虚拟目录,请右键单击站点,选择“添加虚拟目录”来创建。 3. 在虚拟目录的属性中,选择“基本设置”选项卡,然后点击“连接”按钮。 4. 在“物理路径”框中,输入需要代理的目标服务器的URL地址,例如http://www.targetserver.com。 5. 在“身份验证”下拉列表中,选择要用于向目标服务器发送验证的身份验证方法。 6. 在“代理”选项卡中,选择“启用代理”复选框。 7. 在“重写响应”选项卡中,可以选择是否重写目标服务器返回的响应,例如重写URL或响应头。 8. 点击“确定”保存配置。 这样,当客户端发出请求,并匹配到虚拟目录的URL路径时,IIS会将请求转发到目标服务器,并将目标服务器的响应返回给客户端。 通过配置IIS虚拟目录反向代理,可以实现将不同的请求转发到不同的服务器,可以用于负载均衡、缓存、安全和增强性能等方面的需求。希望这个回答对您有所帮助。 ### 回答2: IIS(Internet Information Services)虚拟目录反向代理配置是一种常见的网络配置方案。反向代理是一种转发网络请求的技术,它将客户端请求转发到内部服务器,并将响应返回给客户端,实现了客户端与服务器之间的隔离。 要配置IIS虚拟目录反向代理,需要进行以下步骤: 1. 打开IIS管理器,选择要配置反向代理的网站或应用程序。 2. 在“功能视图”下,找到“URL重写”或“HTTP重定向”功能。 3. 点击“添加规则”或“新建规则”,根据实际需求选择不同的规则类型,例如“反向代理”或“反向代理转发”。 4. 在规则设置中,填写目标服务器的详细信息,包括IP地址、端口号和目标路径等。 5. 配置其他选项,如路径重写、HTTP头设置等,根据实际需求进行调整。 6. 保存配置,并启用规则。 通过上述步骤,IIS就可以将外部客户端的请求转发到指定的内部服务器,实现反向代理的功能。这样可以隐藏内部服务器的实际IP地址和端口号,提供更好的安全性和灵活性。 需要注意的是,配置反向代理时要确保IIS服务器对目标服务器有访问权限,并且要注意网络安全性,避免不必要的风险。另外,根据具体需求可以配置多个虚拟目录反向代理,以实现更复杂的网络配置和应用场景。 总之,IIS虚拟目录反向代理配置可以提供更好的网络性能和安全性,适用于许多场景,如负载均衡、高可用性和内容分发等。 ### 回答3: IIS(Internet Information Services)是微软的一种Web服务器软件,可以通过虚拟目录反向代理配置实现将来自外部请求的流量转发到其他服务器上。 在IIS中设置虚拟目录,首先需要在IIS管理器中创建一个新的网站或虚拟应用程序。在创建过程中,需要指定站点的名称、物理路径和绑定的IP地址或域名等信息。创建完成后,可以在该网站或虚拟应用程序的属性设置中进行高级配置。 在IIS管理器中选中创建的网站或虚拟应用程序,然后点击右侧的"URL重写"或"HTTP重定向"等选项进行配置。在URL重写模块中,可以添加输入和输出规则,用于控制请求的转发规则。例如,可以设置当请求匹配特定的URL路径时,将请求发送到另外一个服务器的指定URL路径下。 在反向代理配置中,需要设置目标服务器的地址和端口号。可以在URL重写规则中的"动作"下选择"重写URL",然后填写目标服务器的地址和端口号。此外,还可以设置其他的转发规则,如是否保留原始URL等。 配置完成后,保存并应用更改。此时,IIS将会将来自外部的请求转发到指定的目标服务器上,从而实现虚拟目录的反向代理。 总结起来,IIS虚拟目录反向代理配置就是通过创建网站或虚拟应用程序,在URL重写模块中设置转发规则,将外部请求转发到其他服务器上。这样可以实现让IIS服务器充当中间人,将流量转发到目标服务器,提高系统的负载均衡和安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值