关于AD的操作 --其他类

namespace TB.ADBlock
{
    using System;


    [Serializable]
    public class SchemaClassException : ADException
    {
        public SchemaClassException()
        {
        }


        public SchemaClassException(string message) : base(message)
        {
        }


        public SchemaClassException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }

}


*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    public enum SchemaClass
    {
        domainDNS,
        builtinDomain,
        computer,
        container,
        organizationalUnit,
        group,
        user,
        none
    }
}

*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    [Serializable]
    public class SameRDNException : ADException
    {
        public SameRDNException()
        {
        }


        public SameRDNException(string message) : base(message)
        {
        }


        public SameRDNException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }
}

*******************************************************************************************************


namespace TB.ADBlock
{
    using System;
    using System.Collections.Specialized;
    using System.Configuration;
    using System.Runtime.CompilerServices;


    public class ParaMgr
    {
        private string domain;
        private string domain2000;
        private string fullPath;
        public const string LDAP_IDENTITY = "LDAP://";
        private string password;
        private static object s_lock = new object();
        private static volatile ParaMgr s_value = null;
        private string userName;


        private ParaMgr()
        {
        }


        public static void SetSysPara(string userName, string domain, string password, string fullPath)
        {
            if (!string.IsNullOrEmpty(userName))
            {
                Value.userName = userName;
            }
            if (!string.IsNullOrEmpty(domain))
            {
                Value.domain = domain;
            }
            if (!string.IsNullOrEmpty(password))
            {
                Value.password = password;
            }
            if (!string.IsNullOrEmpty(userName))
            {
                Value.fullPath = fullPath;
            }
        }


        public static string ADDomain
        {
            get
            {
                return Value.domain;
            }
        }


        public static string ADDomain2000
        {
            get
            {
                return Value.domain2000;
            }
        }


        public static string ADFullName
        {
            get
            {
                return string.Format("{0}@{1}", Value.userName, Value.domain);
            }
        }


        public static string ADFullPath
        {
            get
            {
                return Value.fullPath;
            }
        }


        public static string ADPassword
        {
            get
            {
                return Value.password;
            }
        }


        public static string ADUserName
        {
            get
            {
                return Value.userName;
            }
        }


        private static ParaMgr Value
        {
            get
            {
                if (s_value == null)
                {
                    lock (s_lock)
                    {
                        if (s_value == null)
                        {
                            s_value = new ParaMgr();
                            NameValueCollection setting = ConfigurationManager.AppSettings;
                            if (!string.IsNullOrEmpty(setting["AD_Admin"]))
                            {
                                s_value.userName = setting["AD_Admin"];
                            }
                            if (!string.IsNullOrEmpty(setting["AD_Domain"]))
                            {
                                s_value.domain = setting["AD_Domain"];
                            }
                            if (!string.IsNullOrEmpty(setting["AD_Domain2000"]))
                            {
                                s_value.domain2000 = setting["AD_Domain2000"];
                            }
                            if (!string.IsNullOrEmpty(setting["AD_Password"]))
                            {
                                s_value.password = setting["AD_Password"];
                            }
                            if (!string.IsNullOrEmpty(setting["AD_Path"]))
                            {
                                s_value.fullPath = setting["AD_Path"];
                            }
                        }
                    }
                }
                return s_value;
            }
        }
    }
}



*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    [Serializable]
    public class NotContainerException : ADException
    {
        public NotContainerException()
        {
        }


        public NotContainerException(string message) : base(message)
        {
        }


        public NotContainerException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }
}



*******************************************************************************************************

namespace TB.ADBlock
{
    using System;


    public enum LoginResult
    {
        LOGIN_OK,
        LOGIN_USER_DOT_EXIST,
        LOGIN_USER_ACCOUNT_INACTIVE,
        LOGIN_USER_PASSWORD_INCORRECT
    }
}


*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    public enum GroupScope
    {
        ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = -2147483644,
        ADS_GROUP_TYPE_GLOBAL_GROUP = -2147483646
    }
}



*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    [Serializable]
    public class ExistChildException : ADException
    {
        public ExistChildException()
        {
        }


        public ExistChildException(string message) : base(message)
        {
        }


        public ExistChildException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }
}



*******************************************************************************************************


namespace TB.ADBlock
{
    using System;


    [Serializable]
    public class EntryNotExistException : ADException
    {
        public EntryNotExistException()
        {
        }


        public EntryNotExistException(string message) : base(message)
        {
        }


        public EntryNotExistException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }
}



*******************************************************************************************************


namespace TB.ADBlock
{
    using System;
    using System.DirectoryServices;


    public class Domain : BaseObject
    {
        private string description;
        public const string PROPERTY_DC = "dc";
        public const string PROPERTY_DESCRIPTION = "description";


        public Domain()
        {
        }


        internal Domain(DirectoryEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException();
            }
            this.Parse(entry);
        }


        protected override void Parse(DirectoryEntry entry)
        {
            base.Parse(entry, SchemaClass.domainDNS);
            this.description = Utils.GetProperty(entry, "description");
        }


        public string Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }
    }
}


*******************************************************************************************************


namespace TB.ADBlock
{
    using System;
    using System.DirectoryServices;


    public class Builtin : BaseObject
    {
        private string description;
        public const string PROPERTY_CN = "cn";
        public const string PROPERTY_DESCRIPTION = "description";


        public Builtin()
        {
        }


        internal Builtin(DirectoryEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException();
            }
            this.Parse(entry);
        }


        protected override void Parse(DirectoryEntry entry)
        {
            base.Parse(entry, SchemaClass.builtinDomain);
            this.description = Utils.GetProperty(entry, "description");
        }


        public string Description
        {
            get
            {
                return this.description;
            }
            set
            {
                this.description = value;
            }
        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值