Skip to content

IAdmRoleAssignment

The IAdmRoleAssignment interface represents a Security Role assignment.

Inheritance: The IAdmRoleAssignment interface inherits from the IAdmTop interface.

Properties

  • Property

  • Description

  • ActivityScopeItems

  • Gets a collection of scope items that determine the scope, within which the trustee will be able to apply the permissions of the Security Role.

  • Trustee

  • Gets or sets the user or group the Security Role is assigned to.

  • TrusteeDomain

  • Gets or sets the name of the domain that the trustee belongs to.

Details

ActivityScopeItems

Gets a collection of scope items that determine the scope, within which the trustee will be able to apply the permissions of the Security Role. Each scope item is represented by the IAdmActivityScopeItem interface.


Trustee

Gets or sets the user or group the Security Role is assigned to.

  • Type:
  • String
  • Access:
  • Read/Write

Remarks

The property must be set to a string that contains either the trustee’s SID in the SDDL format (e.g. S-1-5-1-123-456-789), or the user’s logon name (e.g. DOMAIN\username, username@domain.com), or the group name (pre-Windows 2000).

Examples

The following code sample assigns a Security Role to a user including All Objects in the Assignment Scope.

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

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"

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

# Bind to the Security Role
$securityRolesPath = $admService.Backend.GetConfigurationContainerPath(`
  "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
  $securityRolesPath
$myRoleAdsPath = $securityRolesPathObj.CreateChildPath(`
  "CN=My Role")

$role = $admService.OpenObject($myRoleAdsPath, $NULL, $NULL, 0)

# Assign the Security Role to the user

# Bind to the user
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Get the user's SID in the SDDL form
$userSid = New-Object "Softerra.Adaxes.Adsi.Sid" @($user.Get("ObjectSid"), 0)
$sidSddlForm = $userSid.Value

$assignment = $role.Assignments.Create()
$assignment.Trustee = $sidSddlForm
$assignment.SetInfo()
$role.Assignments.Add($assignment)

# Include 'All Objects' in the Assignment Scope
$scopeItem = $assignment.ActivityScopeItems.Create()
$scopeItem.BaseObject = $NULL
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_ALL_DIRECTORY"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$assignment.ActivityScopeItems.Add($scopeItem)
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.AccessControl;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";

        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the Security Role
        String securityRolesPath = admService.Backend.GetConfigurationContainerPath(
            "AccessControlRoles");
        AdsPath securityRolesPathObj = new AdsPath(securityRolesPath);
        AdsPath myRoleAdsPath = securityRolesPathObj.CreateChildPath("CN=My Role");

        IAdmRole role =
            (IAdmRole)admService.OpenObject(myRoleAdsPath.ToString(), null, null, 0);

        // Assign the Security Role to the user

        // Bind to the user
        IADs user = (IADs)admService.OpenObject(userPath, null, null, 0);

        // Get the user's SID in the SDDL form
        byte[] sidBytes = (byte[])user.Get("objectSID");
        Sid sid = new Sid(sidBytes, 0);
        String sidSddlForm = sid.Value;

        IAdmRoleAssignment assignment = (IAdmRoleAssignment)role.Assignments.Create();
        assignment.Trustee = sidSddlForm;
        assignment.SetInfo();
        role.Assignments.Add(assignment);

        // Include 'All Objects' in the Assignment Scope
        IAdmActivityScopeItem scopeItem =
            (IAdmActivityScopeItem)assignment.ActivityScopeItems.Create();
        scopeItem.BaseObject = null;
        scopeItem.Type =
            ADM_SCOPEBASEOBJECTTYPE_ENUM.ADM_SCOPEBASEOBJECTTYPE_ALL_DIRECTORY;
        scopeItem.Inheritance = ADS_SCOPEENUM.ADS_SCOPE_SUBTREE;
        scopeItem.Exclude = false;
        scopeItem.SetInfo();

        assignment.ActivityScopeItems.Add(scopeItem);
    }
}

TrusteeDomain

Gets or sets the name of the domain that the trustee belongs to.

  • Type:
  • String
  • Access:
  • Read/Write

Remarks

The property must be used only for those trustees whose SIDs do not contain any information about the domain (e.g. any built-in Active Directory group, such as ‘BUILTIN\Users’). The property must be assigned a string that contains the domain DNS name or domain SID in the SSDL format.

Examples

The following code sample assigns a Security Role to the built-in domain local group Users including All Objects in the Assignment Scope.

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

$domainDN = "DC=Example,DC=com"

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

# Bind to the Security Role
$securityRolesPath = $admService.Backend.GetConfigurationContainerPath(`
  "AccessControlRoles")
$securityRolesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
  $securityRolesPath
$myRoleAdsPath = $securityRolesPathObj.CreateChildPath(`
  "CN=My Role")

$role = $admService.OpenObject($myRoleAdsPath, $NULL, $NULL, 0)

# Assign the role to the 'Users' group
$assignment = $role.Assignments.Create()
$assignment.Trustee = "BUILTIN\Users"

# Specify the domain SID in the SDDL form
$domain = $admService.OpenObject("Adaxes://$domainDN", $NULL, $NULL, 0)
$domainSid = New-Object "Softerra.Adaxes.Adsi.Sid" @($domain.Get("ObjectSid"), 0)
$sidSddlForm = $domainSid.Value
$assignment.TrusteeDomain = $sidSddlForm

$assignment.SetInfo()
$role.Assignments.Add($assignment)

# Include 'All Objects' in the Assignment Scope
$scopeItem = $assignment.ActivityScopeItems.Create()
$scopeItem.BaseObject = $NULL
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_ALL_DIRECTORY"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$assignment.ActivityScopeItems.Add($scopeItem)
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.AccessControl;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const String domainPath = "Adaxes://DC=Example,DC=com";

        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the Security Role
        String securityRolesPath = admService.Backend.GetConfigurationContainerPath(
            "AccessControlRoles");
        AdsPath securityRolesPathObj = new AdsPath(securityRolesPath);
        AdsPath myRoleAdsPath = securityRolesPathObj.CreateChildPath("CN=My Role");

        IAdmRole role =
        (IAdmRole)admService.OpenObject(myRoleAdsPath.ToString(), null, null, 0);

        // Assign the role to the 'Users' group
        IAdmRoleAssignment assignment = (IAdmRoleAssignment)role.Assignments.Create();
        assignment.Trustee = @"BUILTIN\Users";

        // Specify the domain SID in the SDDL form
        IADs domain = (IADs)admService.OpenObject(domainPath, null, null, 0);
        Byte[] sidBytes = (Byte[])domain.Get("objectSID");
        Sid sid = new Sid(sidBytes, 0);
        String sidSddlForm = sid.Value;
        assignment.TrusteeDomain = sidSddlForm;

        assignment.SetInfo();
        role.Assignments.Add(assignment);

        // Include 'All Objects' in the Assignment Scope
        IAdmActivityScopeItem scopeItem =
            (IAdmActivityScopeItem)assignment.ActivityScopeItems.Create();
        scopeItem.BaseObject = null;
        scopeItem.Type =
            ADM_SCOPEBASEOBJECTTYPE_ENUM.ADM_SCOPEBASEOBJECTTYPE_ALL_DIRECTORY;
        scopeItem.Inheritance = ADS_SCOPEENUM.ADS_SCOPE_SUBTREE;
        scopeItem.Exclude = false;
        scopeItem.SetInfo();

        assignment.ActivityScopeItems.Add(scopeItem);
    }
}

Requirements

Minimum required version: 2009.1

See also