internal DirectoryServerCollection(DirectoryContext context, DirectoryEntry crossRefEntry, bool isADAM, ReadOnlyDirectoryServerCollection servers)
		{
			this.copyList = new ArrayList();
			this.context = context;
			this.crossRefEntry = crossRefEntry;
			this.isADAM = isADAM;
			this.isForNC = true;
			foreach (DirectoryServer server in servers)
			{
				base.InnerList.Add(server);
			}
		}
        internal DirectoryServerCollection(DirectoryContext context, DirectoryEntry crossRefEntry, bool isADAM, ReadOnlyDirectoryServerCollection servers)
        {
            this.context = context;
            _crossRefEntry = crossRefEntry;
            _isADAM = isADAM;

            _isForNC = true;
            foreach (DirectoryServer server in servers)
            {
                InnerList.Add(server);
            }
        }
        public ReadOnlyDirectoryServerCollection FindAllDirectoryServers()
        {
            base.CheckIfDisposed();
            if (this.appType == ApplicationPartitionType.ADApplicationPartition)
            {
                return(this.FindAllDirectoryServersInternal(null));
            }
            if (!this.committed)
            {
                throw new InvalidOperationException(Res.GetString("CannotPerformOperationOnUncommittedObject"));
            }
            ReadOnlyDirectoryServerCollection servers = new ReadOnlyDirectoryServerCollection();

            servers.AddRange(ConfigurationSet.FindAdamInstances(base.context, base.Name, null));
            return(servers);
        }
 public ActiveDirectorySite(DirectoryContext context, string siteName)
 {
     this.adjacentSites = new ReadOnlySiteCollection();
     this.domains = new DomainCollection(null);
     this.servers = new ReadOnlyDirectoryServerCollection();
     this.links = new ReadOnlySiteLinkCollection();
     this.bridgeheadServers = new ReadOnlyDirectoryServerCollection();
     ValidateArgument(context, siteName);
     context = new DirectoryContext(context);
     this.context = context;
     this.name = siteName;
     DirectoryEntry directoryEntry = null;
     try
     {
         directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
         string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext);
         this.siteDN = "CN=Sites," + str;
         directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, this.siteDN);
         string escapedPath = Utils.GetEscapedPath("cn=" + this.name);
         this.cachedEntry = directoryEntry.Children.Add(escapedPath, "site");
     }
     catch (COMException exception)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
     }
     catch (ActiveDirectoryObjectNotFoundException)
     {
         throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name }));
     }
     finally
     {
         if (directoryEntry != null)
         {
             directoryEntry.Dispose();
         }
     }
     this.subnets = new ActiveDirectorySubnetCollection(context, "CN=" + siteName + "," + this.siteDN);
     string transportName = "CN=IP,CN=Inter-Site Transports," + this.siteDN;
     this.RPCBridgeheadServers = new DirectoryServerCollection(context, "CN=" + siteName + "," + this.siteDN, transportName);
     transportName = "CN=SMTP,CN=Inter-Site Transports," + this.siteDN;
     this.SMTPBridgeheadServers = new DirectoryServerCollection(context, "CN=" + siteName + "," + this.siteDN, transportName);
 }
示例#5
0
		private ReadOnlyDirectoryServerCollection GetBridgeheadServers()
		{
			DirectoryServer domainController;
			NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname());
			pathname.EscapedMode = 4;
			ReadOnlyDirectoryServerCollection readOnlyDirectoryServerCollection = new ReadOnlyDirectoryServerCollection();
			if (this.existing)
			{
				Hashtable hashtables = new Hashtable();
				Hashtable hashtables1 = new Hashtable();
				Hashtable hashtables2 = new Hashtable();
				string str = string.Concat("CN=Servers,", (string)PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.DistinguishedName));
				DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, str);
				try
				{
					string[] strArrays = new string[4];
					strArrays[0] = "fromServer";
					strArrays[1] = "distinguishedName";
					strArrays[2] = "dNSHostName";
					strArrays[3] = "objectCategory";
					ADSearcher aDSearcher = new ADSearcher(directoryEntry, "(|(objectCategory=server)(objectCategory=NTDSConnection))", strArrays, SearchScope.Subtree, true, true);
					SearchResultCollection searchResultCollections = null;
					try
					{
						searchResultCollections = aDSearcher.FindAll();
					}
					catch (COMException cOMException1)
					{
						COMException cOMException = cOMException1;
						throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException);
					}
					try
					{
						foreach (SearchResult searchResult in searchResultCollections)
						{
							string searchResultPropertyValue = (string)PropertyManager.GetSearchResultPropertyValue(searchResult, PropertyManager.ObjectCategory);
							if (Utils.Compare(searchResultPropertyValue, 0, "CN=Server".Length, "CN=Server", 0, "CN=Server".Length) != 0)
							{
								continue;
							}
							hashtables2.Add((string)PropertyManager.GetSearchResultPropertyValue(searchResult, PropertyManager.DistinguishedName), (string)PropertyManager.GetSearchResultPropertyValue(searchResult, PropertyManager.DnsHostName));
						}
						foreach (SearchResult searchResult1 in searchResultCollections)
						{
							string searchResultPropertyValue1 = (string)PropertyManager.GetSearchResultPropertyValue(searchResult1, PropertyManager.ObjectCategory);
							if (Utils.Compare(searchResultPropertyValue1, 0, "CN=Server".Length, "CN=Server", 0, "CN=Server".Length) == 0)
							{
								continue;
							}
							string str1 = (string)PropertyManager.GetSearchResultPropertyValue(searchResult1, PropertyManager.FromServer);
							string partialDN = Utils.GetPartialDN(str1, 3);
							pathname.Set(partialDN, 4);
							partialDN = pathname.Retrieve(11);
							partialDN = partialDN.Substring(3);
							string partialDN1 = Utils.GetPartialDN((string)PropertyManager.GetSearchResultPropertyValue(searchResult1, PropertyManager.DistinguishedName), 2);
							if (hashtables.Contains(partialDN1))
							{
								continue;
							}
							string item = (string)hashtables2[partialDN1];
							if (!hashtables1.Contains(partialDN1))
							{
								hashtables1.Add(partialDN1, item);
							}
							if (Utils.Compare((string)PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.Cn), partialDN) == 0)
							{
								continue;
							}
							hashtables.Add(partialDN1, item);
							hashtables1.Remove(partialDN1);
						}
					}
					finally
					{
						searchResultCollections.Dispose();
					}
				}
				finally
				{
					directoryEntry.Dispose();
				}
				if (hashtables1.Count != 0)
				{
					DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(this.context, this.siteDN);
					StringBuilder stringBuilder = new StringBuilder(100);
					if (hashtables1.Count > 1)
					{
						stringBuilder.Append("(|");
					}
					foreach (DictionaryEntry hashtable in hashtables1)
					{
						stringBuilder.Append("(fromServer=");
						stringBuilder.Append("CN=NTDS Settings,");
						stringBuilder.Append(Utils.GetEscapedFilterValue((string)hashtable.Key));
						stringBuilder.Append(")");
					}
					if (hashtables1.Count > 1)
					{
						stringBuilder.Append(")");
					}
					string[] strArrays1 = new string[2];
					strArrays1[0] = "fromServer";
					strArrays1[1] = "distinguishedName";
					ADSearcher aDSearcher1 = new ADSearcher(directoryEntry1, string.Concat("(&(objectClass=nTDSConnection)(objectCategory=NTDSConnection)", stringBuilder.ToString(), ")"), strArrays1, SearchScope.Subtree);
					SearchResultCollection searchResultCollections1 = null;
					try
					{
						searchResultCollections1 = aDSearcher1.FindAll();
					}
					catch (COMException cOMException3)
					{
						COMException cOMException2 = cOMException3;
						throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException2);
					}
					try
					{
						foreach (SearchResult searchResult2 in searchResultCollections1)
						{
							string searchResultPropertyValue2 = (string)PropertyManager.GetSearchResultPropertyValue(searchResult2, PropertyManager.FromServer);
							string str2 = searchResultPropertyValue2.Substring(17);
							if (!hashtables1.Contains(str2))
							{
								continue;
							}
							string partialDN2 = Utils.GetPartialDN((string)PropertyManager.GetSearchResultPropertyValue(searchResult2, PropertyManager.DistinguishedName), 4);
							pathname.Set(partialDN2, 4);
							partialDN2 = pathname.Retrieve(11);
							partialDN2 = partialDN2.Substring(3);
							if (Utils.Compare(partialDN2, (string)PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.Cn)) == 0)
							{
								continue;
							}
							string item1 = (string)hashtables1[str2];
							hashtables1.Remove(str2);
							hashtables.Add(str2, item1);
						}
					}
					finally
					{
						searchResultCollections1.Dispose();
						directoryEntry1.Dispose();
					}
				}
				foreach (DictionaryEntry dictionaryEntry in hashtables)
				{
					string value = (string)dictionaryEntry.Value;
					if (!this.IsADAM)
					{
						domainController = new DomainController(Utils.GetNewDirectoryContext(value, DirectoryContextType.DirectoryServer, this.context), value);
					}
					else
					{
						DirectoryEntry directoryEntry2 = DirectoryEntryManager.GetDirectoryEntry(this.context, string.Concat("CN=NTDS Settings,", dictionaryEntry.Key));
						int propertyValue = (int)PropertyManager.GetPropertyValue(this.context, directoryEntry2, PropertyManager.MsDSPortLDAP);
						string str3 = value;
						if (propertyValue != 0x185)
						{
							str3 = string.Concat(value, ":", propertyValue);
						}
						domainController = new AdamInstance(Utils.GetNewDirectoryContext(str3, DirectoryContextType.DirectoryServer, this.context), str3);
					}
					readOnlyDirectoryServerCollection.Add(domainController);
				}
			}
			return readOnlyDirectoryServerCollection;
		}
示例#6
0
		internal ActiveDirectorySite(DirectoryContext context, string siteName, bool existing)
		{
			this.adjacentSites = new ReadOnlySiteCollection();
			this.domains = new DomainCollection(null);
			this.servers = new ReadOnlyDirectoryServerCollection();
			this.links = new ReadOnlySiteLinkCollection();
			this.bridgeheadServers = new ReadOnlyDirectoryServerCollection();
			this.context = context;
			this.name = siteName;
			this.existing = existing;
			DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
			this.siteDN = string.Concat("CN=Sites,", (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext));
			this.cachedEntry = DirectoryEntryManager.GetDirectoryEntry(context, string.Concat("CN=", siteName, ",", this.siteDN));
			this.subnets = new ActiveDirectorySubnetCollection(context, string.Concat("CN=", siteName, ",", this.siteDN));
			string str = string.Concat("CN=IP,CN=Inter-Site Transports,", this.siteDN);
			this.RPCBridgeheadServers = new DirectoryServerCollection(context, (string)PropertyManager.GetPropertyValue(context, this.cachedEntry, PropertyManager.DistinguishedName), str);
			str = string.Concat("CN=SMTP,CN=Inter-Site Transports,", this.siteDN);
			this.SMTPBridgeheadServers = new DirectoryServerCollection(context, (string)PropertyManager.GetPropertyValue(context, this.cachedEntry, PropertyManager.DistinguishedName), str);
		}
示例#7
0
		public ActiveDirectorySite(DirectoryContext context, string siteName)
		{
			this.adjacentSites = new ReadOnlySiteCollection();
			this.domains = new DomainCollection(null);
			this.servers = new ReadOnlyDirectoryServerCollection();
			this.links = new ReadOnlySiteLinkCollection();
			this.bridgeheadServers = new ReadOnlyDirectoryServerCollection();
			ActiveDirectorySite.ValidateArgument(context, siteName);
			context = new DirectoryContext(context);
			this.context = context;
			this.name = siteName;
			DirectoryEntry directoryEntry = null;
			using (directoryEntry)
			{
				try
				{
					directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
					string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext);
					this.siteDN = string.Concat("CN=Sites,", propertyValue);
					directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, this.siteDN);
					string escapedPath = string.Concat("cn=", this.name);
					escapedPath = Utils.GetEscapedPath(escapedPath);
					this.cachedEntry = directoryEntry.Children.Add(escapedPath, "site");
				}
				catch (COMException cOMException1)
				{
					COMException cOMException = cOMException1;
					throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
				}
				catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
				{
					object[] name = new object[1];
					name[0] = context.Name;
					throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name));
				}
			}
			this.subnets = new ActiveDirectorySubnetCollection(context, string.Concat("CN=", siteName, ",", this.siteDN));
			string str = string.Concat("CN=IP,CN=Inter-Site Transports,", this.siteDN);
			this.RPCBridgeheadServers = new DirectoryServerCollection(context, string.Concat("CN=", siteName, ",", this.siteDN), str);
			str = string.Concat("CN=SMTP,CN=Inter-Site Transports,", this.siteDN);
			this.SMTPBridgeheadServers = new DirectoryServerCollection(context, string.Concat("CN=", siteName, ",", this.siteDN), str);
		}
示例#8
0
        public ReadOnlyDirectoryServerCollection FindAllDirectoryServers(string siteName)
        {
            CheckIfDisposed();

            if (siteName == null)
            {
                throw new ArgumentNullException("siteName");
            }

            if (_appType == ApplicationPartitionType.ADApplicationPartition)
            {
                // AD
                return FindAllDirectoryServersInternal(siteName);
            }
            else
            {
                // Check that the application partition has been committed
                if (!_committed)
                {
                    throw new InvalidOperationException(Res.GetString(Res.CannotPerformOperationOnUncommittedObject));
                }

                ReadOnlyDirectoryServerCollection directoryServers = new ReadOnlyDirectoryServerCollection();
                directoryServers.AddRange(ConfigurationSet.FindAdamInstances(context, Name, siteName));
                return directoryServers;
            }
        }
        internal DirectoryServerCollection(DirectoryContext context, DirectoryEntry crossRefEntry, bool isADAM, ReadOnlyDirectoryServerCollection servers)
        {
            this.context   = context;
            _crossRefEntry = crossRefEntry;
            _isADAM        = isADAM;

            _isForNC = true;
            foreach (DirectoryServer server in servers)
            {
                InnerList.Add(server);
            }
        }
示例#10
0
        private ReadOnlyDirectoryServerCollection GetBridgeheadServers()
        {
            NativeComInterfaces.IAdsPathname pathCracker = (NativeComInterfaces.IAdsPathname)new NativeComInterfaces.Pathname();
            // need to turn off the escaping for name
            pathCracker.EscapedMode = NativeComInterfaces.ADS_ESCAPEDMODE_OFF_EX;

            ReadOnlyDirectoryServerCollection collection = new ReadOnlyDirectoryServerCollection();
            if (existing)
            {
                Hashtable bridgeHeadTable = new Hashtable();
                Hashtable nonBridgHeadTable = new Hashtable();
                Hashtable hostNameTable = new Hashtable();
                const string ocValue = "CN=Server";

                // get destination bridgehead servers

                // first go to the servers container under the current site and then do a search to get the all server objects.
                string serverContainer = "CN=Servers," + (string)PropertyManager.GetPropertyValue(context, cachedEntry, PropertyManager.DistinguishedName);
                DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, serverContainer);

                try
                {
                    // go through connection objects and find out its fromServer property. 
                    ADSearcher adSearcher = new ADSearcher(de,
                                                          "(|(objectCategory=server)(objectCategory=NTDSConnection))",
                                                          new string[] { "fromServer", "distinguishedName", "dNSHostName", "objectCategory" },
                                                          SearchScope.Subtree,
                                                          true, /* need paged search */
                                                          true /* need cached result as we need to go back to the first record */);
                    SearchResultCollection conResults = null;
                    try
                    {
                        conResults = adSearcher.FindAll();
                    }
                    catch (COMException e)
                    {
                        throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                    }

                    try
                    {
                        // find out whether fromServer indicates replicating from a server in another site.
                        foreach (SearchResult r in conResults)
                        {
                            string objectCategoryValue = (string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.ObjectCategory);
                            if (Utils.Compare(objectCategoryValue, 0, ocValue.Length, ocValue, 0, ocValue.Length) == 0)
                            {
                                hostNameTable.Add((string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.DistinguishedName), (string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.DnsHostName));
                            }
                        }

                        foreach (SearchResult r in conResults)
                        {
                            string objectCategoryValue = (string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.ObjectCategory);
                            if (Utils.Compare(objectCategoryValue, 0, ocValue.Length, ocValue, 0, ocValue.Length) != 0)
                            {
                                string fromServer = (string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.FromServer);

                                // escaping manipulation                                
                                string fromSite = Utils.GetPartialDN(fromServer, 3);
                                pathCracker.Set(fromSite, NativeComInterfaces.ADS_SETTYPE_DN);
                                fromSite = pathCracker.Retrieve(NativeComInterfaces.ADS_FORMAT_LEAF);
                                Debug.Assert(fromSite != null && Utils.Compare(fromSite, 0, 3, "CN=", 0, 3) == 0);
                                fromSite = fromSite.Substring(3);

                                string serverObjectName = Utils.GetPartialDN((string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.DistinguishedName), 2);
                                // don't know whether it is a bridgehead server yet.
                                if (!bridgeHeadTable.Contains(serverObjectName))
                                {
                                    string hostName = (string)hostNameTable[serverObjectName];
                                    // add if not yet done
                                    if (!nonBridgHeadTable.Contains(serverObjectName))
                                        nonBridgHeadTable.Add(serverObjectName, hostName);

                                    // check whether from different site
                                    if (Utils.Compare((string)PropertyManager.GetPropertyValue(context, cachedEntry, PropertyManager.Cn), fromSite) != 0)
                                    {
                                        // the server is a bridgehead server
                                        bridgeHeadTable.Add(serverObjectName, hostName);
                                        nonBridgHeadTable.Remove(serverObjectName);
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        conResults.Dispose();
                    }
                }
                finally
                {
                    de.Dispose();
                }

                // get source bridgehead server
                if (nonBridgHeadTable.Count != 0)
                {
                    // go to sites container to get all the connecdtion object that replicates from servers in the current sites that have
                    // not been determined whether it is a bridgehead server or not.
                    DirectoryEntry serverEntry = DirectoryEntryManager.GetDirectoryEntry(context, _siteDN);
                    // constructing the filter
                    StringBuilder str = new StringBuilder(100);
                    if (nonBridgHeadTable.Count > 1)
                        str.Append("(|");
                    foreach (DictionaryEntry val in nonBridgHeadTable)
                    {
                        str.Append("(fromServer=");
                        str.Append("CN=NTDS Settings,");
                        str.Append(Utils.GetEscapedFilterValue((string)val.Key));
                        str.Append(")");
                    }
                    if (nonBridgHeadTable.Count > 1)
                        str.Append(")");
                    ADSearcher adSearcher = new ADSearcher(serverEntry,
                                                          "(&(objectClass=nTDSConnection)(objectCategory=NTDSConnection)" + str.ToString() + ")",
                                                          new string[] { "fromServer", "distinguishedName" },
                                                          SearchScope.Subtree);
                    SearchResultCollection conResults = null;
                    try
                    {
                        conResults = adSearcher.FindAll();
                    }
                    catch (COMException e)
                    {
                        throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                    }

                    try
                    {
                        foreach (SearchResult r in conResults)
                        {
                            string fromServer = (string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.FromServer);
                            string serverObject = fromServer.Substring(17);

                            if (nonBridgHeadTable.Contains(serverObject))
                            {
                                string otherSite = Utils.GetPartialDN((string)PropertyManager.GetSearchResultPropertyValue(r, PropertyManager.DistinguishedName), 4);
                                // escaping manipulation
                                pathCracker.Set(otherSite, NativeComInterfaces.ADS_SETTYPE_DN);
                                otherSite = pathCracker.Retrieve(NativeComInterfaces.ADS_FORMAT_LEAF);
                                Debug.Assert(otherSite != null && Utils.Compare(otherSite, 0, 3, "CN=", 0, 3) == 0);
                                otherSite = otherSite.Substring(3);

                                // check whether from different sites
                                if (Utils.Compare(otherSite, (string)PropertyManager.GetPropertyValue(context, cachedEntry, PropertyManager.Cn)) != 0)
                                {
                                    string val = (string)nonBridgHeadTable[serverObject];
                                    nonBridgHeadTable.Remove(serverObject);
                                    bridgeHeadTable.Add(serverObject, val);
                                }
                            }
                        }
                    }
                    finally
                    {
                        conResults.Dispose();
                        serverEntry.Dispose();
                    }
                }

                DirectoryEntry ADAMEntry = null;
                foreach (DictionaryEntry e in bridgeHeadTable)
                {
                    DirectoryServer replica = null;
                    string host = (string)e.Value;
                    // construct directoryreplica
                    if (IsADAM)
                    {
                        ADAMEntry = DirectoryEntryManager.GetDirectoryEntry(context, "CN=NTDS Settings," + e.Key);
                        int port = (int)PropertyManager.GetPropertyValue(context, ADAMEntry, PropertyManager.MsDSPortLDAP);
                        string fullhost = host;
                        if (port != 389)
                        {
                            fullhost = host + ":" + port;
                        }
                        replica = new AdamInstance(Utils.GetNewDirectoryContext(fullhost, DirectoryContextType.DirectoryServer, context), fullhost);
                    }
                    else
                    {
                        replica = new DomainController(Utils.GetNewDirectoryContext(host, DirectoryContextType.DirectoryServer, context), host);
                    }

                    collection.Add(replica);
                }
            }

            return collection;
        }
 internal DirectoryServerCollection(DirectoryContext context, DirectoryEntry crossRefEntry, bool isADAM, ReadOnlyDirectoryServerCollection servers)
 {
     this.copyList      = new ArrayList();
     this.context       = context;
     this.crossRefEntry = crossRefEntry;
     this.isADAM        = isADAM;
     this.isForNC       = true;
     foreach (DirectoryServer server in servers)
     {
         base.InnerList.Add(server);
     }
 }
示例#12
0
		public ReadOnlyDirectoryServerCollection FindAllDirectoryServers(string siteName)
		{
			base.CheckIfDisposed();
			if (siteName != null)
			{
				if (this.appType != ApplicationPartitionType.ADApplicationPartition)
				{
					if (this.committed)
					{
						ReadOnlyDirectoryServerCollection readOnlyDirectoryServerCollection = new ReadOnlyDirectoryServerCollection();
						readOnlyDirectoryServerCollection.AddRange(ConfigurationSet.FindAdamInstances(this.context, base.Name, siteName));
						return readOnlyDirectoryServerCollection;
					}
					else
					{
						throw new InvalidOperationException(Res.GetString("CannotPerformOperationOnUncommittedObject"));
					}
				}
				else
				{
					return this.FindAllDirectoryServersInternal(siteName);
				}
			}
			else
			{
				throw new ArgumentNullException("siteName");
			}
		}
 public ReadOnlyDirectoryServerCollection FindAllDirectoryServers()
 {
     base.CheckIfDisposed();
     if (this.appType == ApplicationPartitionType.ADApplicationPartition)
     {
         return this.FindAllDirectoryServersInternal(null);
     }
     if (!this.committed)
     {
         throw new InvalidOperationException(Res.GetString("CannotPerformOperationOnUncommittedObject"));
     }
     ReadOnlyDirectoryServerCollection servers = new ReadOnlyDirectoryServerCollection();
     servers.AddRange(ConfigurationSet.FindAdamInstances(base.context, base.Name, null));
     return servers;
 }
 private ReadOnlyDirectoryServerCollection GetBridgeheadServers()
 {
     NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname();
     pathname.EscapedMode = 4;
     ReadOnlyDirectoryServerCollection servers = new ReadOnlyDirectoryServerCollection();
     if (this.existing)
     {
         Hashtable hashtable = new Hashtable();
         Hashtable hashtable2 = new Hashtable();
         Hashtable hashtable3 = new Hashtable();
         string dn = "CN=Servers," + ((string) PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.DistinguishedName));
         using (DirectoryEntry entry = DirectoryEntryManager.GetDirectoryEntry(this.context, dn))
         {
             ADSearcher searcher = new ADSearcher(entry, "(|(objectCategory=server)(objectCategory=NTDSConnection))", new string[] { "fromServer", "distinguishedName", "dNSHostName", "objectCategory" }, SearchScope.Subtree, true, true);
             SearchResultCollection results = null;
             try
             {
                 results = searcher.FindAll();
             }
             catch (COMException exception)
             {
                 throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
             }
             try
             {
                 foreach (SearchResult result in results)
                 {
                     string searchResultPropertyValue = (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.ObjectCategory);
                     if (Utils.Compare(searchResultPropertyValue, 0, "CN=Server".Length, "CN=Server", 0, "CN=Server".Length) == 0)
                     {
                         hashtable3.Add((string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.DistinguishedName), (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.DnsHostName));
                     }
                 }
                 foreach (SearchResult result2 in results)
                 {
                     string str3 = (string) PropertyManager.GetSearchResultPropertyValue(result2, PropertyManager.ObjectCategory);
                     if (Utils.Compare(str3, 0, "CN=Server".Length, "CN=Server", 0, "CN=Server".Length) != 0)
                     {
                         string distinguishedName = (string) PropertyManager.GetSearchResultPropertyValue(result2, PropertyManager.FromServer);
                         string partialDN = Utils.GetPartialDN(distinguishedName, 3);
                         pathname.Set(partialDN, 4);
                         partialDN = pathname.Retrieve(11).Substring(3);
                         string key = Utils.GetPartialDN((string) PropertyManager.GetSearchResultPropertyValue(result2, PropertyManager.DistinguishedName), 2);
                         if (!hashtable.Contains(key))
                         {
                             string str7 = (string) hashtable3[key];
                             if (!hashtable2.Contains(key))
                             {
                                 hashtable2.Add(key, str7);
                             }
                             if (Utils.Compare((string) PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.Cn), partialDN) != 0)
                             {
                                 hashtable.Add(key, str7);
                                 hashtable2.Remove(key);
                             }
                         }
                     }
                 }
             }
             finally
             {
                 results.Dispose();
             }
         }
         if (hashtable2.Count != 0)
         {
             DirectoryEntry searchRoot = DirectoryEntryManager.GetDirectoryEntry(this.context, this.siteDN);
             StringBuilder builder = new StringBuilder(100);
             if (hashtable2.Count > 1)
             {
                 builder.Append("(|");
             }
             foreach (DictionaryEntry entry3 in hashtable2)
             {
                 builder.Append("(fromServer=");
                 builder.Append("CN=NTDS Settings,");
                 builder.Append(Utils.GetEscapedFilterValue((string) entry3.Key));
                 builder.Append(")");
             }
             if (hashtable2.Count > 1)
             {
                 builder.Append(")");
             }
             ADSearcher searcher2 = new ADSearcher(searchRoot, "(&(objectClass=nTDSConnection)(objectCategory=NTDSConnection)" + builder.ToString() + ")", new string[] { "fromServer", "distinguishedName" }, SearchScope.Subtree);
             SearchResultCollection results2 = null;
             try
             {
                 results2 = searcher2.FindAll();
             }
             catch (COMException exception2)
             {
                 throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2);
             }
             try
             {
                 foreach (SearchResult result3 in results2)
                 {
                     string str9 = ((string) PropertyManager.GetSearchResultPropertyValue(result3, PropertyManager.FromServer)).Substring(0x11);
                     if (hashtable2.Contains(str9))
                     {
                         string bstrADsPath = Utils.GetPartialDN((string) PropertyManager.GetSearchResultPropertyValue(result3, PropertyManager.DistinguishedName), 4);
                         pathname.Set(bstrADsPath, 4);
                         if (Utils.Compare(pathname.Retrieve(11).Substring(3), (string) PropertyManager.GetPropertyValue(this.context, this.cachedEntry, PropertyManager.Cn)) != 0)
                         {
                             string str11 = (string) hashtable2[str9];
                             hashtable2.Remove(str9);
                             hashtable.Add(str9, str11);
                         }
                     }
                 }
             }
             finally
             {
                 results2.Dispose();
                 searchRoot.Dispose();
             }
         }
         DirectoryEntry directoryEntry = null;
         foreach (DictionaryEntry entry5 in hashtable)
         {
             DirectoryServer server = null;
             string domainControllerName = (string) entry5.Value;
             if (this.IsADAM)
             {
                 directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, "CN=NTDS Settings," + entry5.Key);
                 int num = (int) PropertyManager.GetPropertyValue(this.context, directoryEntry, PropertyManager.MsDSPortLDAP);
                 string adamInstanceName = domainControllerName;
                 if (num != 0x185)
                 {
                     adamInstanceName = domainControllerName + ":" + num;
                 }
                 server = new AdamInstance(Utils.GetNewDirectoryContext(adamInstanceName, DirectoryContextType.DirectoryServer, this.context), adamInstanceName);
             }
             else
             {
                 server = new DomainController(Utils.GetNewDirectoryContext(domainControllerName, DirectoryContextType.DirectoryServer, this.context), domainControllerName);
             }
             servers.Add(server);
         }
     }
     return servers;
 }