Hello Jay,
Thank you for clarifying. The solution will include a Home Page Action, a Scheduled Task and a Property Pattern. The Home Page Action form will contain only the group name field and the four fields you mentioned in your first post. The Scheduled Task will create an LDAP filter for group members and add corresponding users to the group. The Property Pattern will specify a template used to generate group Description.
As long as Company of a group is a Company of the group owner, we recommend using one of Adaxes text attributes (e.g. CustomAttributeText1) to store the company name that will be used to filter group members. For the third and fourth field, we also recommend using Adaxes custom text attributes (e.g. CustomAttributeText2 and CustomAttributeText3)
i. Creating the Home Page Action
- Launch Adaxes Web Interface Customization Tool.
- Select the interface type and click Configure Home Page Actions on the General tab.
- Click Add and select Create New Group.
- Click Next.
- On step 2 of the wizard, specify the conditions for selecting the container where new groups will be created and click Next.
- Select Use customized form and click Customize Form.
- Delete all the sections except for the General one.
- Delete all the properties from the section except for Group Name and Group Type.
- Click Add below Section fields.
- Select Show all properties.
- Select CustomAttributeText1, CustomAttributeText2 and CustomAttributeText3.
- Click OK twice and finish creating the Home Page Action.
For information on how to change property display names, have a look at the following help article: https://www.adaxes.com/help/?HowDoI.Man ... Names.html.
ii. Creating the Property Pattern
- Launch Adaxes Administration Console.
- Right-click your Adaxes service node, navigate to New and click Property Pattern.
- On step 2 of the Create Property Pattern wizard, select Group Object type and click Next.
- Click Add and select Description.
- In the Generate default value field, type the template. For example:
This group controls access for %adm-CustomAttributeText1% to %adm-CustomAttributeText2%.
- Click OK.
- Click Next and finish creating the Property Pattern.
iii. Creating the Scheduled Task
-
Launch Adaxes Administration Console.
-
Right-click your Adaxes service node, navigate to New and click Scheduled Task.
-
On step 3 of Create Scheduled Task wizard select Group Object type and click Next.
-
Click Add Action.
-
Select Run a program or Powershell script.
-
Paste the below script into the Script field.
$companyProperty = "adm-CustomAttributeText1" # TODO: modify me
$employeeTypeProperty = "adm-CustomAttributeText2" # TODO: modify me
function SearchObjects($filter, $domainName, $properties)
{
# Set search parameters
$searcher = $Context.BindToObject("Adaxes://$domainName")
$searcher.SearchFilter = $filter
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.SetPropertiesToLoad($properties)
try
{
# Execute search
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
return ,$searchResults
}
finally
{
# Release resources
if ($searchResultIterator){ $searchResultIterator.Dispose() }
}
}
# Get company for LDAP filter
try
{
$company = $Context.TargetObject.Get($companyProperty)
}
catch
{
$Context.LogMessage("Company not specified", "Warning")
return
}
# Get employee type for LDAP filter
try
{
$employeeType = $Context.TargetObject.Get($employeeTypeProperty)
}
catch
{
$employeeType = $NULL
}
# Build filter
$filter = New-Object "System.Text.StringBuilder"
[void]$filter.Append("(&(sAMAccountType=805306368)(company=$company)")
if (-not([System.String]::IsNullOrEmpty($employeeType)))
{
[void]$filter.Append("(employeeType=$employeeType)")
}
[void]$filter.Append(")")
$domainName = $Context.GetObjectDomain("%distinguishedName%")
# Search users
$searchResults = SearchObjects $filter.ToString() $domainName @("distinguishedName")
# Add users to group
if ($searchResults.Length -eq 0)
{
$Context.TargetObject.PutEx("ADS_PROPERTY_CLEAR", "member", $NULL)
}
else
{
[System.Array]$userDNs = $searchResults | %%{$_.Properties["distinguishedName"].Value}
$Context.TargetObject.PutEx("ADS_PROPERTY_UPDATE", "member", $userDNs)
}
# Save the changes
$Context.TargetObject.SetInfo()
-
Enter a short description and click OK.
-
Click Next and finish creating the Scheduled Task.