DirectoryEntry de = new DirectoryEntry("LDAP://" + hostName + "/OU=" + ou_departCur + ",OU=" + ou_depart1 + ",OU=" + ou_compary + ",DC=" + hostName + ",DC=" + hostNameArea + "");
           这个里面的地址不对,应该从哪儿找这个地址呢,

解决方案 »

  1.   

    http://zl198751.iteye.com/category/127794?show_full=true文章介绍
      

  2.   

       DirectorySearcher searcher;
                string path;
                SearchResult result;
                SearchResultCollection resultList;
                ResultPropertyCollection myResultPropColl;
                DirectoryEntry entry;            path = ConfigurationManager.AppSettings["LdapPath"];
                //entry = new DirectoryEntry(path);
                searcher = new DirectorySearcher(path);
                searcher.Filter = "";
                result = searcher.FindOne();
                string distinguishedName = result.Properties["distinguishedname"][0].ToString();