The following script assigns group My Group to a Security Role called My Role over a Business Rules container called My Container:
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$adaxesHost = "localhost"
$trusteeDN = "CN=My Group,CN=Users,DC=company,DC=com" # TODO: modify me
$businessRuleContainerName = "My Container" # TODO: modify me
$securityRoleName = "My Role" # TODO: modify me
# Connect to the Adaxes service
$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly($adaxesHost)
# Bind to the trustee object
$trustee = $admService.OpenObject("Adaxes://$trusteeDN", $NULL, $NULL, 0)
# Bind to the root container of Business Rules
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath([Softerra.Adaxes.Adsi.WellKnownBackendContainer]::BusinessRules)
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $businessRulesPath
$businessRulesContainerAdsPath = $businessRulesPathObj.CreateChildPath("CN=$businessRuleContainerName")
$businessRulesContainer = $admService.OpenObject($businessRulesContainerAdsPath.ToString(), $NULL, $NULL, 0)
# The following function assigns a Security Role to a given trustee over specified activity scope
function AssignRole($roleName, $trustee, $baseObject, $scopeType, $scopeInheritance)
{
$securityRolesContainerPath = $admService.Backend.GetConfigurationContainerPath([Softerra.Adaxes.Adsi.WellKnownBackendContainer]::AccessControlRoles)
$securityRolesContainerAdsPath = New-Object "Softerra.Adaxes.Adsi.AdsPath" $securityRolesContainerPath
$roleAdsPath = $securityRolesContainerAdsPath.CreateChildPath("CN=$roleName")
$admRole = $admService.OpenObject($roleAdsPath.ToString(), $NULL, $NULL, 0)
$admAssignment = $admRole.Assignments.Create()
$trusteeSidBytes = $trustee.Get("objectSid")
$trusteeSid = New-Object "Softerra.Adaxes.Adsi.Sid" @($trusteeSidBytes, 0)
$admAssignment.Trustee = $trusteeSid.ToString()
$admAssignment.SetInfo()
$admRole.Assignments.Add($admAssignment)
$admScopeItem = $admAssignment.ActivityScopeItems.Create()
$admScopeItem.Put("adm-ScopeBaseObjectGuid", $baseObject.Get("objectGUID"))
$admScopeItem.Exclude = $False
$admScopeItem.Type = $scopeType
$admScopeItem.Inheritance = $scopeInheritance
$admScopeItem.SetInfo()
$admAssignment.ActivityScopeItems.Add($admScopeItem)
}
# Assign the Security Role over the specified container of Business Rules
AssignRole $securityRoleName $trustee $businessRulesContainer "ADM_SCOPEBASEOBJECTTYPE_CONTAINER" "ADS_SCOPE_SUBTREE"
BTW, if you assign your Security Role like that, it may contain only one permission - Allow Full Control -> All Objects.