public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ValidateArgument(context, name); if (sourceServer == null) { throw new ArgumentNullException("sourceServer"); } if ((transport < ActiveDirectoryTransportType.Rpc) || (transport > ActiveDirectoryTransportType.Smtp)) { throw new InvalidEnumArgumentException("value", (int) transport, typeof(ActiveDirectoryTransportType)); } context = new DirectoryContext(context); this.ValidateTargetAndSourceServer(context, sourceServer); this.context = context; this.connectionName = name; this.transport = transport; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ServerName); string dn = "CN=NTDS Settings," + str; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); string escapedPath = Utils.GetEscapedPath("cn=" + this.connectionName); this.cachedDirectoryEntry = directoryEntry.Children.Add(escapedPath, "nTDSConnection"); DirectoryContext context2 = sourceServer.Context; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context2, WellKnownDN.RootDSE); string str4 = (string) PropertyManager.GetPropertyValue(context2, directoryEntry, PropertyManager.ServerName); str4 = "CN=NTDS Settings," + str4; this.cachedDirectoryEntry.Properties["fromServer"].Add(str4); if (schedule != null) { this.cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } string dNFromTransportType = Utils.GetDNFromTransportType(this.TransportType, context); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dNFromTransportType); try { directoryEntry.Bind(true); } catch (COMException exception) { if (((exception.ErrorCode == -2147016656) && Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode)) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } this.cachedDirectoryEntry.Properties["transportType"].Add(dNFromTransportType); this.cachedDirectoryEntry.Properties["enabledConnection"].Value = false; this.cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException exception2) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } finally { directoryEntry.Close(); } }
public ActiveDirectorySiteLink(DirectoryContext context, string siteLinkName, ActiveDirectoryTransportType transport, ActiveDirectorySchedule schedule) { DirectoryEntry directoryEntry; this.systemDefaultInterval = new TimeSpan(0, 15, 0); this.sites = new ActiveDirectorySiteCollection(); ValidateArgument(context, siteLinkName, transport); context = new DirectoryContext(context); this.context = context; this.name = siteLinkName; this.transport = transport; try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = null; if (transport == ActiveDirectoryTransportType.Rpc) { dn = "CN=IP,CN=Inter-Site Transports,CN=Sites," + str; } else { dn = "CN=SMTP,CN=Inter-Site Transports,CN=Sites," + str; } directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name })); } try { string escapedPath = Utils.GetEscapedPath("cn=" + this.name); this.cachedEntry = directoryEntry.Children.Add(escapedPath, "siteLink"); this.cachedEntry.Properties["cost"].Value = 100; this.cachedEntry.Properties["replInterval"].Value = 180; if (schedule != null) { this.cachedEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } } catch (COMException exception2) { if (((exception2.ErrorCode == -2147016656) && Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode)) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } finally { directoryEntry.Dispose(); } }
public ActiveDirectorySiteLink(DirectoryContext context, string siteLinkName, ActiveDirectoryTransportType transport, ActiveDirectorySchedule schedule) { DirectoryEntry directoryEntry; this.systemDefaultInterval = new TimeSpan(0, 15, 0); this.sites = new ActiveDirectorySiteCollection(); ValidateArgument(context, siteLinkName, transport); context = new DirectoryContext(context); this.context = context; this.name = siteLinkName; this.transport = transport; try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = null; if (transport == ActiveDirectoryTransportType.Rpc) { dn = "CN=IP,CN=Inter-Site Transports,CN=Sites," + str; } else { dn = "CN=SMTP,CN=Inter-Site Transports,CN=Sites," + str; } directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name })); } try { string escapedPath = Utils.GetEscapedPath("cn=" + this.name); this.cachedEntry = directoryEntry.Children.Add(escapedPath, "siteLink"); this.cachedEntry.Properties["cost"].Value = 100; this.cachedEntry.Properties["replInterval"].Value = 180; if (schedule != null) { this.cachedEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } } catch (COMException exception2) { if (((exception2.ErrorCode == -2147016656) && Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode)) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } finally { directoryEntry.Dispose(); } }
public ActiveDirectorySiteLink(DirectoryContext context, string siteLinkName, ActiveDirectoryTransportType transport, ActiveDirectorySchedule schedule) { ValidateArgument(context, siteLinkName, transport); // work with copy of the context context = new DirectoryContext(context); this.context = context; _name = siteLinkName; _transport = transport; // bind to the rootdse to get the configurationnamingcontext DirectoryEntry de; try { de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string config = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ConfigurationNamingContext); string parentDN = null; if (transport == ActiveDirectoryTransportType.Rpc) { parentDN = "CN=IP,CN=Inter-Site Transports,CN=Sites," + config; } else { parentDN = "CN=SMTP,CN=Inter-Site Transports,CN=Sites," + config; } de = DirectoryEntryManager.GetDirectoryEntry(context, parentDN); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } catch (ActiveDirectoryObjectNotFoundException) { // this is the case where the context is a config set and we could not find an ADAM instance in that config set throw new ActiveDirectoryOperationException(String.Format(CultureInfo.CurrentCulture, SR.ADAMInstanceNotFoundInConfigSet, context.Name)); } try { string rdn = "cn=" + _name; rdn = Utils.GetEscapedPath(rdn); cachedEntry = de.Children.Add(rdn, "siteLink"); cachedEntry.Properties["cost"].Value = appDefaultCost; cachedEntry.Properties["replInterval"].Value = appDefaultInterval; if (schedule != null) { cachedEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } } catch (COMException e) { if (e.ErrorCode == unchecked ((int)0x80072030)) { // if it is ADAM and transport type is SMTP, throw NotSupportedException. DirectoryEntry tmpDE = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(tmpDE, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(SR.NotSupportTransportSMTP); } } throw ExceptionHelper.GetExceptionFromCOMException(context, e); } finally { de.Dispose(); } }
public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ValidateArgument(context, name); if (sourceServer == null) { throw new ArgumentNullException("sourceServer"); } if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } // work with copy of the context context = new DirectoryContext(context); ValidateTargetAndSourceServer(context, sourceServer); this.context = context; _connectionName = name; _transport = transport; DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { string serverDN = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ServerName); string connectionContainer = "CN=NTDS Settings," + serverDN; de = DirectoryEntryManager.GetDirectoryEntry(context, connectionContainer); // create the connection entry string rdn = "cn=" + _connectionName; rdn = Utils.GetEscapedPath(rdn); cachedDirectoryEntry = de.Children.Add(rdn, "nTDSConnection"); // set all the properties // sourceserver property DirectoryContext sourceServerContext = sourceServer.Context; de = DirectoryEntryManager.GetDirectoryEntry(sourceServerContext, WellKnownDN.RootDSE); string serverName = (string)PropertyManager.GetPropertyValue(sourceServerContext, de, PropertyManager.ServerName); serverName = "CN=NTDS Settings," + serverName; cachedDirectoryEntry.Properties["fromServer"].Add(serverName); // schedule property if (schedule != null) { cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } // transporttype property string transportPath = Utils.GetDNFromTransportType(TransportType, context); // verify that the transport is supported de = DirectoryEntryManager.GetDirectoryEntry(context, transportPath); try { de.Bind(true); } catch (COMException e) { if (e.ErrorCode == unchecked ((int)0x80072030)) { // if it is ADAM and transport type is SMTP, throw NotSupportedException. DirectoryEntry tmpDE = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(tmpDE, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(SR.NotSupportTransportSMTP); } } throw ExceptionHelper.GetExceptionFromCOMException(context, e); } cachedDirectoryEntry.Properties["transportType"].Add(transportPath); // enabledConnection property cachedDirectoryEntry.Properties["enabledConnection"].Value = false; // options cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } finally { de.Close(); } }
public ActiveDirectorySiteLink(DirectoryContext context, string siteLinkName, ActiveDirectoryTransportType transport, ActiveDirectorySchedule schedule) { ValidateArgument(context, siteLinkName, transport); // work with copy of the context context = new DirectoryContext(context); this.context = context; _name = siteLinkName; _transport = transport; // bind to the rootdse to get the configurationnamingcontext DirectoryEntry de; try { de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string config = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ConfigurationNamingContext); string parentDN = null; if (transport == ActiveDirectoryTransportType.Rpc) parentDN = "CN=IP,CN=Inter-Site Transports,CN=Sites," + config; else parentDN = "CN=SMTP,CN=Inter-Site Transports,CN=Sites," + config; de = DirectoryEntryManager.GetDirectoryEntry(context, parentDN); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } catch (ActiveDirectoryObjectNotFoundException) { // this is the case where the context is a config set and we could not find an ADAM instance in that config set throw new ActiveDirectoryOperationException(Res.GetString(Res.ADAMInstanceNotFoundInConfigSet, context.Name)); } try { string rdn = "cn=" + _name; rdn = Utils.GetEscapedPath(rdn); cachedEntry = de.Children.Add(rdn, "siteLink"); cachedEntry.Properties["cost"].Value = appDefaultCost; cachedEntry.Properties["replInterval"].Value = appDefaultInterval; if (schedule != null) cachedEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } catch (COMException e) { if (e.ErrorCode == unchecked((int)0x80072030)) { // if it is ADAM and transport type is SMTP, throw NotSupportedException. DirectoryEntry tmpDE = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(tmpDE, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(Res.GetString(Res.NotSupportTransportSMTP)); } } throw ExceptionHelper.GetExceptionFromCOMException(context, e); } finally { de.Dispose(); } }
public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ReplicationConnection.ValidateArgument(context, name); if (sourceServer != null) { if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } else { context = new DirectoryContext(context); this.ValidateTargetAndSourceServer(context, sourceServer); this.context = context; this.connectionName = name; this.transport = transport; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { try { string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ServerName); string str = string.Concat("CN=NTDS Settings,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); string escapedPath = string.Concat("cn=", this.connectionName); escapedPath = Utils.GetEscapedPath(escapedPath); this.cachedDirectoryEntry = directoryEntry.Children.Add(escapedPath, "nTDSConnection"); DirectoryContext directoryContext = sourceServer.Context; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(directoryContext, WellKnownDN.RootDSE); string propertyValue1 = (string)PropertyManager.GetPropertyValue(directoryContext, directoryEntry, PropertyManager.ServerName); propertyValue1 = string.Concat("CN=NTDS Settings,", propertyValue1); this.cachedDirectoryEntry.Properties["fromServer"].Add(propertyValue1); if (schedule != null) { this.cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } string dNFromTransportType = Utils.GetDNFromTransportType(this.TransportType, context); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dNFromTransportType); try { //TODO: REVIEW: URGENT!!: directoryEntry.Bind(true); } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode == -2147016656) { DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(directoryEntry1, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } } throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException); } this.cachedDirectoryEntry.Properties["transportType"].Add(dNFromTransportType); this.cachedDirectoryEntry.Properties["enabledConnection"].Value = false; this.cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } } finally { directoryEntry.Close(); } return; } } else { throw new ArgumentNullException("sourceServer"); } }
public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ReplicationConnection.ValidateArgument(context, name); if (sourceServer != null) { if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } else { context = new DirectoryContext(context); this.ValidateTargetAndSourceServer(context, sourceServer); this.context = context; this.connectionName = name; this.transport = transport; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { try { string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ServerName); string str = string.Concat("CN=NTDS Settings,", propertyValue); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); string escapedPath = string.Concat("cn=", this.connectionName); escapedPath = Utils.GetEscapedPath(escapedPath); this.cachedDirectoryEntry = directoryEntry.Children.Add(escapedPath, "nTDSConnection"); DirectoryContext directoryContext = sourceServer.Context; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(directoryContext, WellKnownDN.RootDSE); string propertyValue1 = (string)PropertyManager.GetPropertyValue(directoryContext, directoryEntry, PropertyManager.ServerName); propertyValue1 = string.Concat("CN=NTDS Settings,", propertyValue1); this.cachedDirectoryEntry.Properties["fromServer"].Add(propertyValue1); if (schedule != null) { this.cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } string dNFromTransportType = Utils.GetDNFromTransportType(this.TransportType, context); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dNFromTransportType); try { //TODO: REVIEW: URGENT!!: directoryEntry.Bind(true); } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode == -2147016656) { DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(directoryEntry1, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } } throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException); } this.cachedDirectoryEntry.Properties["transportType"].Add(dNFromTransportType); this.cachedDirectoryEntry.Properties["enabledConnection"].Value = false; this.cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } } finally { directoryEntry.Close(); } return; } } else { throw new ArgumentNullException("sourceServer"); } }
public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ValidateArgument(context, name); if (sourceServer == null) throw new ArgumentNullException("sourceServer"); if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); // work with copy of the context context = new DirectoryContext(context); ValidateTargetAndSourceServer(context, sourceServer); this.context = context; _connectionName = name; _transport = transport; DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { string serverDN = (string)PropertyManager.GetPropertyValue(context, de, PropertyManager.ServerName); string connectionContainer = "CN=NTDS Settings," + serverDN; de = DirectoryEntryManager.GetDirectoryEntry(context, connectionContainer); // create the connection entry string rdn = "cn=" + _connectionName; rdn = Utils.GetEscapedPath(rdn); cachedDirectoryEntry = de.Children.Add(rdn, "nTDSConnection"); // set all the properties // sourceserver property DirectoryContext sourceServerContext = sourceServer.Context; de = DirectoryEntryManager.GetDirectoryEntry(sourceServerContext, WellKnownDN.RootDSE); string serverName = (string)PropertyManager.GetPropertyValue(sourceServerContext, de, PropertyManager.ServerName); serverName = "CN=NTDS Settings," + serverName; cachedDirectoryEntry.Properties["fromServer"].Add(serverName); // schedule property if (schedule != null) cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); // transporttype property string transportPath = Utils.GetDNFromTransportType(TransportType, context); // verify that the transport is supported de = DirectoryEntryManager.GetDirectoryEntry(context, transportPath); try { de.Bind(true); } catch (COMException e) { if (e.ErrorCode == unchecked((int)0x80072030)) { // if it is ADAM and transport type is SMTP, throw NotSupportedException. DirectoryEntry tmpDE = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (Utils.CheckCapability(tmpDE, Capability.ActiveDirectoryApplicationMode) && transport == ActiveDirectoryTransportType.Smtp) { throw new NotSupportedException(Res.GetString(Res.NotSupportTransportSMTP)); } } throw ExceptionHelper.GetExceptionFromCOMException(context, e); } cachedDirectoryEntry.Properties["transportType"].Add(transportPath); // enabledConnection property cachedDirectoryEntry.Properties["enabledConnection"].Value = false; // options cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } finally { de.Close(); } }
public ReplicationConnection(DirectoryContext context, string name, DirectoryServer sourceServer, ActiveDirectorySchedule schedule, ActiveDirectoryTransportType transport) { ValidateArgument(context, name); if (sourceServer == null) { throw new ArgumentNullException("sourceServer"); } if ((transport < ActiveDirectoryTransportType.Rpc) || (transport > ActiveDirectoryTransportType.Smtp)) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } context = new DirectoryContext(context); this.ValidateTargetAndSourceServer(context, sourceServer); this.context = context; this.connectionName = name; this.transport = transport; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { string str = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ServerName); string dn = "CN=NTDS Settings," + str; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn); string escapedPath = Utils.GetEscapedPath("cn=" + this.connectionName); this.cachedDirectoryEntry = directoryEntry.Children.Add(escapedPath, "nTDSConnection"); DirectoryContext context2 = sourceServer.Context; directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context2, WellKnownDN.RootDSE); string str4 = (string)PropertyManager.GetPropertyValue(context2, directoryEntry, PropertyManager.ServerName); str4 = "CN=NTDS Settings," + str4; this.cachedDirectoryEntry.Properties["fromServer"].Add(str4); if (schedule != null) { this.cachedDirectoryEntry.Properties["schedule"].Value = schedule.GetUnmanagedSchedule(); } string dNFromTransportType = Utils.GetDNFromTransportType(this.TransportType, context); directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dNFromTransportType); try { directoryEntry.Bind(true); } catch (COMException exception) { if (((exception.ErrorCode == -2147016656) && Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode)) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } this.cachedDirectoryEntry.Properties["transportType"].Add(dNFromTransportType); this.cachedDirectoryEntry.Properties["enabledConnection"].Value = false; this.cachedDirectoryEntry.Properties["options"].Value = 0; } catch (COMException exception2) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } finally { directoryEntry.Close(); } }