Class LdapAttribute
The name and values of one attribute of a directory entry. LdapAttribute objects are used when searching for, adding, modifying, and deleting attributes from the directory. LdapAttributes are often used in conjunction with an LdapAttributeSet when retrieving or adding multiple attributes to an entry.
Inherited Members
Namespace: Swan.Ldap
Syntax
public class LdapAttribute
Constructors
LdapAttribute(String)
Initializes a new instance of the LdapAttribute class. Constructs an attribute with no values.
Declaration
public LdapAttribute(string attrName)
Parameters
Type | Name | Description |
---|---|---|
String | attrName | Name of the attribute. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute name cannot be null. |
LdapAttribute(String, String)
Initializes a new instance of the LdapAttribute class. Constructs an attribute with a single String value.
Declaration
public LdapAttribute(string attrName, string attrString)
Parameters
Type | Name | Description |
---|---|---|
String | attrName | Name of the attribute. |
String | attrString | Value of the attribute as a string. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute value cannot be null. |
Properties
ByteValue
Returns the first value of the attribute as a byte array or null.
Declaration
public sbyte[] ByteValue { get; }
Property Value
Type | Description |
---|---|
SByte[] | The byte value. |
ByteValueArray
Returns the values of the attribute as an array of bytes.
Declaration
public sbyte[][] ByteValueArray { get; }
Property Value
Type | Description |
---|---|
SByte[][] | The byte value array. |
LangSubtype
Returns the language subtype of the attribute, if any. For example, if the attribute name is cn;lang-ja;phonetic, this method returns the string, lang-ja.
Declaration
public string LangSubtype { get; }
Property Value
Type | Description |
---|---|
String | The language subtype. |
Name
Returns the name of the attribute.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String | The name. |
StringValue
Returns the the first value of the attribute as an UTF-8 string.
Declaration
public string StringValue { get; }
Property Value
Type | Description |
---|---|
String | The string value. |
StringValueArray
Returns the values of the attribute as an array of strings.
Declaration
public string[] StringValueArray { get; }
Property Value
Type | Description |
---|---|
String[] | The string value array. |
Methods
AddBase64Value(Char[])
Adds a base64 encoded value to the attribute. The value will be decoded and stored as bytes. Character data encoded as a base64 value must be UTF-8 characters.
Declaration
public void AddBase64Value(char[] attrChars)
Parameters
Type | Name | Description |
---|---|---|
Char[] | attrChars | The base64 value of the attribute as an array of characters. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | attrChars. |
AddBase64Value(String)
Adds a base64 encoded value to the attribute. The value will be decoded and stored as bytes. String data encoded as a base64 value must be UTF-8 characters.
Declaration
public void AddBase64Value(string attrString)
Parameters
Type | Name | Description |
---|---|---|
String | attrString | The base64 value of the attribute as a String. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute value cannot be null. |
AddBase64Value(StringBuilder, Int32, Int32)
Adds a base64 encoded value to the attribute. The value will be decoded and stored as bytes. Character data encoded as a base64 value must be UTF-8 characters.
Declaration
public void AddBase64Value(StringBuilder attrString, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | attrString | The base64 value of the attribute as a StringBuffer. |
Int32 | start | The start index of base64 encoded part, inclusive. |
Int32 | end | The end index of base encoded part, exclusive. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | attrString. |
AddValue(SByte[])
Adds a byte-formatted value to the attribute.
Declaration
public void AddValue(sbyte[] attrBytes)
Parameters
Type | Name | Description |
---|---|---|
SByte[] | attrBytes | Value of the attribute as raw bytes. Note: If attrBytes represents a string it should be UTF-8 encoded. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute value cannot be null. |
AddValue(String)
Adds a String value to the attribute.
Declaration
public void AddValue(string attrString)
Parameters
Type | Name | Description |
---|---|---|
String | attrString | Value of the attribute as a String. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute value cannot be null. |
Clone()
Clones this instance.
Declaration
public LdapAttribute Clone()
Returns
Type | Description |
---|---|
LdapAttribute | A cloned instance. |
CompareTo(Object)
Compares this object with the specified object for order. Ordering is determined by comparing attribute names using the method Compare() of the String class.
Declaration
public int CompareTo(object attribute)
Parameters
Type | Name | Description |
---|---|---|
Object | attribute | The LdapAttribute to be compared to this object. |
Returns
Type | Description |
---|---|
Int32 | Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. |
GetBaseName()
Returns the base name of the attribute. For example, if the attribute name is cn;lang-ja;phonetic, this method returns cn.
Declaration
public string GetBaseName()
Returns
Type | Description |
---|---|
String | The base name of the attribute. |
GetBaseName(String)
Returns the base name of the specified attribute name. For example, if the attribute name is cn;lang-ja;phonetic, this method returns cn.
Declaration
public static string GetBaseName(string attrName)
Parameters
Type | Name | Description |
---|---|---|
String | attrName | Name of the attribute from which to extract the base name. |
Returns
Type | Description |
---|---|
String | The base name of the attribute. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute name cannot be null. |
GetSubtypes()
Extracts the subtypes from the attribute name. For example, if the attribute name is cn;lang-ja;phonetic, this method returns an array containing lang-ja and phonetic.
Declaration
public string[] GetSubtypes()
Returns
Type | Description |
---|---|
String[] | An array subtypes or null if the attribute has none. |
GetSubtypes(String)
Extracts the subtypes from the specified attribute name. For example, if the attribute name is cn;lang-ja;phonetic, this method returns an array containing lang-ja and phonetic.
Declaration
public static string[] GetSubtypes(string attrName)
Parameters
Type | Name | Description |
---|---|---|
String | attrName | Name of the attribute from which to extract the subtypes. |
Returns
Type | Description |
---|---|
String[] | An array subtypes or null if the attribute has none. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Attribute name cannot be null. |
HasSubtype(String)
Reports if the attribute name contains the specified subtype. For example, if you check for the subtype lang-en and the attribute name is cn;lang-en, this method returns true.
Declaration
public bool HasSubtype(string subtype)
Parameters
Type | Name | Description |
---|---|---|
String | subtype | The single subtype to check for. |
Returns
Type | Description |
---|---|
Boolean | True, if the attribute has the specified subtype; false, if it doesn't. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | subtype. |
HasSubtypes(String[])
Reports if the attribute name contains all the specified subtypes. For example, if you check for the subtypes lang-en and phonetic and if the attribute name is cn;lang-en;phonetic, this method returns true. If the attribute name is cn;phonetic or cn;lang-en, this method returns false.
Declaration
public bool HasSubtypes(string[] subtypes)
Parameters
Type | Name | Description |
---|---|---|
String[] | subtypes | An array of subtypes to check for. |
Returns
Type | Description |
---|---|
Boolean | True, if the attribute has all the specified subtypes; false, if it doesn't have all the subtypes. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | subtypes. |
ArgumentException | subtype at array index {i}. |
RemoveValue(SByte[])
Removes a byte-formatted value from the attribute.
Declaration
public void RemoveValue(sbyte[] attrBytes)
Parameters
Type | Name | Description |
---|---|---|
SByte[] | attrBytes | Value of the attribute as raw bytes. Note: If attrBytes represents a string it should be UTF-8 encoded. Note: Removing a value which is not present in the attribute has no effect. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | attrBytes. |
RemoveValue(String)
Removes a string value from the attribute.
Declaration
public void RemoveValue(string attrString)
Parameters
Type | Name | Description |
---|---|---|
String | attrString | Value of the attribute as a string. Note: Removing a value which is not present in the attribute has no effect. |
Size()
Returns the number of values in the attribute.
Declaration
public int Size()
Returns
Type | Description |
---|---|
Int32 | The number of values in the attribute. |
ToString()
Returns a string representation of this LdapAttribute.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | a string representation of this LdapAttribute. |
Overrides
Exceptions
Type | Condition |
---|---|
Exception | NullReferenceException. |