mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-01-05 21:49:47 +00:00
Minor code cleanup
This commit is contained in:
parent
421a33e102
commit
2251526bfa
@ -1,6 +1,9 @@
|
||||
|
||||
namespace DSInternals.Common.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the CRC32 algorithm, as used by AD replication.
|
||||
/// </summary>
|
||||
public static class Crc32
|
||||
{
|
||||
private static readonly uint[] crcTable = new uint[] {
|
||||
@ -76,7 +79,7 @@ namespace DSInternals.Common.Cryptography
|
||||
uint crc = uint.MaxValue;
|
||||
for(int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
crc = crcTable[(crc ^ buffer[i]) & 0xFF] ^ (crc >> 8);
|
||||
crc = crcTable[(crc ^ buffer[i]) & byte.MaxValue] ^ (crc >> 8 );
|
||||
}
|
||||
return crc ^ uint.MaxValue;
|
||||
}
|
||||
|
@ -59,6 +59,7 @@
|
||||
public const string OrganizationalUnitName = "ou";
|
||||
public const string ParentDNTag = "PDNT";
|
||||
public const string PEKList = "pekList";
|
||||
public const string PEKChangeInterval = "pekKeyChangeInterval";
|
||||
public const string PrimaryGroupId = "primaryGroupID";
|
||||
public const int PrimaryGroupIdId = 589922;
|
||||
public const string PropertyMetaData = "replPropertyMetaData";
|
||||
|
@ -12,6 +12,10 @@ namespace DSInternals.DataStore
|
||||
private const string linkDNCol = "link_DNT";
|
||||
private const string backlinkDNCol = "backlink_DNT";
|
||||
private const string linkBaseCol = "link_base";
|
||||
private const string linkDataCol = "link_data";
|
||||
private const string linkMetadataCol = "link_metadata";
|
||||
private const string linkDeletedTimeCol = "link_deltime";
|
||||
private const string linkDeactivatedTimeCol = "link_deactivetime";
|
||||
private const string linkIndex = "link_present_active_index";
|
||||
|
||||
private Cursor cursor;
|
||||
@ -27,29 +31,25 @@ namespace DSInternals.DataStore
|
||||
|
||||
public int? GetLinkedDNTag(int dnTag, string attributeName)
|
||||
{
|
||||
int[] result = this.GetLinkedDNTags(dnTag, attributeName);
|
||||
switch(result.Length)
|
||||
try
|
||||
{
|
||||
case 0:
|
||||
return null;
|
||||
case 1:
|
||||
return result[0];
|
||||
default:
|
||||
// TODO: Make this a special exception type. Move message to resources.
|
||||
throw new Exception("More than 1 objects have been found.");
|
||||
return this.GetLinkedDNTags(dnTag, attributeName).SingleOrDefault();
|
||||
}
|
||||
catch(InvalidOperationException)
|
||||
{
|
||||
// TODO: Make this a special exception type. Move message to resources.
|
||||
throw new Exception("More than 1 objects have been found.");
|
||||
}
|
||||
}
|
||||
|
||||
public int[] GetLinkedDNTags(int dnTag, string attributeName)
|
||||
public IEnumerable<int> GetLinkedDNTags(int dnTag, string attributeName)
|
||||
{
|
||||
var result = new List<int>();
|
||||
SchemaAttribute attr = this.schema.FindAttribute(attributeName);
|
||||
if(!attr.LinkId.HasValue)
|
||||
{
|
||||
// This is not a linked multivalue attribute.
|
||||
//TODO: Throw a proper exception
|
||||
throw new Exception();
|
||||
|
||||
// TODO: Check that attribute type is DN
|
||||
throw new Exception("This is not a linked multivalue attribute.");
|
||||
}
|
||||
int linkId = attr.LinkId.Value;
|
||||
// Remove the rightmost bit that indicates if this is a forward link or a backlink.
|
||||
@ -62,9 +62,14 @@ namespace DSInternals.DataStore
|
||||
{
|
||||
// TODO: Not deactivated?
|
||||
int foundTag = (int)cursor.IndexRecord[backlinkDNCol];
|
||||
result.Add(foundTag);
|
||||
yield return foundTag;
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public IEnumerable<byte[]> GetDNBinaryValues(int dnTag, string attributeName)
|
||||
{
|
||||
// TODO: Implement DN-Binary attribute value retrieval from linktable.
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
Loading…
Reference in New Issue
Block a user