IAdmUsernameDomainSelectionOptions

The IAdmUsernameDomainSelectionOptions interface represents the domain suffix selection restrictions for a particular domain.

Inheritance: IUnknown

Properties

  • Property

  • Description

  • Mode

  • Gets or sets the mode in which the restriction operates.

  • SpecificDomains

  • Gets or sets a list of domains that must be shown or hidden.

  • DefaultDomain

  • Gets or sets the domain to select by default.

Details

Mode

Gets or sets the mode in which the restriction operates.


SpecificDomains

Gets or sets a list of domains that must be shown or hidden, depending on the specified mode.

  • Type:
  • string[]
  • Access:
  • Read/Write

Remarks

This property should be specified only if Mode is set to ShowSpecific or HideSpecific.


Examples

The following code sample sets suffix restrictions for the example.com domain. Two suffixes are hidden and a specific suffix is marked as deafult.

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

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

# Build the ADS path of the User property pattern and bind to it.
$containerPath = $service.Backend.GetConfigurationContainerPath("PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $containerPath
$builtinPathObj = $propertyPatternsPathObj.CreateChildPath("CN=Builtin")
$userPatternPath = $builtinPathObj.CreateChildPath("CN=User")

$pattern = $service.OpenObject($userPatternPath.ToString(), $null, $null, 0)

# Get the item for the Username property.
foreach ($item in $pattern.Items)
{
    if ($item.PropertyName -ieq "userPrincipalName")
    {
        # Create suffix restrictions for domain.
        $domainRestriction = 
            New-Object Softerra.Adaxes.Adsi.PropertyPatterns.UsernameDomainSelectionOptions
        $domainRestriction.Mode = "HideSpecific"
        $domainRestriction.SpecificDomains = @("example1.com", "example.onmicrosoft.com")
        $domainRestriction.DefaultDomain = "example.com"

        # Set restrictions.
        $domainOptions = New-Object Softerra.Adaxes.Adsi.Utils.AdmKeyValuePair
        $domainOptions.Key = "example.com"
        $domainOptions.Value = $domainRestriction
        $item.DomainOptions += $domainOptions

        $item.SetInfo()
    }
}
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi.PropertyPatterns;
class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Build the ADS path of the User property pattern and bind to it.
        string containerPath = service.Backend.GetConfigurationContainerPath("PropertyPatterns");
        AdsPath propertyPatternsPathObj = new AdsPath(containerPath);
        AdsPath builtinPathObj = propertyPatternsPathObj.CreateChildPath("CN=Builtin");
        AdsPath userPatternPath = builtinPathObj.CreateChildPath("CN=User");

        IAdmPropertyPattern pattern = (IAdmPropertyPattern)service.OpenObject(
            userPatternPath.ToString(), null, null, 0);

        // Get the item for the Username property.
        foreach (IAdmPropertyPatternItem item in pattern.Items)
        {
            if (StringComparer.OrdinalIgnoreCase.Equals("userPrincipalName", item.PropertyName))
            {
                IAdmUsernamePropertyPatternItem usernameItem = (IAdmUsernamePropertyPatternItem)item;

                // Create suffix restrictions for the domain.
                IAdmUsernameDomainSelectionOptions domainRestriction = 
                new UsernameDomainSelectionOptions
                {
                    Mode = UsernameDomainSelectionMode.HideSpecific,
                    SpecificDomains = new[] { "example1.com", "example.onmicrosoft.com" },
                    DefaultDomain = "example.com"
                };

                // Set restrictions.
                IAdmKeyValuePair domainOptions = new AdmKeyValuePair
                {
                    Key = "example.com",
                    Value = domainRestriction
                };
                usernameItem.DomainOptions = new [] { domainOptions };

                usernameItem.SetInfo();
            }
        }
    }
}

DefaultDomain

Gets or sets the domain to select by default.

  • Type:
  • string
  • Access:
  • Read/Write

Requirements

Minimum required version: 2023

See also