public ApplicationPartition(DirectoryContext context, string distinguishedName) { this.appType = ApplicationPartitionType.Unknown; this.committed = true; this.ValidateApplicationPartitionParameters(context, distinguishedName, null, false); this.CreateApplicationPartition(distinguishedName, "domainDns"); }
// Internal Constructors internal ApplicationPartition(DirectoryContext context, string distinguishedName, string dnsName, ApplicationPartitionType appType, DirectoryEntryManager directoryEntryMgr) : base(context, distinguishedName) { this.directoryEntryMgr = directoryEntryMgr; _appType = appType; _dnsName = dnsName; }
public ApplicationPartition(DirectoryContext context, string distinguishedName, string objectClass) { this.appType = ApplicationPartitionType.Unknown; this.committed = true; this.ValidateApplicationPartitionParameters(context, distinguishedName, objectClass, true); this.CreateApplicationPartition(distinguishedName, objectClass); }
private static ApplicationPartitionType GetApplicationPartitionType(DirectoryContext context) { ApplicationPartitionType unknown = ApplicationPartitionType.Unknown; DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { foreach (string str in directoryEntry.Properties[PropertyManager.SupportedCapabilities]) { if (string.Compare(str, SupportedCapability.ADOid, StringComparison.OrdinalIgnoreCase) == 0) { unknown = ApplicationPartitionType.ADApplicationPartition; } if (string.Compare(str, SupportedCapability.ADAMOid, StringComparison.OrdinalIgnoreCase) == 0) { unknown = ApplicationPartitionType.ADAMApplicationPartition; } } } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } finally { directoryEntry.Dispose(); } if (unknown == ApplicationPartitionType.Unknown) { throw new ActiveDirectoryOperationException(Res.GetString("ApplicationPartitionTypeUnknown")); } return(unknown); }
internal ApplicationPartition(DirectoryContext context, string distinguishedName, string dnsName, ApplicationPartitionType appType, DirectoryEntryManager directoryEntryMgr) : base(context, distinguishedName) { this.appType = ApplicationPartitionType.Unknown; this.committed = true; base.directoryEntryMgr = directoryEntryMgr; this.appType = appType; this.dnsName = dnsName; }
private void ValidateApplicationPartitionParameters(DirectoryContext context, string distinguishedName, string objectClass, bool objectClassSpecified) { if (context == null) { throw new ArgumentNullException("context"); } if ((context.Name == null) || !context.isServer()) { throw new ArgumentException(Res.GetString("TargetShouldBeServer"), "context"); } if (distinguishedName == null) { throw new ArgumentNullException("distinguishedName"); } if (distinguishedName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "distinguishedName"); } base.context = new DirectoryContext(context); base.directoryEntryMgr = new DirectoryEntryManager(base.context); this.dnsName = Utils.GetDnsNameFromDN(distinguishedName); base.partitionName = distinguishedName; if (Utils.GetDNComponents(distinguishedName).Length == 1) { throw new NotSupportedException(Res.GetString("OneLevelPartitionNotSupported")); } this.appType = GetApplicationPartitionType(base.context); if ((this.appType == ApplicationPartitionType.ADApplicationPartition) && objectClassSpecified) { throw new InvalidOperationException(Res.GetString("NoObjectClassForADPartition")); } if (objectClassSpecified) { if (objectClass == null) { throw new ArgumentNullException("objectClass"); } if (objectClass.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "objectClass"); } } if (this.appType == ApplicationPartitionType.ADApplicationPartition) { string name = null; try { DirectoryEntry cachedDirectoryEntry = base.directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE); name = (string)PropertyManager.GetPropertyValue(base.context, cachedDirectoryEntry, PropertyManager.DnsHostName); } catch (COMException exception) { ExceptionHelper.GetExceptionFromCOMException(base.context, exception); } base.context = Utils.GetNewDirectoryContext(name, DirectoryContextType.DirectoryServer, context); } }
private static string PrepareError(double last, string ord, ApplicationPartitionType role, char instance2, bool iscust3) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 if (role == (ApplicationPartitionType)1 || (!double.IsInfinity(last) && !double.IsNaN(last))) { return(ord); } if (role == (ApplicationPartitionType)2) { if (iscust3) { return(testError); } return("0.0"); } return(instance2 + ord + instance2); }
private void ValidateApplicationPartitionParameters(DirectoryContext context, string distinguishedName, string objectClass, bool objectClassSpecified) { // validate context if (context == null) { throw new ArgumentNullException("context"); } // contexttype should be DirectoryServer if ((context.Name == null) || (!context.isServer())) { throw new ArgumentException(Res.GetString(Res.TargetShouldBeServer), "context"); } // check that the distinguished name is not null or empty if (distinguishedName == null) { throw new ArgumentNullException("distinguishedName"); } if (distinguishedName.Length == 0) { throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "distinguishedName"); } // initialize private variables this.context = new DirectoryContext(context); this.directoryEntryMgr = new DirectoryEntryManager(this.context); // validate the distinguished name // Utils.GetDnsNameFromDN will throw an ArgumentException if the dn is not valid (cannot be syntactically converted to dns name) _dnsName = Utils.GetDnsNameFromDN(distinguishedName); this.partitionName = distinguishedName; // // if the partition being created is a one-level partition, we do not support it // Component[] components = Utils.GetDNComponents(distinguishedName); if (components.Length == 1) { throw new NotSupportedException(Res.GetString(Res.OneLevelPartitionNotSupported)); } // check if the object class can be specified _appType = GetApplicationPartitionType(this.context); if ((_appType == ApplicationPartitionType.ADApplicationPartition) && (objectClassSpecified)) { throw new InvalidOperationException(Res.GetString(Res.NoObjectClassForADPartition)); } else if (objectClassSpecified) { // ADAM case and objectClass is explicitly specified, so must be validated if (objectClass == null) { throw new ArgumentNullException("objectClass"); } if (objectClass.Length == 0) { throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "objectClass"); } } if (_appType == ApplicationPartitionType.ADApplicationPartition) { // // the target in the directory context could be the netbios name of the server, so we will get the dns name // (since application partition creation will fail if dns name is not specified) // string serverDnsName = null; try { DirectoryEntry rootDSEEntry = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE); serverDnsName = (string)PropertyManager.GetPropertyValue(this.context, rootDSEEntry, PropertyManager.DnsHostName); } catch (COMException e) { ExceptionHelper.GetExceptionFromCOMException(this.context, e); } this.context = Utils.GetNewDirectoryContext(serverDnsName, DirectoryContextType.DirectoryServer, context); } }
private void ValidateApplicationPartitionParameters(DirectoryContext context, string distinguishedName, string objectClass, bool objectClassSpecified) { if (context != null) { if (context.Name == null || !context.isServer()) { throw new ArgumentException(Res.GetString("TargetShouldBeServer"), "context"); } else { if (distinguishedName != null) { if (distinguishedName.Length != 0) { this.context = new DirectoryContext(context); this.directoryEntryMgr = new DirectoryEntryManager(this.context); this.dnsName = Utils.GetDnsNameFromDN(distinguishedName); this.partitionName = distinguishedName; Component[] dNComponents = Utils.GetDNComponents(distinguishedName); if ((int)dNComponents.Length != 1) { this.appType = ApplicationPartition.GetApplicationPartitionType(this.context); if (this.appType != ApplicationPartitionType.ADApplicationPartition || !objectClassSpecified) { if (objectClassSpecified) { if (objectClass != null) { if (objectClass.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "objectClass"); } } else { throw new ArgumentNullException("objectClass"); } } if (this.appType == ApplicationPartitionType.ADApplicationPartition) { string propertyValue = null; try { DirectoryEntry cachedDirectoryEntry = this.directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE); propertyValue = (string)PropertyManager.GetPropertyValue(this.context, cachedDirectoryEntry, PropertyManager.DnsHostName); } catch (COMException cOMException1) { COMException cOMException = cOMException1; ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException); } this.context = Utils.GetNewDirectoryContext(propertyValue, DirectoryContextType.DirectoryServer, context); } return; } else { throw new InvalidOperationException(Res.GetString("NoObjectClassForADPartition")); } } else { throw new NotSupportedException(Res.GetString("OneLevelPartitionNotSupported")); } } else { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "distinguishedName"); } } else { throw new ArgumentNullException("distinguishedName"); } } } else { throw new ArgumentNullException("context"); } }
private void ValidateApplicationPartitionParameters(DirectoryContext context, string distinguishedName, string objectClass, bool objectClassSpecified) { if (context == null) { throw new ArgumentNullException("context"); } if ((context.Name == null) || !context.isServer()) { throw new ArgumentException(Res.GetString("TargetShouldBeServer"), "context"); } if (distinguishedName == null) { throw new ArgumentNullException("distinguishedName"); } if (distinguishedName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "distinguishedName"); } base.context = new DirectoryContext(context); base.directoryEntryMgr = new DirectoryEntryManager(base.context); this.dnsName = Utils.GetDnsNameFromDN(distinguishedName); base.partitionName = distinguishedName; if (Utils.GetDNComponents(distinguishedName).Length == 1) { throw new NotSupportedException(Res.GetString("OneLevelPartitionNotSupported")); } this.appType = GetApplicationPartitionType(base.context); if ((this.appType == ApplicationPartitionType.ADApplicationPartition) && objectClassSpecified) { throw new InvalidOperationException(Res.GetString("NoObjectClassForADPartition")); } if (objectClassSpecified) { if (objectClass == null) { throw new ArgumentNullException("objectClass"); } if (objectClass.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "objectClass"); } } if (this.appType == ApplicationPartitionType.ADApplicationPartition) { string name = null; try { DirectoryEntry cachedDirectoryEntry = base.directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE); name = (string) PropertyManager.GetPropertyValue(base.context, cachedDirectoryEntry, PropertyManager.DnsHostName); } catch (COMException exception) { ExceptionHelper.GetExceptionFromCOMException(base.context, exception); } base.context = Utils.GetNewDirectoryContext(name, DirectoryContextType.DirectoryServer, context); } }
internal static string AwakeError(double task, ApplicationPartitionType counter, char dir, bool allowtoken2) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 return(PrepareError(task, UpdateError(task, task.ToString("R", CultureInfo.InvariantCulture)), counter, dir, allowtoken2)); }
internal static string PushError(float key, ApplicationPartitionType pol, char control, bool isivk2) { //Discarded unreachable code: IL_0002 //IL_0003: Incompatible stack heights: 0 vs 1 return(PrepareError(key, UpdateError(key, key.ToString("R", CultureInfo.InvariantCulture)), pol, control, isivk2)); }
public static ApplicationPartition FindByName(DirectoryContext context, string distinguishedName) { DirectoryEntryManager directoryEntryMgr = null; DirectoryContext context2 = 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 (distinguishedName == null) { throw new ArgumentNullException("distinguishedName"); } if (distinguishedName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "distinguishedName"); } if (!Utils.IsValidDNFormat(distinguishedName)) { throw new ArgumentException(Res.GetString("InvalidDNFormat"), "distinguishedName"); } context = new DirectoryContext(context); directoryEntryMgr = new DirectoryEntryManager(context); DirectoryEntry searchRoot = null; try { searchRoot = DirectoryEntryManager.GetDirectoryEntry(context, directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer)); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name })); } StringBuilder builder = new StringBuilder(15); builder.Append("(&("); builder.Append(PropertyManager.ObjectCategory); builder.Append("=crossRef)("); builder.Append(PropertyManager.SystemFlags); builder.Append(":1.2.840.113556.1.4.804:="); builder.Append(1); builder.Append(")(!("); builder.Append(PropertyManager.SystemFlags); builder.Append(":1.2.840.113556.1.4.803:="); builder.Append(2); builder.Append("))("); builder.Append(PropertyManager.NCName); builder.Append("="); builder.Append(Utils.GetEscapedFilterValue(distinguishedName)); builder.Append("))"); string filter = builder.ToString(); string[] propertiesToLoad = new string[] { PropertyManager.DnsRoot, PropertyManager.NCName }; ADSearcher searcher = new ADSearcher(searchRoot, filter, propertiesToLoad, SearchScope.OneLevel, false, false); SearchResult res = null; try { res = searcher.FindOne(); } catch (COMException exception2) { if (exception2.ErrorCode == -2147016656) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AppNCNotFound"), typeof(ApplicationPartition), distinguishedName); } throw ExceptionHelper.GetExceptionFromCOMException(context, exception2); } finally { searchRoot.Dispose(); } if (res == null) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AppNCNotFound"), typeof(ApplicationPartition), distinguishedName); } string domainName = null; try { domainName = (res.Properties[PropertyManager.DnsRoot].Count > 0) ? ((string)res.Properties[PropertyManager.DnsRoot][0]) : null; } catch (COMException exception3) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception3); } ApplicationPartitionType applicationPartitionType = GetApplicationPartitionType(context); if (context.ContextType != DirectoryContextType.DirectoryServer) { if (applicationPartitionType == ApplicationPartitionType.ADApplicationPartition) { DomainControllerInfo info; int errorCode = 0; errorCode = Locator.DsGetDcNameWrapper(null, domainName, null, 0x8000L, out info); if (errorCode == 0x54b) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AppNCNotFound"), typeof(ApplicationPartition), distinguishedName); } if (errorCode != 0) { throw ExceptionHelper.GetExceptionFromErrorCode(errorCode); } context2 = Utils.GetNewDirectoryContext(info.DomainControllerName.Substring(2), DirectoryContextType.DirectoryServer, context); } else { context2 = Utils.GetNewDirectoryContext(ConfigurationSet.FindOneAdamInstance(context.Name, context, distinguishedName, null).Name, DirectoryContextType.DirectoryServer, context); } goto Label_03FC; } bool flag = false; DistinguishedName dn = new DistinguishedName(distinguishedName); DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); try { foreach (string str3 in directoryEntry.Properties[PropertyManager.NamingContexts]) { DistinguishedName name2 = new DistinguishedName(str3); if (name2.Equals(dn)) { flag = true; goto Label_0352; } } } catch (COMException exception4) { throw ExceptionHelper.GetExceptionFromCOMException(context, exception4); } finally { directoryEntry.Dispose(); } Label_0352: if (!flag) { throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AppNCNotFound"), typeof(ApplicationPartition), distinguishedName); } context2 = context; Label_03FC: return(new ApplicationPartition(context2, (string)PropertyManager.GetSearchResultPropertyValue(res, PropertyManager.NCName), domainName, applicationPartitionType, directoryEntryMgr)); }