本文整理汇总了C#中System.DirectoryServices.ActiveDirectory.DirectoryContext.isADAMConfigSet方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryContext.isADAMConfigSet方法的具体用法?C# DirectoryContext.isADAMConfigSet怎么用?C# DirectoryContext.isADAMConfigSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DirectoryServices.ActiveDirectory.DirectoryContext
的用法示例。
在下文中一共展示了DirectoryContext.isADAMConfigSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActiveDirectorySchemaProperty
public ActiveDirectorySchemaProperty(DirectoryContext context, string ldapDisplayName)
{
this.syntax = ~ActiveDirectorySyntax.CaseExactString;
this.rangeLower = null;
this.rangeUpper = null;
this.linkId = null;
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.isADAMConfigSet() && !context.isServer()))
{
throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
}
if (ldapDisplayName == null)
{
throw new ArgumentNullException("ldapDisplayName");
}
if (ldapDisplayName.Length == 0)
{
throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
}
this.context = new DirectoryContext(context);
this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
this.schemaEntry.Bind(true);
this.ldapDisplayName = ldapDisplayName;
this.commonName = ldapDisplayName;
this.isBound = false;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:ActiveDirectorySchemaProperty.cs
示例2: ActiveDirectorySchemaClass
public ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if ((context.Name == null) && (!context.isRootDomain()))
{
throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
}
if (context.Name != null)
{
// the target should be a valid forest name or a server
if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || (context.isServer())))
{
throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
}
}
if (ldapDisplayName == null)
{
throw new ArgumentNullException("ldapDisplayName");
}
if (ldapDisplayName.Length == 0)
{
throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "ldapDisplayName");
}
_context = new DirectoryContext(context);
// validate the context
_schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
_schemaEntry.Bind(true);
_ldapDisplayName = ldapDisplayName;
// the common name will default to the ldap display name
_commonName = ldapDisplayName;
// set the bind flag
this.isBound = false;
}
示例3: FindByName
public static ApplicationPartition FindByName(DirectoryContext context, string distinguishedName)
{
ApplicationPartition partition = null;
DirectoryEntryManager directoryEntryMgr = null;
DirectoryContext appNCContext = null;
// check that the argument is not null
if (context == null)
throw new ArgumentNullException("context");
if ((context.Name == null) && (!context.isRootDomain()))
{
throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
}
if (context.Name != null)
{
// the target should be a valid forest name, configset name or a server
if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || context.isServer()))
{
throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
}
}
// check that the distingushed name of the application partition is not null or empty
if (distinguishedName == null)
throw new ArgumentNullException("distinguishedName");
if (distinguishedName.Length == 0)
throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "distinguishedName");
if (!Utils.IsValidDNFormat(distinguishedName))
throw new ArgumentException(Res.GetString(Res.InvalidDNFormat), "distinguishedName");
// work with copy of the context
context = new DirectoryContext(context);
// search in the partitions container of the forest for
// crossRef objects that have their nCName set to the specified distinguishedName
directoryEntryMgr = new DirectoryEntryManager(context);
DirectoryEntry partitionsEntry = null;
try
{
partitionsEntry = DirectoryEntryManager.GetDirectoryEntry(context, directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer));
}
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));
}
// build the filter
StringBuilder str = new StringBuilder(15);
str.Append("(&(");
str.Append(PropertyManager.ObjectCategory);
str.Append("=crossRef)(");
str.Append(PropertyManager.SystemFlags);
str.Append(":1.2.840.113556.1.4.804:=");
str.Append((int)SystemFlag.SystemFlagNtdsNC);
str.Append(")(!(");
str.Append(PropertyManager.SystemFlags);
str.Append(":1.2.840.113556.1.4.803:=");
str.Append((int)SystemFlag.SystemFlagNtdsDomain);
str.Append("))(");
str.Append(PropertyManager.NCName);
str.Append("=");
str.Append(Utils.GetEscapedFilterValue(distinguishedName));
str.Append("))");
string filter = str.ToString();
string[] propertiesToLoad = new string[2];
propertiesToLoad[0] = PropertyManager.DnsRoot;
propertiesToLoad[1] = PropertyManager.NCName;
ADSearcher searcher = new ADSearcher(partitionsEntry, filter, propertiesToLoad, SearchScope.OneLevel, false /*not paged search*/, false /*no cached results*/);
SearchResult res = null;
try
{
res = searcher.FindOne();
}
catch (COMException e)
{
if (e.ErrorCode == unchecked((int)0x80072030))
{
// object is not found since we cannot even find the container in which to search
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AppNCNotFound), typeof(ApplicationPartition), distinguishedName);
}
else
{
throw ExceptionHelper.GetExceptionFromCOMException(context, e);
}
}
finally
//.........这里部分代码省略.........
示例4: FindByTransportType
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);
}
示例5: ValidateArgument
private static void ValidateArgument(DirectoryContext context, string siteLinkName, ActiveDirectoryTransportType transport)
{
// basic validation first
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 (siteLinkName == null)
throw new ArgumentNullException("siteLinkName");
if (siteLinkName.Length == 0)
throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "siteLinkName");
if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp)
throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType));
}
示例6: GetSchema
public static ActiveDirectorySchema GetSchema(DirectoryContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
// contexttype should be Forest, DirectoryServer or ConfigurationSet
if ((context.ContextType != DirectoryContextType.Forest) &&
(context.ContextType != DirectoryContextType.ConfigurationSet) &&
(context.ContextType != DirectoryContextType.DirectoryServer))
{
throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
}
if ((context.Name == null) && (!context.isRootDomain()))
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ContextNotAssociatedWithDomain), typeof(ActiveDirectorySchema), null);
}
if (context.Name != null)
{
// the target should be a valid forest name or a server
if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || (context.isServer())))
{
if (context.ContextType == DirectoryContextType.Forest)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ForestNotFound), typeof(ActiveDirectorySchema), context.Name);
}
else if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ActiveDirectorySchema), context.Name);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ServerNotFound, context.Name), typeof(ActiveDirectorySchema), null);
}
}
}
// work with copy of the context
context = new DirectoryContext(context);
DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
string schemaNC = null;
try
{
DirectoryEntry rootDSE = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
if ((context.isServer()) && (!Utils.CheckCapability(rootDSE, Capability.ActiveDirectoryOrADAM)))
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ServerNotFound, context.Name), typeof(ActiveDirectorySchema), null);
}
schemaNC = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.SchemaNamingContext);
}
catch (COMException e)
{
int errorCode = e.ErrorCode;
if (errorCode == unchecked((int)0x8007203a))
{
if (context.ContextType == DirectoryContextType.Forest)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ForestNotFound), typeof(ActiveDirectorySchema), context.Name);
}
else if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ActiveDirectorySchema), context.Name);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ServerNotFound, context.Name), typeof(ActiveDirectorySchema), null);
}
}
else
{
throw ExceptionHelper.GetExceptionFromCOMException(context, e);
}
}
catch (ActiveDirectoryObjectNotFoundException)
{
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
// 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 ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ActiveDirectorySchema), context.Name);
}
else
throw;
}
return new ActiveDirectorySchema(context, schemaNC, directoryEntryMgr);
}
示例7: ValidateArgument
private static void ValidateArgument(DirectoryContext context, string subnetName)
{
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 (subnetName == null)
{
throw new ArgumentNullException("subnetName");
}
if (subnetName.Length == 0)
{
throw new ArgumentException(Res.GetString("EmptyStringParameter"), "subnetName");
}
}
示例8: ActiveDirectorySchemaClass
public ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName)
{
this.type = SchemaClassType.Structural;
if (context != null)
{
if (context.Name != null || context.isRootDomain())
{
if (context.Name == null || context.isRootDomain() || context.isADAMConfigSet() || context.isServer())
{
if (ldapDisplayName != null)
{
if (ldapDisplayName.Length != 0)
{
this.context = new DirectoryContext(context);
this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
//TODO: REVIEW: URGENT!!:this.schemaEntry.Bind(true);
this.ldapDisplayName = ldapDisplayName;
this.commonName = ldapDisplayName;
this.isBound = false;
return;
}
else
{
throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
}
}
else
{
throw new ArgumentNullException("ldapDisplayName");
}
}
else
{
throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
}
}
else
{
throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
}
}
else
{
throw new ArgumentNullException("context");
}
}
示例9: FindByName
public static ActiveDirectorySchemaProperty FindByName(DirectoryContext context, string ldapDisplayName)
{
ActiveDirectorySchemaProperty schemaProperty = null;
if (context == null)
{
throw new ArgumentNullException("context");
}
if ((context.Name == null) && (!context.isRootDomain()))
{
throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
}
if (context.Name != null)
{
// the target should be a valid forest name or a server
if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || (context.isServer())))
{
throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
}
}
if (ldapDisplayName == null)
{
throw new ArgumentNullException("ldapDisplayName");
}
if (ldapDisplayName.Length == 0)
{
throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "ldapDisplayName");
}
// work with copy of the context
context = new DirectoryContext(context);
// create a schema property
schemaProperty = new ActiveDirectorySchemaProperty(context, ldapDisplayName, (DirectoryEntry)null, null);
return schemaProperty;
}
示例10: FindByName
public static ActiveDirectorySchemaProperty FindByName(DirectoryContext context, string ldapDisplayName)
{
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.isADAMConfigSet() && !context.isServer()))
{
throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
}
if (ldapDisplayName == null)
{
throw new ArgumentNullException("ldapDisplayName");
}
if (ldapDisplayName.Length == 0)
{
throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
}
context = new DirectoryContext(context);
return new ActiveDirectorySchemaProperty(context, ldapDisplayName, null, null);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:ActiveDirectorySchemaProperty.cs
示例11: GetConfigurationSet
public static ConfigurationSet GetConfigurationSet(DirectoryContext context)
{
// check that the argument is not null
if (context == null)
throw new ArgumentNullException("context");
// target should ConfigurationSet or DirectoryServer
if ((context.ContextType != DirectoryContextType.ConfigurationSet) &&
(context.ContextType != DirectoryContextType.DirectoryServer))
{
throw new ArgumentException(Res.GetString(Res.TargetShouldBeServerORConfigSet), "context");
}
// target should be an adam config set or server
if (((!context.isServer()) && (!context.isADAMConfigSet())))
{
// the target should be a server or an ADAM Config Set
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
}
}
// work with copy of the context
context = new DirectoryContext(context);
//
// bind to rootdse of an adam instance (if target is already a server, verify that it is an adam instance)
//
DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
DirectoryEntry rootDSE = null;
string configSetName = null;
try
{
rootDSE = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
if ((context.isServer()) && (!Utils.CheckCapability(rootDSE, Capability.ActiveDirectoryApplicationMode)))
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
}
configSetName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.ConfigurationNamingContext);
}
catch (COMException e)
{
int errorCode = e.ErrorCode;
if (errorCode == unchecked((int)0x8007203a))
{
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
}
}
else
{
throw ExceptionHelper.GetExceptionFromCOMException(context, e);
}
}
catch (ActiveDirectoryObjectNotFoundException)
{
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
// this is the case when we could not find an ADAM instance in that config set
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
}
else
throw;
}
// return config set object
return new ConfigurationSet(context, configSetName, directoryEntryMgr);
}
示例12: FindByTransportType
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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:61,代码来源:ActiveDirectoryInterSiteTransport.cs
示例13: GetSchema
public static ActiveDirectorySchema GetSchema(DirectoryContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if (((context.ContextType != DirectoryContextType.Forest) && (context.ContextType != DirectoryContextType.ConfigurationSet)) && (context.ContextType != DirectoryContextType.DirectoryServer))
{
throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
}
if ((context.Name == null) && !context.isRootDomain())
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(ActiveDirectorySchema), null);
}
if (((context.Name != null) && !context.isRootDomain()) && (!context.isADAMConfigSet() && !context.isServer()))
{
if (context.ContextType == DirectoryContextType.Forest)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(ActiveDirectorySchema), context.Name);
}
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
}
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
}
context = new DirectoryContext(context);
DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
string distinguishedName = null;
try
{
DirectoryEntry cachedDirectoryEntry = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
if (context.isServer() && !Utils.CheckCapability(cachedDirectoryEntry, Capability.ActiveDirectoryOrADAM))
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
}
distinguishedName = (string) PropertyManager.GetPropertyValue(context, cachedDirectoryEntry, PropertyManager.SchemaNamingContext);
}
catch (COMException exception)
{
if (exception.ErrorCode != -2147016646)
{
throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
}
if (context.ContextType == DirectoryContextType.Forest)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(ActiveDirectorySchema), context.Name);
}
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
}
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
}
catch (ActiveDirectoryObjectNotFoundException)
{
if (context.ContextType == DirectoryContextType.ConfigurationSet)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
}
throw;
}
return new ActiveDirectorySchema(context, distinguishedName, directoryEntryMgr);
}
示例14: ValidateArgument
private static void ValidateArgument(DirectoryContext context, string bridgeName, ActiveDirectoryTransportType transport)
{
if (context != null)
{
if (context.Name != null || context.isRootDomain())
{
if (context.Name == null || context.isRootDomain() || context.isServer() || context.isADAMConfigSet())
{
if (bridgeName != null)
{
if (bridgeName.Length != 0)
{
if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp)
{
throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType));
}
else
{
return;
}
}
else
{
throw new ArgumentException(Res.GetString("EmptyStringParameter"), "bridgeName");
}
}
else
{
throw new ArgumentNullException("bridgeName");
}
}
else
{
throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
}
}
else
{
throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
}
}
else
{
throw new ArgumentNullException("context");
}
}
示例15: FindByName
public static ApplicationPartition FindByName(DirectoryContext context, string distinguishedName)
{
DomainControllerInfo domainControllerInfo = null;
string item;
DirectoryContext newDirectoryContext = null;
if (context != null)
{
if (context.Name != null || context.isRootDomain())
{
if (context.Name == null || context.isRootDomain() || context.isADAMConfigSet() || context.isServer())
{
if (distinguishedName != null)
{
if (distinguishedName.Length != 0)
{
if (Utils.IsValidDNFormat(distinguishedName))
{
context = new DirectoryContext(context);
DirectoryEntryManager directoryEntryManager = new DirectoryEntryManager(context);
DirectoryEntry directoryEntry = null;
try
{
directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, directoryEntryManager.ExpandWellKnownDN(WellKnownDN.PartitionsContainer));
}
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));
}
StringBuilder stringBuilder = new StringBuilder(15);
stringBuilder.Append("(&(");
stringBuilder.Append(PropertyManager.ObjectCategory);
stringBuilder.Append("=crossRef)(");
stringBuilder.Append(PropertyManager.SystemFlags);
stringBuilder.Append(":1.2.840.113556.1.4.804:=");
stringBuilder.Append(1);
stringBuilder.Append(")(!(");
stringBuilder.Append(PropertyManager.SystemFlags);
stringBuilder.Append(":1.2.840.113556.1.4.803:=");
stringBuilder.Append(2);
stringBuilder.Append("))(");
stringBuilder.Append(PropertyManager.NCName);
stringBuilder.Append("=");
stringBuilder.Append(Utils.GetEscapedFilterValue(distinguishedName));
stringBuilder.Append("))");
string str = stringBuilder.ToString();
string[] dnsRoot = new string[2];
dnsRoot[0] = PropertyManager.DnsRoot;
dnsRoot[1] = PropertyManager.NCName;
ADSearcher aDSearcher = new ADSearcher(directoryEntry, str, dnsRoot, SearchScope.OneLevel, false, false);
SearchResult searchResult = null;
try
{
try
{
searchResult = aDSearcher.FindOne();
}
catch (COMException cOMException3)
{
COMException cOMException2 = cOMException3;
if (cOMException2.ErrorCode != -2147016656)
{
throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AppNCNotFound"), typeof(ApplicationPartition), distinguishedName);
}
}
}
finally
{
directoryEntry.Dispose();
}
if (searchResult != null)
{
string str1 = null;
try
{
if (searchResult.Properties[PropertyManager.DnsRoot].Count > 0)
{
item = (string)searchResult.Properties[PropertyManager.DnsRoot][0];
}
else
{
item = null;
}
str1 = item;
}
catch (COMException cOMException5)
{
COMException cOMException4 = cOMException5;
throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException4);
}
//.........这里部分代码省略.........