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); }
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); }
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); }