private void LoadClassList(Cursor dataTableCursor) { // Initialize the class list this.classesByName = new Dictionary<string, int>(); // Load column IDs Columnid ldapDisplayNameCol = this.FindColumnId(CommonDirectoryAttributes.LDAPDisplayName); Columnid dntCol = this.FindColumnId(CommonDirectoryAttributes.DNTag); // Search for all classes dataTableCursor.CurrentIndex = this.FindIndexName(CommonDirectoryAttributes.ObjectClass); dataTableCursor.FindRecords(MatchCriteria.EqualTo, Key.Compose(CommonDirectoryClasses.ClassSchemaId)); while (dataTableCursor.MoveNext()) { // TODO: Load more data about classes int classId = dataTableCursor.RetrieveColumnAsDNTag(dntCol).Value; string className = dataTableCursor.RetrieveColumnAsString(ldapDisplayNameCol); classesByName.Add(className, classId); } }
private void LoadAttributeProperties(Cursor dataTableCursor) { // With these built-in attributes, ID == Internal ID Columnid attributeIdCol = this.attributesByInternalId[CommonDirectoryAttributes.AttributeIdId].ColumnID; SchemaAttribute ldapDisplayNameAtt = this.attributesByInternalId[CommonDirectoryAttributes.LdapDisplayNameId]; Columnid ldapDisplayNameCol = ldapDisplayNameAtt.ColumnID; // Set index to ldapDisplayName so that we can find attributes by their name dataTableCursor.CurrentIndex = ldapDisplayNameAtt.Index; // Load attribute ids of attributeSchema attributes by doing DB lookups // TODO: Hardcode IDs of these attributes so that we do not have to do DB lookups? Columnid internalIdCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.InternalId); Columnid linkIdCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.LinkId); Columnid isSingleValuedCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.IsSingleValued); Columnid attributeSyntaxCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.AttributeSyntax); Columnid isInGlobalCatalogCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.IsInGlobalCatalog); Columnid searchFlagsCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.SearchFlags); Columnid systemOnlyCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.SystemOnly); Columnid syntaxCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.AttributeSyntax); Columnid omSyntaxCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.AttributeOmSyntax); Columnid cnCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.CommonName); Columnid rangeLowerCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.RangeLower); Columnid rangeUpperCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.RangeUpper); Columnid schemaGuidCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.SchemaGuid); Columnid systemFlagsCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.SystemFlags); Columnid isDefunctCol = this.LoadColumnIdByAttributeName(dataTableCursor, CommonDirectoryAttributes.IsDefunct); // Now traverse through all schema attributes and load their properties dataTableCursor.CurrentIndex = this.attributesByInternalId[CommonDirectoryAttributes.ObjectClassId].Index; dataTableCursor.FindRecords(MatchCriteria.EqualTo, Key.Compose(CommonDirectoryClasses.AttributeSchemaId)); while (dataTableCursor.MoveNext()) { int? internalId = dataTableCursor.RetrieveColumnAsInt(internalIdCol); int attributeId = dataTableCursor.RetrieveColumnAsInt(attributeIdCol).Value; // Some built-in attributes do not have internal id set, which meand it is equal to the public id int id = internalId ?? attributeId; SchemaAttribute attribute; bool found = this.attributesByInternalId.TryGetValue(id, out attribute); if (! found) { // Load info about a new attribute attribute = new SchemaAttribute(); attribute.InternalId = internalId; } attribute.Id = dataTableCursor.RetrieveColumnAsInt(attributeIdCol).Value; attribute.Name = dataTableCursor.RetrieveColumnAsString(ldapDisplayNameCol); attribute.CommonName = dataTableCursor.RetrieveColumnAsString(cnCol); attribute.RangeLower = dataTableCursor.RetrieveColumnAsInt(rangeLowerCol); attribute.RangeUpper = dataTableCursor.RetrieveColumnAsInt(rangeUpperCol); attribute.SchemaGuid = dataTableCursor.RetrieveColumnAsGuid(schemaGuidCol).Value; attribute.IsDefunct = dataTableCursor.RetrieveColumnAsBoolean(isDefunctCol); attribute.SystemFlags = dataTableCursor.RetrieveColumnAsAttributeSystemFlags(systemFlagsCol); attribute.LinkId = dataTableCursor.RetrieveColumnAsInt(linkIdCol); attribute.IsInGlobalCatalog = dataTableCursor.RetrieveColumnAsBoolean(isInGlobalCatalogCol); attribute.IsSingleValued = dataTableCursor.RetrieveColumnAsBoolean(isSingleValuedCol); attribute.SearchFlags = dataTableCursor.RetrieveColumnAsSearchFlags(searchFlagsCol); attribute.IsSystemOnly = dataTableCursor.RetrieveColumnAsBoolean(systemOnlyCol); attribute.Syntax = dataTableCursor.RetrieveColumnAsAttributeSyntax(syntaxCol); attribute.OmSyntax = dataTableCursor.RetrieveColumnAsAttributeOmSyntax(omSyntaxCol); // Make it case-insensitive by always lowering the name: this.attributesByName.Add(attribute.Name.ToLower(), attribute); } }