namespace DSInternals.DataStore
{
using System;
using Microsoft.Database.Isam;
using DSInternals.Common.Data;
///
/// The ActiveDirectorySchemaAttribute class represents a schema property definition that is contained in the schema partition.
///
//TODO: Rename Attribute to ActiveDirectorySchemaAttribute
public class SchemaAttribute : ISchemaAttributeExt
{
///
/// Gets the ldapDisplayName of the ActiveDirectorySchemaAttribute object.
///
public string Name
{
get;
internal set;
}
///
/// Gets or sets the Common Name (CN) of the ActiveDirectorySchemaProperty object.
///
public string CommonName
{
get;
internal set;
}
// Contains compressed OID
public int? Id
{
get;
internal set;
}
// Corresponds to column name suffix
public int? InternalId
{
get;
internal set;
}
public string Oid
{
get;
internal set;
}
public string ColumnName
{
get;
internal set;
}
public Columnid ColumnID
{
get;
internal set;
}
public string Index
{
get;
internal set;
}
///
/// Gets or sets the value for the link identifier when the schema property is linked.
///
/// An even integer denotes a forward link; an odd integer denotes a back link.
public int? LinkId
{
get;
internal set;
}
///
/// Gets or sets flags that define additional properties of the attribute.
///
public AttributeSystemFlags SystemFlags
{
get;
internal set;
}
public LinkType? LinkType
{
get
{
if(!this.LinkId.HasValue)
{
return null;
}
if(this.LinkId.Value % 2 == 0)
{
return DataStore.LinkType.ForwardLink;
}
else
{
return DataStore.LinkType.BackLink;
}
}
}
public int? LinkBase
{
get
{
if (!this.LinkId.HasValue)
{
// This attribute is not a linked value.
return null;
}
// Remove the rightmost bit that indicates if this is a forward link or a backlink.
return this.LinkId.Value >> 1;
}
}
///
/// Gets or sets a value that represents the minimum value or length that the schema property can have.
///
public int? RangeLower
{
get;
internal set;
}
///
/// Gets or sets a value that represents the maximum value or length that the schema property can have.
///
public int? RangeUpper
{
get;
internal set;
}
///
/// Gets a value indicating whether the schema property is indexed in the Active Directory Domain Services store.
///
public bool IsIndexed
{
get
{
return this.SearchFlags.HasFlag(SearchFlags.AttributeIndex);
}
}
public bool IsDefunct
{
get;
internal set;
}
///
/// Gets or sets a value indicating whether the schema property is contained in the global catalog.
///
public bool IsInGlobalCatalog
{
get;
internal set;
}
///
/// Gets or sets a value indicating whether the schema property is single-valued.
///
public bool IsSingleValued
{
get;
internal set;
}
///
/// This attribute specifies whether an attribute is indexed, among other things.
///
public SearchFlags SearchFlags
{
get;
internal set;
}
///
/// Gets a value indicating whether there is a tuple index for this schema property.
///
public bool IsTupleIndexed
{
get
{
return this.SearchFlags.HasFlag(SearchFlags.TupleIndex);
}
}
///
/// Gets a value indicating whether the schema property is in the ANR set.
///
public bool IsInAnr
{
get
{
return this.SearchFlags.HasFlag(SearchFlags.AmbiguousNameResolution);
}
}
///
/// Gets a value indicating whether the schema property is indexed in all containers.
///
public bool IsIndexedOverContainer
{
get
{
return this.SearchFlags.HasFlag(SearchFlags.ContainerIndex);
}
}
///
/// Gets a value indicating whether the schema property is in the tombstone object that contains deleted properties.
///
public bool IsOnTombstonedObject
{
get
{
return this.SearchFlags.HasFlag(SearchFlags.PreserveOnDelete);
}
}
///
/// Gets a value indicating whether only the system can modify this attribute.
///
public bool IsSystemOnly
{
get;
internal set;
}
public bool IsConstructed
{
get
{
return this.SystemFlags.HasFlag(AttributeSystemFlags.Constructed);
}
}
///
/// Gets or sets an ActiveDirectorySyntax object indicating the property type (syntax) of the Attribute object.
///
public AttributeSyntax Syntax
{
get;
internal set;
}
///
/// Gets or sets the schemaIDGuid for the ActiveDirectorySchemaProperty object.
///
public Guid SchemaGuid
{
get;
internal set;
}
///
/// Gets the OID of the attribute syntax.
///
public string SyntaxOid
{
get
{
return PrefixMap.GetAttributeSyntaxOid(this.Syntax);
}
}
public AttributeOmSyntax OmSyntax
{
get;
internal set;
}
public override string ToString()
{
return String.Format("Att: {0}, Col: {1}", Name, ColumnName);
}
}
}