public override string ToString() { if (_disposed) { throw new ObjectDisposedException(GetType().Name); } return(_transport.ToString()); }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { DirectoryEntry directoryEntry; if (context != null) { if (context.Name != null || context.isRootDomain()) { if (context.Name == null || context.isRootDomain() || context.isServer() || context.isADAMConfigSet()) { if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } else { context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Inter-Site Transports,CN=Sites,", propertyValue); if (transport != ActiveDirectoryTransportType.Rpc) { str = string.Concat("CN=SMTP,", str); } else { str = string.Concat("CN=IP,", str); } directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); } 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)); } try { string[] strArrays = new string[1]; strArrays[0] = "options"; directoryEntry.RefreshCache(strArrays); } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; if (cOMException2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } else { DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (!Utils.CheckCapability(directoryEntry1, Capability.ActiveDirectoryApplicationMode) || transport != ActiveDirectoryTransportType.Smtp) { object[] objArray = new object[1]; objArray[0] = transport.ToString(); throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", objArray), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } else { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } } } return new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry); } } else { throw new ArgumentException(Res.GetString("NotADOrADAM"), "context"); } } else { throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context"); } } else { throw new ArgumentNullException("context"); } }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { if (context == null) { throw new ArgumentNullException("context"); } // if target is not specified, then we determin the target from the logon credential, so if it is a local user context, it should fail if ((context.Name == null) && (!context.isRootDomain())) { throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context"); } // more validation for the context, if the target is not null, then it should be either forest name or server name if (context.Name != null) { if (!(context.isRootDomain() || context.isServer() || context.isADAMConfigSet())) { throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context"); } } 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); // 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 containerDN = "CN=Inter-Site Transports,CN=Sites," + config; if (transport == ActiveDirectoryTransportType.Rpc) { containerDN = "CN=IP," + containerDN; } else { containerDN = "CN=SMTP," + containerDN; } de = DirectoryEntryManager.GetDirectoryEntry(context, containerDN); } 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 { de.RefreshCache(new string[] { "options" }); } 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 new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.TransportNotFound, transport.ToString()), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } else { throw ExceptionHelper.GetExceptionFromCOMException(context, e); } } return(new ActiveDirectoryInterSiteTransport(context, transport, de)); }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { if (context == null) throw new ArgumentNullException("context"); // if target is not specified, then we determin the target from the logon credential, so if it is a local user context, it should fail if ((context.Name == null) && (!context.isRootDomain())) { throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context"); } // more validation for the context, if the target is not null, then it should be either forest name or server name if (context.Name != null) { if (!(context.isRootDomain() || context.isServer() || context.isADAMConfigSet())) throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context"); } 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); // 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 containerDN = "CN=Inter-Site Transports,CN=Sites," + config; if (transport == ActiveDirectoryTransportType.Rpc) containerDN = "CN=IP," + containerDN; else containerDN = "CN=SMTP," + containerDN; de = DirectoryEntryManager.GetDirectoryEntry(context, containerDN); } 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 { de.RefreshCache(new string[] { "options" }); } 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 new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.TransportNotFound, transport.ToString()), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } else throw ExceptionHelper.GetExceptionFromCOMException(context, e); } return new ActiveDirectoryInterSiteTransport(context, transport, de); }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { DirectoryEntry directoryEntry; if (context == null) { throw new ArgumentNullException("context"); } if ((context.Name == null) && !context.isRootDomain()) { throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context"); } if (((context.Name != null) && !context.isRootDomain()) && (!context.isServer() && !context.isADAMConfigSet())) { throw new ArgumentException(Res.GetString("NotADOrADAM"), "context"); } if ((transport < ActiveDirectoryTransportType.Rpc) || (transport > ActiveDirectoryTransportType.Smtp)) { throw new InvalidEnumArgumentException("value", (int) transport, typeof(ActiveDirectoryTransportType)); } context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = "CN=Inter-Site Transports,CN=Sites," + str; if (transport == ActiveDirectoryTransportType.Rpc) { dn = "CN=IP," + dn; } else { dn = "CN=SMTP," + dn; } 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 { directoryEntry.RefreshCache(new string[] { "options" }); } catch (COMException exception2) { if (exception2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } if (Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", new object[] { transport.ToString() }), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } return new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry); }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { DirectoryEntry directoryEntry; if (context == null) { throw new ArgumentNullException("context"); } if ((context.Name == null) && !context.isRootDomain()) { throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context"); } if (((context.Name != null) && !context.isRootDomain()) && (!context.isServer() && !context.isADAMConfigSet())) { throw new ArgumentException(Res.GetString("NotADOrADAM"), "context"); } if ((transport < ActiveDirectoryTransportType.Rpc) || (transport > ActiveDirectoryTransportType.Smtp)) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string str = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string dn = "CN=Inter-Site Transports,CN=Sites," + str; if (transport == ActiveDirectoryTransportType.Rpc) { dn = "CN=IP," + dn; } else { dn = "CN=SMTP," + dn; } 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 { directoryEntry.RefreshCache(new string[] { "options" }); } catch (COMException exception2) { if (exception2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } if (Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode) && (transport == ActiveDirectoryTransportType.Smtp)) { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", new object[] { transport.ToString() }), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } return(new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry)); }
public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport) { DirectoryEntry directoryEntry; if (context != null) { if (context.Name != null || context.isRootDomain()) { if (context.Name == null || context.isRootDomain() || context.isServer() || context.isADAMConfigSet()) { if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp) { throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType)); } else { context = new DirectoryContext(context); try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext); string str = string.Concat("CN=Inter-Site Transports,CN=Sites,", propertyValue); if (transport != ActiveDirectoryTransportType.Rpc) { str = string.Concat("CN=SMTP,", str); } else { str = string.Concat("CN=IP,", str); } directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str); } 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)); } try { string[] strArrays = new string[1]; strArrays[0] = "options"; directoryEntry.RefreshCache(strArrays); } catch (COMException cOMException3) { COMException cOMException2 = cOMException3; if (cOMException2.ErrorCode != -2147016656) { throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2); } else { DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); if (!Utils.CheckCapability(directoryEntry1, Capability.ActiveDirectoryApplicationMode) || transport != ActiveDirectoryTransportType.Smtp) { object[] objArray = new object[1]; objArray[0] = transport.ToString(); throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", objArray), typeof(ActiveDirectoryInterSiteTransport), transport.ToString()); } else { throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP")); } } } return(new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry)); } } else { throw new ArgumentException(Res.GetString("NotADOrADAM"), "context"); } } else { throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context"); } } else { throw new ArgumentNullException("context"); } }