正文

基于DirectoryServices的IIS虚拟目录管理(1)2009-07-25 16:57:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/xman/45577.html

分享到:

一。IIS属性集VirtualDirectory类

using System;

using System.DirectoryServices; // 添加DirectorysServices引用!

 

/// <summary>

/// 自定义基于DirectoryServicesIIS虚拟目录管理服务,

/// 支持创建、更新、删除WebFtp虚拟目录。

/// </summary>

namespace VirtualDirectoryServices

{

    /// <summary>

    /// IIS属性类

    /// </summary>

    public class VirtualDirectory

    {

             

        private string _Name;

        private string _Path;

        private string _AppFriendlyName;

 

        private string _UNCUsername;

        private string _UNCPassword;

 

        private bool _AccessRead;

        private bool _AccessWrite;

        private bool _AccessExecute;

        private bool _AccessScript;

 

        private bool _DontLog;  

        private bool _ContentIndexed;

        private bool _EnableDirBrowsing;

 

        private int _AppIsolated;

 

        /// <summary>构造函数1</summary>

        /// <param name="strVirDirName">虚拟目录名称</param>

        /// <param name="strPhyPath">虚拟目录所指向的路径</param>

        public VirtualDirectory(string strVirDirName, string strPhyPath)

        {

            _Name = strVirDirName;

            _AppFriendlyName = strVirDirName;

            _Path = strPhyPath;

 

            // 内置UNC账户

            _UNCUsername = "UNCAccount";

            _UNCPassword = "123456";

 

            _AccessRead = true;

            _AccessWrite = false;

            _AccessExecute = false;

            _AccessScript = true;

           

            _DontLog = false;

            _ContentIndexed = true;

            _EnableDirBrowsing = false;

 

            _AppIsolated = 2;

        }

 

        /// <summary>构造函数2,可设置UNC账户</summary>

        /// <param name="strVirDirName">虚拟目录名称</param>

        /// <param name="strPhyPath">虚拟目录所指向的路径</param>

        /// <param name="strUNCAccount">

        /// UNC共享虚拟目录账户,strUNCAccount[0]为账户名,strUNCAccount[1]为账户密码

        /// </param>

        public VirtualDirectory(string strVirDirName, string strPhyPath, string[] strUNCAccount)

        {

            _Name = strVirDirName;

            _AppFriendlyName = strVirDirName;

            _Path = strPhyPath;

 

            _UNCUsername = strUNCAccount[0];

            _UNCPassword = strUNCAccount[1];

 

            _AccessRead = true;

            _AccessWrite = false;

 

            _AccessExecute = false;

            _AccessScript = true;

 

            _DontLog = false;

            _ContentIndexed = true;

            _EnableDirBrowsing = false;

 

            _AppIsolated = 2;

        }

 

        /// <value>

        /// 虚拟目录名称属性,例如PictureAudioVideo

        /// </value>

        public string Name

        {

            get { return _Name; }

            set { _Name = value; }

        }

 

        /// <value>

        /// 应用程序名称属性<br/>

        /// 虚拟目录的描述性文字,例如Picture:图片文件夹。

        /// </value>

        public string AppFriendlyName

        {

            get { return _AppFriendlyName; }

            set { _AppFriendlyName = value; }

        }

 

        /// <value>

        /// 物理(网络)路径属性<br/>

        /// 形如"D:\files\picture""\\192.168.89.244\picture"

        /// </value>

        public string Path

        {

            get { return _Path; }

            set { _Path = value; }

        }

下一篇基于DirectoryServices的IIS虚拟目录管理(2)

阅读(2218) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册