zoukankan      html  css  js  c++  java
  • DirectoryEntry的属性测试代码

     public static DirectoryEntry FindOneDirectoryEntry(string strDomainName, string strFilter, SearchScope scSearchScope)
            {
                dbMessage = new dbAccessMessage();
                AdInfo adinfo = Config.GetConfig(strDomainName);
                DirectoryEntry de = null;
                try
                {
                    string path = "LDAP://" + adinfo.DomainControler + "/" + Utility.GetDomainDN(adinfo.RootDn);
                    DirectoryEntry root = new DirectoryEntry(path, adinfo.SuperUserName, adinfo.SuperUserPass);
                    DirectorySearcher srch = new DirectorySearcher();
                    srch.SearchRoot = root;
                    srch.Filter = strFilter;
                    srch.SearchScope = scSearchScope;
                    SearchResult sr = srch.FindOne();

                    if (sr != null)
                    {

                        de = sr.GetDirectoryEntry();
                    }

                }
                catch
                {
                }
                return de;
            }

    aspx.cs

            if (!Page.IsPostBack)
            {
                DirectoryEntry de = Utility.FindOneDirectoryEntry(strDomainName,strFilter,scSearchScope);
                AdUserInfo aduserinfo=new AdUserInfo();
                foreach (string property in de.Properties.PropertyNames)
                {
                    /*
                    PropertyValueCollection valueCollection = de.Properties[property];
                    for (int i = 0; i < valueCollection.Count; i++)
                    {
                        msg.Text += property + ":" + valueCollection[i].ToString()+"<br/>";
                    }
                     * */
                    msg.Text += property + ":" + de.Properties[property].Value.ToString()+ "<br/>";
                }
                //aduserinfo = ADUser.GetUserInfo(de); ;
                msg1.Text = aduserinfo.sAMAccountName;
            }

    注释代码的返回结果:

    objectClass:top
    objectClass:domain
    objectClass:domainDNS

    方法二的返回结果:

    objectClass:System.Object[]

    两个之间的关系是什么呢?至今未弄清楚。

  • 相关阅读:
    zabbix添加对haproxy的监控
    【转】最近搞Hadoop集群迁移踩的坑杂记
    【转】Hive配置文件中配置项的含义详解(收藏版)
    【转】Spark-Sql版本升级对应的新特性汇总
    kylin查询出现日期对应不上的情况
    【转】saiku与kylin整合备忘录
    Eclipse中Ctrl+方法名发现无法进入到该方法中……
    maven会报Could not transfer artifact xxx错误
    【转】CDH5.x升级
    【转】Kylin实践之使用Hive视图
  • 原文地址:https://www.cnblogs.com/xyzyyj/p/2856691.html
Copyright © 2011-2022 走看看