public int Add(ActiveDirectorySchemaClass schemaClass) { if (schemaClass != null) { if (schemaClass.isBound) { if (this.Contains(schemaClass)) { object[] objArray = new object[1]; objArray[0] = schemaClass; throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", objArray), "schemaClass"); } else { return base.List.Add(schemaClass); } } else { object[] name = new object[1]; name[0] = schemaClass.Name; throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", name)); } } else { throw new ArgumentNullException("schemaClass"); } }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { Contract.Requires(schemaClass != null); Contract.Ensures(Contract.Result<int>() >= -1); Contract.Ensures(Contract.Result<int>() < this.Count); return default(int); }
internal ActiveDirectorySchemaPropertyCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, bool isBound, string propertyName, ICollection properties) { this.schemaClass = schemaClass; this.propertyName = propertyName; this.isBound = isBound; this.context = context; foreach (ActiveDirectorySchemaProperty property in properties) { base.InnerList.Add(property); } }
internal ActiveDirectorySchemaPropertyCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, bool isBound, string propertyName, ICollection propertyNames, bool onlyNames) { this.schemaClass = schemaClass; this.propertyName = propertyName; this.isBound = isBound; this.context = context; foreach (string str in propertyNames) { base.InnerList.Add(new ActiveDirectorySchemaProperty(context, str, null, null)); } }
public int Add(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", new object[] { schemaClass.Name })); } if (this.Contains(schemaClass)) { throw new ArgumentException(Res.GetString("AlreadyExistingInCollection", new object[] { schemaClass }), "schemaClass"); } return base.List.Add(schemaClass); }
internal ActiveDirectorySchemaPropertyCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, bool isBound, string propertyName, ICollection properties) { _schemaClass = schemaClass; _propertyName = propertyName; _isBound = isBound; _context = context; foreach (ActiveDirectorySchemaProperty schemaProperty in properties) { this.InnerList.Add(schemaProperty); } }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySchemaClass class2 = (ActiveDirectorySchemaClass) base.InnerList[i]; if (Utils.Compare(class2.Name, schemaClass.Name) == 0) { return i; } } return -1; }
internal ActiveDirectorySchemaPropertyCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, bool isBound, string propertyName, ICollection propertyNames, bool onlyNames) { _schemaClass = schemaClass; _propertyName = propertyName; _isBound = isBound; _context = context; foreach (string ldapDisplayName in propertyNames) { // all properties in writeable property collection are non-defunct // so calling constructor for non-defunct property this.InnerList.Add(new ActiveDirectorySchemaProperty(context, ldapDisplayName, (DirectoryEntry)null, null)); } }
public void AddRange(ActiveDirectorySchemaClass[] schemaClasses) { if (schemaClasses == null) { throw new ArgumentNullException("schemaClasses"); } ActiveDirectorySchemaClass[] classArray = schemaClasses; for (int i = 0; i < classArray.Length; i++) { if (classArray[i] == null) { throw new ArgumentException("schemaClasses"); } } for (int j = 0; j < schemaClasses.Length; j++) { this.Add(schemaClasses[j]); } }
internal ActiveDirectorySchemaClassCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, bool isBound, string propertyName, ICollection classNames, bool onlyNames) { _schemaClass = schemaClass; _propertyName = propertyName; _isBound = isBound; _context = context; foreach (string ldapDisplayName in classNames) { // all properties in writeable class collection are non-defunct // so calling constructor for non-defunct class InnerList.Add(new ActiveDirectorySchemaClass(context, ldapDisplayName, (DirectoryEntry)null, null)); } }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", new object[] { schemaClass.Name })); } for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySchemaClass class2 = (ActiveDirectorySchemaClass)base.InnerList[i]; if (Utils.Compare(class2.Name, schemaClass.Name) == 0) { return(i); } } return(-1); }
public void Insert(int index, ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString(Res.SchemaObjectNotCommitted, schemaClass.Name)); } if (!Contains(schemaClass)) { List.Insert(index, schemaClass); } else { throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, schemaClass), "schemaClass"); } }
public void Remove(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", new object[] { schemaClass.Name })); } for (int i = 0; i < base.InnerList.Count; i++) { ActiveDirectorySchemaClass class2 = (ActiveDirectorySchemaClass)base.InnerList[i]; if (Utils.Compare(class2.Name, schemaClass.Name) == 0) { base.List.Remove(class2); return; } } throw new ArgumentException(Res.GetString("NotFoundInCollection", new object[] { schemaClass }), "schemaClass"); }
public int Add(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString(Res.SchemaObjectNotCommitted, schemaClass.Name)); } if (!Contains(schemaClass)) { return List.Add(schemaClass); } else { throw new ArgumentException(Res.GetString(Res.AlreadyExistingInCollection, schemaClass), "schemaClass"); } }
public int Add(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SchemaObjectNotCommitted, schemaClass.Name)); } if (!Contains(schemaClass)) { return(List.Add(schemaClass)); } else { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.AlreadyExistingInCollection, schemaClass), "schemaClass"); } }
// // This method finds only among defunct classes // public ActiveDirectorySchemaClass FindDefunctClass(string commonName) { CheckIfDisposed(); if (commonName == null) { throw new ArgumentNullException(nameof(commonName)); } if (commonName.Length == 0) { throw new ArgumentException(SR.EmptyStringParameter, nameof(commonName)); } // this will bind to the schema container and load the properties of this class // (will also check whether or not the class exists) Hashtable propertiesFromServer = ActiveDirectorySchemaClass.GetPropertiesFromSchemaContainer(context, _schemaEntry, commonName, true /* isDefunctOnServer */); ActiveDirectorySchemaClass schemaClass = new ActiveDirectorySchemaClass(context, commonName, propertiesFromServer, _schemaEntry); return(schemaClass); }
public ActiveDirectorySchemaClass FindDefunctClass(string commonName) { base.CheckIfDisposed(); if (commonName != null) { if (commonName.Length != 0) { Hashtable propertiesFromSchemaContainer = ActiveDirectorySchemaClass.GetPropertiesFromSchemaContainer(this.context, this.schemaEntry, commonName, true); ActiveDirectorySchemaClass activeDirectorySchemaClass = new ActiveDirectorySchemaClass(this.context, commonName, propertiesFromSchemaContainer, this.schemaEntry); return(activeDirectorySchemaClass); } else { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "commonName"); } } else { throw new ArgumentNullException("commonName"); } }
public bool Contains(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(Res.GetString(Res.SchemaObjectNotCommitted, schemaClass.Name)); } for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySchemaClass tmp = (ActiveDirectorySchemaClass)InnerList[i]; if (Utils.Compare(tmp.Name, schemaClass.Name) == 0) { return(true); } } return(false); }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SchemaObjectNotCommitted, schemaClass.Name)); } for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySchemaClass tmp = (ActiveDirectorySchemaClass)InnerList[i]; if (Utils.Compare(tmp.Name, schemaClass.Name) == 0) { return(i); } } return(-1); }
public void Remove(ActiveDirectorySchemaClass schemaClass) { if (schemaClass == null) { throw new ArgumentNullException("schemaClass"); } if (!schemaClass.isBound) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, SR.SchemaObjectNotCommitted, schemaClass.Name)); } for (int i = 0; i < InnerList.Count; i++) { ActiveDirectorySchemaClass tmp = (ActiveDirectorySchemaClass)InnerList[i]; if (Utils.Compare(tmp.Name, schemaClass.Name) == 0) { List.Remove(tmp); return; } } throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.NotFoundInCollection, schemaClass), "schemaClass"); }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { if (schemaClass != null) { int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySchemaClass item = (ActiveDirectorySchemaClass)base.InnerList[num]; if (Utils.Compare(item.Name, schemaClass.Name) != 0) { num++; } else { return(num); } } return(-1); } else { throw new ArgumentNullException("schemaClass"); } }
public void Remove(ActiveDirectorySchemaClass schemaClass) { if (schemaClass != null) { if (schemaClass.isBound) { int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySchemaClass item = (ActiveDirectorySchemaClass)base.InnerList[num]; if (Utils.Compare(item.Name, schemaClass.Name) != 0) { num++; } else { base.List.Remove(item); return; } } object[] objArray = new object[1]; objArray[0] = schemaClass; throw new ArgumentException(Res.GetString("NotFoundInCollection", objArray), "schemaClass"); } else { object[] name = new object[1]; name[0] = schemaClass.Name; throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", name)); } } else { throw new ArgumentNullException("schemaClass"); } }
// // This method finds only among non-defunct classes // public ActiveDirectorySchemaClass FindClass(string ldapDisplayName) { CheckIfDisposed(); return(ActiveDirectorySchemaClass.FindByName(context, ldapDisplayName)); }
public static ActiveDirectorySchemaClass FindByName(DirectoryContext context, string ldapDisplayName) { ActiveDirectorySchemaClass schemaClass = 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) { if (!(context.isRootDomain() || context.isServer() || context.isADAMConfigSet())) { 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 class schemaClass = new ActiveDirectorySchemaClass(context, ldapDisplayName, (DirectoryEntry)null, null); return schemaClass; }
// // This method searches in the schema container for all non-defunct classes of the // specified name (ldapDisplayName). // private ArrayList GetClasses(ICollection ldapDisplayNames) { ArrayList classes = new ArrayList(); SearchResultCollection resCol = null; try { if (ldapDisplayNames.Count < 1) { return classes; } if (_schemaEntry == null) { _schemaEntry = DirectoryEntryManager.GetDirectoryEntry(_context, WellKnownDN.SchemaNamingContext); } // constructing the filter StringBuilder str = new StringBuilder(100); if (ldapDisplayNames.Count > 1) { str.Append("(|"); } foreach (string ldapDisplayName in ldapDisplayNames) { str.Append("("); str.Append(PropertyManager.LdapDisplayName); str.Append("="); str.Append(Utils.GetEscapedFilterValue(ldapDisplayName)); str.Append(")"); } if (ldapDisplayNames.Count > 1) { str.Append(")"); } string filter = "(&(" + PropertyManager.ObjectCategory + "=classSchema)" + str.ToString() + "(!(" + PropertyManager.IsDefunct + "=TRUE)))"; string[] propertiesToLoad = new String[1]; propertiesToLoad[0] = PropertyManager.LdapDisplayName; ADSearcher searcher = new ADSearcher(_schemaEntry, filter, propertiesToLoad, SearchScope.OneLevel); resCol = searcher.FindAll(); foreach (SearchResult res in resCol) { string ldapDisplayName = (string)PropertyManager.GetSearchResultPropertyValue(res, PropertyManager.LdapDisplayName); DirectoryEntry de = res.GetDirectoryEntry(); de.AuthenticationType = Utils.DefaultAuthType; de.Username = _context.UserName; de.Password = _context.Password; ActiveDirectorySchemaClass schemaClass = new ActiveDirectorySchemaClass(_context, ldapDisplayName, de, _schemaEntry); classes.Add(schemaClass); } } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(_context, e); } finally { if (resCol != null) { resCol.Dispose(); } } return classes; }
public void CopyTo(ActiveDirectorySchemaClass[] classes, int index) { base.InnerList.CopyTo(classes, index); }
public void Remove(ActiveDirectorySchemaClass schemaClass) { if (schemaClass != null) { if (schemaClass.isBound) { int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySchemaClass item = (ActiveDirectorySchemaClass)base.InnerList[num]; if (Utils.Compare(item.Name, schemaClass.Name) != 0) { num++; } else { base.List.Remove(item); return; } } object[] objArray = new object[1]; objArray[0] = schemaClass; throw new ArgumentException(Res.GetString("NotFoundInCollection", objArray), "schemaClass"); } else { object[] name = new object[1]; name[0] = schemaClass.Name; throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", name)); } } else { throw new ArgumentNullException("schemaClass"); } }
public int IndexOf (ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException (); }
public bool Contains (ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException (); }
public int Add(ActiveDirectorySchemaClass schemaClass) { Contract.Requires(schemaClass != null); return(default(int)); }
public void Remove(ActiveDirectorySchemaClass schemaClass) { Contract.Requires(schemaClass != null); }
public void Save() { this.CheckIfDisposed(); if (!this.isBound) { try { if (this.schemaEntry == null) { this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext); } string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName); this.classEntry = this.schemaEntry.Children.Add(escapedPath, "classSchema"); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name })); } this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName); this.SetProperty(PropertyManager.GovernsID, this.oid); this.SetProperty(PropertyManager.Description, this.description); if (this.possibleSuperiors != null) { this.classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(this.possibleSuperiors.GetMultiValuedProperty()); } if (this.mandatoryProperties != null) { this.classEntry.Properties[PropertyManager.MustContain].AddRange(this.mandatoryProperties.GetMultiValuedProperty()); } if (this.optionalProperties != null) { this.classEntry.Properties[PropertyManager.MayContain].AddRange(this.optionalProperties.GetMultiValuedProperty()); } if (this.subClassOf != null) { this.SetProperty(PropertyManager.SubClassOf, this.subClassOf.Name); } else { this.SetProperty(PropertyManager.SubClassOf, "top"); } this.SetProperty(PropertyManager.ObjectClassCategory, this.type); if (this.schemaGuidBinaryForm != null) { this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm); } if (this.defaultSDSddlForm != null) { this.SetProperty(PropertyManager.DefaultSecurityDescriptor, this.defaultSDSddlForm); } } try { this.classEntry.CommitChanges(); if (this.schema == null) { ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(this.context); bool flag = false; DirectoryServer schemaRoleOwner = null; try { schemaRoleOwner = schema.SchemaRoleOwner; if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0) { DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context); this.schema = ActiveDirectorySchema.GetSchema(context); } else { flag = true; this.schema = schema; } } finally { if (schemaRoleOwner != null) { schemaRoleOwner.Dispose(); } if (!flag) { schema.Dispose(); } } } this.schema.RefreshSchema(); } catch (COMException exception2) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2); } this.isDefunctOnServer = this.isDefunct; this.commonName = null; this.oid = null; this.description = null; this.descriptionInitialized = false; this.possibleSuperiors = null; this.auxiliaryClasses = null; this.possibleInferiors = null; this.mandatoryProperties = null; this.optionalProperties = null; this.subClassOf = null; this.typeInitialized = false; this.schemaGuidBinaryForm = null; this.defaultSDSddlForm = null; this.defaultSDSddlFormInitialized = false; this.propertiesFromSchemaContainerInitialized = false; this.isBound = true; }
// // This method finds only among defunct classes // public ActiveDirectorySchemaClass FindDefunctClass(string commonName) { CheckIfDisposed(); if (commonName == null) { throw new ArgumentNullException("commonName"); } if (commonName.Length == 0) { throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "commonName"); } // this will bind to the schema container and load the properties of this class // (will also check whether or not the class exists) Hashtable propertiesFromServer = ActiveDirectorySchemaClass.GetPropertiesFromSchemaContainer(context, _schemaEntry, commonName, true /* isDefunctOnServer */); ActiveDirectorySchemaClass schemaClass = new ActiveDirectorySchemaClass(context, commonName, propertiesFromServer, _schemaEntry); return schemaClass; }
public void CopyTo(ActiveDirectorySchemaClass[] schemaClasses, int index) { base.List.CopyTo(schemaClasses, index); }
public void Insert (int index, ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException (); }
public void Insert(int index, ActiveDirectorySchemaClass schemaClass) { Contract.Requires(schemaClass != null); }
public void CopyTo (ActiveDirectorySchemaClass[] schemaClasses, int index) { throw new NotImplementedException (); }
public bool Contains(ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException(); }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException(); }
public int IndexOf(ActiveDirectorySchemaClass schemaClass) { if (schemaClass != null) { if (schemaClass.isBound) { int num = 0; while (num < base.InnerList.Count) { ActiveDirectorySchemaClass item = (ActiveDirectorySchemaClass)base.InnerList[num]; if (Utils.Compare(item.Name, schemaClass.Name) != 0) { num++; } else { return num; } } return -1; } else { object[] name = new object[1]; name[0] = schemaClass.Name; throw new InvalidOperationException(Res.GetString("SchemaObjectNotCommitted", name)); } } else { throw new ArgumentNullException("schemaClass"); } }
public static void CreateNewClass() { // specify a common name string newClassCommonName = "new-Class"; // specify an lDAPDisplayName string newClassLdapDisplayName = "newClass"; // specify an OID value. The root name was generated by oidgen.exe string newClassOid = "1.2.840.113556.1.5.7000.111.28688.28684.8.240397.1734810.1181742.544876.1"; string subClassOf = "top"; string possibleSuperior = "organizationalUnit"; // add an optional attribute to the new schema class object // This example adds the new attribute created in the CreateNewAttribute method string newClassOptionalAttribute = newAttributeLdapDisplayName; // create a new class object ActiveDirectorySchemaClass newClass = new ActiveDirectorySchemaClass( adamContext, newClassLdapDisplayName); // set the attribute values for this schema class object newClass.CommonName = newClassCommonName; newClass.Oid = newClassOid; newClass.Type = SchemaClassType.Structural; // assign the parent class newClass.SubClassOf = ActiveDirectorySchemaClass.FindByName(adamContext, subClassOf); // add the previously created attribute as an optional attribute newClass.OptionalProperties.Add( ActiveDirectorySchemaProperty.FindByName(adamContext, newClassOptionalAttribute)); //add an OU as a possible superior so that this class can be //instantiated in an OU newClass.PossibleSuperiors.Add( ActiveDirectorySchemaClass.FindByName(adamContext, possibleSuperior)); // save the new class to the schema try { newClass.Save(); } catch (ActiveDirectoryObjectExistsException e) { // an schema object by this name already exists in the schema Console.WriteLine("The schema object {0} was not created. {0}", newClassLdapDisplayName, e.Message); return; } catch (ActiveDirectoryOperationException e) { // a call to the underlying directory was rejected Console.WriteLine("The schema object {0} was not created. {0}", newClassLdapDisplayName, e.Message); return; } Console.WriteLine("Class \"{0}\" created successfully.", newClassLdapDisplayName); }
private ArrayList GetClasses(ICollection ldapDisplayNames) { ArrayList list = new ArrayList(); SearchResultCollection results = null; try { if (ldapDisplayNames.Count >= 1) { if (this.schemaEntry == null) { this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext); } StringBuilder builder = new StringBuilder(100); if (ldapDisplayNames.Count > 1) { builder.Append("(|"); } foreach (string str in ldapDisplayNames) { builder.Append("("); builder.Append(PropertyManager.LdapDisplayName); builder.Append("="); builder.Append(Utils.GetEscapedFilterValue(str)); builder.Append(")"); } if (ldapDisplayNames.Count > 1) { builder.Append(")"); } string filter = "(&(" + PropertyManager.ObjectCategory + "=classSchema)" + builder.ToString() + "(!(" + PropertyManager.IsDefunct + "=TRUE)))"; string[] propertiesToLoad = new string[] { PropertyManager.LdapDisplayName }; results = new ADSearcher(this.schemaEntry, filter, propertiesToLoad, SearchScope.OneLevel).FindAll(); foreach (SearchResult result in results) { string searchResultPropertyValue = (string) PropertyManager.GetSearchResultPropertyValue(result, PropertyManager.LdapDisplayName); DirectoryEntry directoryEntry = result.GetDirectoryEntry(); directoryEntry.AuthenticationType = Utils.DefaultAuthType; directoryEntry.Username = this.context.UserName; directoryEntry.Password = this.context.Password; ActiveDirectorySchemaClass class2 = new ActiveDirectorySchemaClass(this.context, searchResultPropertyValue, directoryEntry, this.schemaEntry); list.Add(class2); } } return list; } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } finally { if (results != null) { results.Dispose(); } } return list; }
public void Insert(int index, ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException(); }
private ArrayList GetPropertyValuesRecursively(string[] propertyNames) { ArrayList list = new ArrayList(); try { if (Utils.Compare(this.SubClassOf.Name, this.Name) != 0) { foreach (string str in this.SubClassOf.GetPropertyValuesRecursively(propertyNames)) { if (!list.Contains(str)) { list.Add(str); } } } foreach (string str2 in this.GetValuesFromCache(PropertyManager.AuxiliaryClass)) { ActiveDirectorySchemaClass class2 = new ActiveDirectorySchemaClass(this.context, str2, null, null); foreach (string str3 in class2.GetPropertyValuesRecursively(propertyNames)) { if (!list.Contains(str3)) { list.Add(str3); } } } foreach (string str4 in this.GetValuesFromCache(PropertyManager.SystemAuxiliaryClass)) { ActiveDirectorySchemaClass class3 = new ActiveDirectorySchemaClass(this.context, str4, null, null); foreach (string str5 in class3.GetPropertyValuesRecursively(propertyNames)) { if (!list.Contains(str5)) { list.Add(str5); } } } } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } foreach (string str6 in propertyNames) { foreach (string str7 in this.GetValuesFromCache(str6)) { if (!list.Contains(str7)) { list.Add(str7); } } } return list; }
public void Remove(ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException(); }
public void Save() { this.CheckIfDisposed(); if (!this.isBound) { try { if (this.schemaEntry == null) { this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, WellKnownDN.SchemaNamingContext); } string escapedPath = Utils.GetEscapedPath("CN=" + this.commonName); this.classEntry = this.schemaEntry.Children.Add(escapedPath, "classSchema"); } catch (COMException exception) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception); } catch (ActiveDirectoryObjectNotFoundException) { throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { this.context.Name })); } this.SetProperty(PropertyManager.LdapDisplayName, this.ldapDisplayName); this.SetProperty(PropertyManager.GovernsID, this.oid); this.SetProperty(PropertyManager.Description, this.description); if (this.possibleSuperiors != null) { this.classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(this.possibleSuperiors.GetMultiValuedProperty()); } if (this.mandatoryProperties != null) { this.classEntry.Properties[PropertyManager.MustContain].AddRange(this.mandatoryProperties.GetMultiValuedProperty()); } if (this.optionalProperties != null) { this.classEntry.Properties[PropertyManager.MayContain].AddRange(this.optionalProperties.GetMultiValuedProperty()); } if (this.subClassOf != null) { this.SetProperty(PropertyManager.SubClassOf, this.subClassOf.Name); } else { this.SetProperty(PropertyManager.SubClassOf, "top"); } this.SetProperty(PropertyManager.ObjectClassCategory, this.type); if (this.schemaGuidBinaryForm != null) { this.SetProperty(PropertyManager.SchemaIDGuid, this.schemaGuidBinaryForm); } if (this.defaultSDSddlForm != null) { this.SetProperty(PropertyManager.DefaultSecurityDescriptor, this.defaultSDSddlForm); } } try { this.classEntry.CommitChanges(); if (this.schema == null) { ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(this.context); bool flag = false; DirectoryServer schemaRoleOwner = null; try { schemaRoleOwner = schema.SchemaRoleOwner; if (Utils.Compare(schemaRoleOwner.Name, this.context.GetServerName()) != 0) { DirectoryContext context = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, this.context); this.schema = ActiveDirectorySchema.GetSchema(context); } else { flag = true; this.schema = schema; } } finally { if (schemaRoleOwner != null) { schemaRoleOwner.Dispose(); } if (!flag) { schema.Dispose(); } } } this.schema.RefreshSchema(); } catch (COMException exception2) { throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception2); } this.isDefunctOnServer = this.isDefunct; this.commonName = null; this.oid = null; this.description = null; this.descriptionInitialized = false; this.possibleSuperiors = null; this.auxiliaryClasses = null; this.possibleInferiors = null; this.mandatoryProperties = null; this.optionalProperties = null; this.subClassOf = null; this.typeInitialized = false; this.schemaGuidBinaryForm = null; this.defaultSDSddlForm = null; this.defaultSDSddlFormInitialized = false; this.propertiesFromSchemaContainerInitialized = false; this.isBound = true; }
private ArrayList GetPropertyValuesRecursively(string[] propertyNames) { ArrayList values = new ArrayList(); // get the properties of the super class try { if (Utils.Compare(SubClassOf.Name, Name) != 0) { foreach (string value in SubClassOf.GetPropertyValuesRecursively(propertyNames)) { if (!values.Contains(value)) { values.Add(value); } } } // get the properties of the auxiliary classes foreach (string auxSchemaClassName in GetValuesFromCache(PropertyManager.AuxiliaryClass)) { ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry)null, null); foreach (string property in auxSchemaClass.GetPropertyValuesRecursively(propertyNames)) { if (!values.Contains(property)) { values.Add(property); } } } foreach (string auxSchemaClassName in GetValuesFromCache(PropertyManager.SystemAuxiliaryClass)) { ActiveDirectorySchemaClass auxSchemaClass = new ActiveDirectorySchemaClass(_context, auxSchemaClassName, (DirectoryEntry)null, null); foreach (string property in auxSchemaClass.GetPropertyValuesRecursively(propertyNames)) { if (!values.Contains(property)) { values.Add(property); } } } } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(_context, e); } foreach (string propertyName in propertyNames) { foreach (string value in GetValuesFromCache(propertyName)) { if (!values.Contains(value)) { values.Add(value); } } } return values; }
public void AddRange (ActiveDirectorySchemaClass[] schemaClasses) { throw new NotImplementedException (); }
public void Save() { CheckIfDisposed(); if (!isBound) { try { // create a new directory entry for this class if (_schemaEntry == null) { _schemaEntry = DirectoryEntryManager.GetDirectoryEntry(_context, WellKnownDN.SchemaNamingContext); } // this will create the class and set the CN value string rdn = "CN=" + _commonName; rdn = Utils.GetEscapedPath(rdn); _classEntry = _schemaEntry.Children.Add(rdn, "classSchema"); } 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)); } // set the ldap display name property SetProperty(PropertyManager.LdapDisplayName, _ldapDisplayName); // set the oid value SetProperty(PropertyManager.GovernsID, _oid); // set the description SetProperty(PropertyManager.Description, _description); // set the possibleSuperiors property if (_possibleSuperiors != null) { _classEntry.Properties[PropertyManager.PossibleSuperiors].AddRange(_possibleSuperiors.GetMultiValuedProperty()); } // set the mandatoryProperties property if (_mandatoryProperties != null) { _classEntry.Properties[PropertyManager.MustContain].AddRange(_mandatoryProperties.GetMultiValuedProperty()); } // set the optionalProperties property if (_optionalProperties != null) { _classEntry.Properties[PropertyManager.MayContain].AddRange(_optionalProperties.GetMultiValuedProperty()); } // set the subClassOf property if (_subClassOf != null) { SetProperty(PropertyManager.SubClassOf, _subClassOf.Name); } else { // if no super class is specified, set it to "top" SetProperty(PropertyManager.SubClassOf, "top"); } // set the objectClassCategory property SetProperty(PropertyManager.ObjectClassCategory, _type); // set the schemaIDGuid property if (_schemaGuidBinaryForm != null) { SetProperty(PropertyManager.SchemaIDGuid, _schemaGuidBinaryForm); } // set the default security descriptor if (_defaultSDSddlForm != null) { SetProperty(PropertyManager.DefaultSecurityDescriptor, _defaultSDSddlForm); } } try { // commit the classEntry to server _classEntry.CommitChanges(); // Refresh the schema cache on the schema role owner if (_schema == null) { ActiveDirectorySchema schemaObject = ActiveDirectorySchema.GetSchema(_context); bool alreadyUsingSchemaRoleOwnerContext = false; DirectoryServer schemaRoleOwner = null; try { // // if we are not already talking to the schema role owner, change the context // schemaRoleOwner = schemaObject.SchemaRoleOwner; if (Utils.Compare(schemaRoleOwner.Name, _context.GetServerName()) != 0) { DirectoryContext schemaRoleOwnerContext = Utils.GetNewDirectoryContext(schemaRoleOwner.Name, DirectoryContextType.DirectoryServer, _context); _schema = ActiveDirectorySchema.GetSchema(schemaRoleOwnerContext); } else { alreadyUsingSchemaRoleOwnerContext = true; _schema = schemaObject; } } finally { if (schemaRoleOwner != null) { schemaRoleOwner.Dispose(); } if (!alreadyUsingSchemaRoleOwnerContext) { schemaObject.Dispose(); } } } _schema.RefreshSchema(); } catch (COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(_context, e); } // now that the changes are committed to the server // update the defunct/non-defunct status of the class on the server _isDefunctOnServer = _isDefunct; // invalidate all properties _commonName = null; _oid = null; _description = null; _descriptionInitialized = false; _possibleSuperiors = null; _auxiliaryClasses = null; _possibleInferiors = null; _mandatoryProperties = null; _optionalProperties = null; _subClassOf = null; _typeInitialized = false; _schemaGuidBinaryForm = null; _defaultSDSddlForm = null; _defaultSDSddlFormInitialized = false; _propertiesFromSchemaContainerInitialized = false; // set bind flag isBound = true; }
public void Remove (ActiveDirectorySchemaClass schemaClass) { throw new NotImplementedException (); }
public bool Contains(ActiveDirectorySchemaClass schemaClass) { Contract.Requires(schemaClass != null); return(default(bool)); }
public void AddRange(ActiveDirectorySchemaClass[] schemaClasses) { if (schemaClasses != null) { ActiveDirectorySchemaClass[] activeDirectorySchemaClassArray = schemaClasses; int num = 0; while (num < (int)activeDirectorySchemaClassArray.Length) { ActiveDirectorySchemaClass activeDirectorySchemaClass = activeDirectorySchemaClassArray[num]; if (activeDirectorySchemaClass != null) { num++; } else { throw new ArgumentException("schemaClasses"); } } for (int i = 0; i < (int)schemaClasses.Length; i++) { this.Add(schemaClasses[i]); } return; } else { throw new ArgumentNullException("schemaClasses"); } }