Holen Sie sich alle domain-Namen im Netzwerk

ich brauche, um die Liste der domain-Namen in meinem Netzwerk...

aber ich bin immer nur der domain-name mit dem ich log-in...
so zum Beispiel gibt es 2 domains "xyz" und "xyz2"
aber ich bekomme nur die Domäne mit dem ich log-in....

hier ist mein code:

if (!IsPostBack)
        {

            StringCollection adDomains = this.GetDomainList();

                foreach (string strDomain in adDomains)
                {
                    DropDownList1.Items.Add(strDomain);

                }
            }
        }

    private StringCollection GetDomainList()
    {
        StringCollection domainList = new StringCollection();
        try
        {
            DirectoryEntry en = new DirectoryEntry("LDAP://");
            //Search for objectCategory type "Domain"
            DirectorySearcher srch = new DirectorySearcher("objectCategory=Domain");
            SearchResultCollection coll = srch.FindAll();
            //Enumerate over each returned domain.
            foreach (SearchResult rs in coll)
            {
                ResultPropertyCollection resultPropColl = rs.Properties;
                foreach (object domainName in resultPropColl["name"])
                {
                    domainList.Add(domainName.ToString());
                }
            }
        }
        catch (Exception ex)
        {
            Trace.Write(ex.Message);
        }
        return domainList;
    }               

InformationsquelleAutor user175084 | 2010-04-13

Schreibe einen Kommentar