Skip to content

IADsPropertyValue2

The IADsPropertyValue2 interface is used to represent a value of an IADsPropertyEntry object in a predefined data type.

The IADsPropertyEntry::Values property contains an array of IADsPropertyValue2 objects. Each of the objects contains a single value of the IADsPropertyEntry2 object. For more information and a code example on creating entirely new property entries and values, see IADsPropertyList::PutPropertyItem.

Before calling the methods of this interface, call IADs::GetInfo or IADs::GetInfoEx explicitly to load the assigned values of the object into the cache, if the cache was not initialized. After modifying the properties of this interface, call IADs::SetInfo to save the changes to the directory.

This interface is more versatile than IADsPropertyValue because this interface can be used to obtain any data type. The IADsPropertyValue interface can only be used to obtain a limited number of data types.

Inheritance: The IADsPropertyValue2 interface inherits from the IDispatch interface.

Methods

Details

GetObjectProperty()

Retrieves the value of a property.

Object GetObjectProperty(ADSTYPEENUM type)

Parameters

The type parameter contains one of the ADSTYPEENUM values that specifies the data format that the value should be returned in.

Remarks

If the data type is not known, set this to ADSTYPE_UNKNOWN. In this case, this method will obtain the attribute value in the default data type and set this variable to the corresponding value. If any other value is specified, Adaxes will return the attribute value only if the data type matches the format of the value.

Examples

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to object
$domainPath = "Adaxes://DC=domain,DC=com"
$domain = $admService.OpenObject($domainPath, $NULL, $NULL, 0)
$domain.GetInfo()

$propertyEntry = $domain.GetPropertyItem("description", "ADSTYPE_CASE_IGNORE_STRING")

foreach ($propertyValue in $propertyEntry.Values)
{
    $description = $propertyValue.GetObjectProperty([ref]"ADSTYPE_CASE_IGNORE_STRING")
    Write-Host "Description: $description"
}
using System;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Cache;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to object
        const string domainPath = "Adaxes://DC=domain,DC=com";
        IADs domain = (IADs)admService.OpenObject(domainPath, null, null, 0);
        domain.GetInfo();

        IADsPropertyList propertyList = (IADsPropertyList)domain;

        IADsPropertyEntry propertyEntry =
            (IADsPropertyEntry)propertyList.GetPropertyItem("description",
            ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING);

        foreach (IADsPropertyValue2 propertyValue in (Array)propertyEntry.Values)
        {
            string description = (string)propertyValue.GetObjectProperty(
                ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING);
            Console.WriteLine("Description: {0}", description);
        }
    }
}

PutObjectProperty()

Sets the value of a property.

void PutObjectProperty(ADSTYPEENUM type, Object value)

Parameters

  • type - Contains one of the ADSTYPEENUM values that specifies the data format of the value to be set.
  • value - Contains the new attribute value.

Examples

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to object
$userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $admService.OpenObject($userPath, $NULL, $NULL, 0)
$user.GetInfo()

# Create a property value
$propertyValue = New-Object "Softerra.Adaxes.Adsi.AdsPropertyValue"
$propertyValue.PutObjectProperty("ADSTYPE_CASE_IGNORE_STRING", "My Description")

# Create a property entry
$propertyEntry = New-Object "Softerra.Adaxes.Adsi.AdsPropertyEntry"
$propertyEntry.Name = "description"
$propertyEntry.Values =
    @([Softerra.Adaxes.Interop.Adsi.Cache.IADsPropertyValue]$propertyValue)
$propertyEntry.ControlCode = "ADS_PROPERTY_UPDATE"
$propertyEntry.ADsType = "ADSTYPE_CASE_IGNORE_STRING"

# Add the property entry to the property list
$user.PutPropertyItem($propertyEntry)

# Commit changes to the directory store
$user.SetInfo()
using System;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Cache;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to object
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IADs user = (IADs)admService.OpenObject(userPath, null, null, 0);
        user.GetInfo();

        IADsPropertyList propertyList = (IADsPropertyList)user;

        // Create a property value
        IADsPropertyValue2 propertyValue = new AdsPropertyValue();
        propertyValue.PutObjectProperty(
            ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING, "My Description");

        // Create a property entry
        IADsPropertyEntry propertyEntry = new AdsPropertyEntry();
        propertyEntry.Name = "description";
        Object[] values = { propertyValue };
        propertyEntry.Values = values;
        propertyEntry.ControlCode = ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_UPDATE;
        propertyEntry.ADsType = ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;

        // Add the property entry to the property list
        propertyList.PutPropertyItem(propertyEntry);

        // Commit changes to the directory store
        user = (IADs)propertyList;
        user.SetInfo();

    }
}

Requirements

Minimum required version: 2009.1

See also