예제 #1
0
        //获取虚拟目录集合
        private VirtualDirectories GetVirDirs(DirectoryEntries des)
        {
            VirtualDirectories tmpdirs = new VirtualDirectories();

            foreach (DirectoryEntry de in des)
            {
                if (de.SchemaClassName == "IIsWebVirtualDir")
                {
                    VirtualDirectory vd = new VirtualDirectory();
                    vd.Name              = de.Name;
                    vd.AccessRead        = (bool)de.Properties["AccessRead"][0];
                    vd.AccessExecute     = (bool)de.Properties["AccessExecute"][0];
                    vd.AccessWrite       = (bool)de.Properties["AccessWrite"][0];
                    vd.AnonymousUserName = (string)de.Properties["AnonymousUserName"][0];
                    vd.AnonymousUserPass = (string)de.Properties["AnonymousUserName"][0];
                    vd.AuthBasic         = (bool)de.Properties["AuthBasic"][0];
                    vd.AuthNTLM          = (bool)de.Properties["AuthNTLM"][0];
                    vd.ContentIndexed    = (bool)de.Properties["ContentIndexed"][0];
                    vd.EnableDefaultDoc  = (bool)de.Properties["EnableDefaultDoc"][0];
                    vd.EnableDirBrowsing = (bool)de.Properties["EnableDirBrowsing"][0];
                    vd.AccessSSL         = (bool)de.Properties["AccessSSL"][0];
                    vd.Accessscript      = (bool)de.Properties["Accessscript"][0];
                    vd.Path              = (string)de.Properties["Path"][0];
                    vd.flag              = 0;
                    vd.DefaultDoc        = (string)de.Properties["DefaultDoc"][0];
                    tmpdirs.Add(vd.Name, vd);
                }
            }
            return(tmpdirs);
        }
예제 #2
0
        ///<summary>
        ///私有方法
        ///</summary>

        //连接服务器
        private void ConnectToServer()
        {
            string strPath = "IIS://" + _server + "/W3SVC/" + _website + "/ROOT";

            try
            {
                this.rootfolder = new DirectoryEntry(strPath);
                _virdirs        = GetVirDirs(this.rootfolder.Children);
            }
            catch (Exception e)
            {
                throw new Exception("Can't connect to the server [" + _server + "] ...", e);
            }
        }
예제 #3
0
        //执行批量更新
        private void BatchUpdate(VirtualDirectories vds)
        {
            _batchflag = true;
            foreach (object item in vds.Values)
            {
                VirtualDirectory vd = (VirtualDirectory)item;
                switch (vd.flag)
                {
                case 0:
                    break;

                case 1:
                    Create(vd);
                    break;

                case 2:
                    Update(vd);
                    break;
                }
            }
            _batchflag = false;
        }
예제 #4
0
 //重载一个:-)
 public void UpdateBatch(VirtualDirectories vds)
 {
     BatchUpdate(vds);
 }
예제 #5
0
 //获取虚拟目录集合
 private VirtualDirectories GetVirDirs(DirectoryEntries des)
 {
     VirtualDirectories tmpdirs = new VirtualDirectories();
     foreach (DirectoryEntry de in des)
     {
         if (de.SchemaClassName == "IIsWebVirtualDir")
         {
             VirtualDirectory vd = new VirtualDirectory();
             vd.Name = de.Name;
             vd.AccessRead = (bool)de.Properties["AccessRead"][0];
             vd.AccessExecute = (bool)de.Properties["AccessExecute"][0];
             vd.AccessWrite = (bool)de.Properties["AccessWrite"][0];
             vd.AnonymousUserName = (string)de.Properties["AnonymousUserName"][0];
             vd.AnonymousUserPass = (string)de.Properties["AnonymousUserName"][0];
             vd.AuthBasic = (bool)de.Properties["AuthBasic"][0];
             vd.AuthNTLM = (bool)de.Properties["AuthNTLM"][0];
             vd.ContentIndexed = (bool)de.Properties["ContentIndexed"][0];
             vd.EnableDefaultDoc = (bool)de.Properties["EnableDefaultDoc"][0];
             vd.EnableDirBrowsing = (bool)de.Properties["EnableDirBrowsing"][0];
             vd.AccessSSL = (bool)de.Properties["AccessSSL"][0];
             vd.Accessscript = (bool)de.Properties["Accessscript"][0];
             vd.Path = (string)de.Properties["Path"][0];
             vd.flag = 0;
             vd.DefaultDoc = (string)de.Properties["DefaultDoc"][0];
             tmpdirs.Add(vd.Name, vd);
         }
     }
     return tmpdirs;
 }
예제 #6
0
 ///<summary>
 ///私有方法
 ///</summary>
 //连接服务器
 private void ConnectToServer()
 {
     string strPath = "IIS://" + _server + "/W3SVC/" + _website + "/ROOT";
     try
     {
         this.rootfolder = new DirectoryEntry(strPath);
         _virdirs = GetVirDirs(this.rootfolder.Children);
     }
     catch (Exception e)
     {
         throw new Exception("Can't connect to the server [" + _server + "] ...", e);
     }
 }
예제 #7
0
 //执行批量更新
 private void BatchUpdate(VirtualDirectories vds)
 {
     _batchflag = true;
     foreach (object item in vds.Values)
     {
         VirtualDirectory vd = (VirtualDirectory)item;
         switch (vd.flag)
         {
             case 0:
                 break;
             case 1:
                 Create(vd);
                 break;
             case 2:
                 Update(vd);
                 break;
         }
     }
     _batchflag = false;
 }
예제 #8
0
 //重载一个:-)
 public void UpdateBatch(VirtualDirectories vds)
 {
     BatchUpdate(vds);
 }