Resolved #118: Support for ntds.dit files with conflicting defunct attributes.

This commit is contained in:
Michael Grafnetter 2021-10-08 18:14:02 +02:00
parent b33d915110
commit 677b76bb81
1 changed files with 10 additions and 23 deletions

View File

@ -7,6 +7,7 @@
using Microsoft.Isam.Esent.Interop;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
/// <summary>
@ -25,7 +26,6 @@
private IDictionary<string, SchemaAttribute> attributesByName;
private IDictionary<string, int> classesByName;
// TODO: Internal?
// TODO: ISchema
public DirectorySchema(IsamDatabase database)
{
@ -41,17 +41,6 @@
// TODO: Load Ext-Int Map from hiddentable
}
/// <summary>
/// Gets the partition name.
/// </summary>
public string Name
{
get
{
throw new NotImplementedException();
}
}
/// <summary>
/// Gets the OID prefix map.
/// </summary>
@ -112,15 +101,6 @@
return this.FindAttribute(attributeName).Index;
}
/// <summary>
/// Refreshes the schema cache.
/// </summary>
public void RefreshSchema()
{
throw new NotImplementedException();
}
// TODO: Rename to CategoryDNT
public int FindClassId(string className)
{
@ -229,6 +209,7 @@
// Some built-in attributes do not have internal id set, which means it is equal to the public id
int id = internalId ?? attributeId;
SchemaAttribute attribute;
bool found = this.attributesByInternalId.TryGetValue(id, out attribute);
if (! found)
{
@ -236,6 +217,7 @@
attribute = new SchemaAttribute();
attribute.InternalId = internalId;
}
attribute.Id = dataTableCursor.RetrieveColumnAsInt(attributeIdCol).Value;
attribute.Name = dataTableCursor.RetrieveColumnAsString(ldapDisplayNameCol);
attribute.CommonName = dataTableCursor.RetrieveColumnAsString(cnCol);
@ -251,8 +233,13 @@
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);
// Only index non-defunct attributes by name. A name conflict could arise otherwise.
if(!attribute.IsDefunct)
{
// Make the attribute name lookup case-insensitive by always lowercasing the name:
this.attributesByName.Add(attribute.Name.ToLower(CultureInfo.InvariantCulture), attribute);
}
}
}