0 votes

Hello,

We currently use a lot of business rules that act as job templates. When a matching job title is found after a user creation, it runs the business rule to configure the user for that particular role. The issue is, we don't have a template built out for every single title.

My question is, can I create a catch-all rule that could run if no other business rule is applied so the user is at least assigned a basic access template?

Thanks

by (520 points)

1 Answer

0 votes
by (289k points)
selected by
Best answer

Hello,

No, there is not such possibility. As a solution, you can have only one Business Rule that will run a PowerShell script to configure the user based on their job title.

0

Yep that would be the plan.

Use the country and job title to determine group memberships.

I've added all the group memberships in the CSV as well as seen in the screenshot above.

0

Hello,

Thank you for clarifying. You will need to use a Business Rule triggering After Creating a User and the below script.

$csvFilePath = "\\Server\share\file.csv" # TODO: modify me
$countryColumnName = "Country" # TODO: modify me
$jobTitleColumnName = "Title" # TODO: modify me
$groupIdentityColumnName = "Group" # TODO: modify me

function SearchObjects($filter)
{
    $domainName = $Context.GetObjectDomain("%distinguishedName%")
    $searcher = $Context.BindToObject("Adaxes://$domainName/rootDSE")
    $searcher.SearchFilter = $filter
    $searcher.SearchScope = "ADS_SCOPE_SUBTREE"
    $searcher.PageSize = 500
    $searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"

    try
    {
        $searchResultIterator = $searcher.ExecuteSearch()
        $searchResults = $searchResultIterator.FetchAll()

        return ,$searchResults
    }
    finally
    {
        # Release resources
        if ($searchResultIterator){ $searchResultIterator.Dispose() }
    }
}

# Get user country
try
{
    $country = $Context.TargetObject.Get("c")
}
catch
{
    $Context.LogMessage("Country not specified", "Warning")
    return
}

# Get user Job title
try
{
    $title = $Context.TargetObject.Get("title")
}
catch
{
    $Context.LogMessage("Job Title not specified", "Warning")
    return
}

# Get group identity
$records = Import-Csv -Path $csvFilePath | Where{($_.$countryColumnName -eq $country) -and ($_.$jobTitleColumnName -eq $title)}
if ($records -ne $NULL)
{
    foreach ($record in $records)
    {
        $groupIdentity = $record.$groupIdentityColumnName
        $searchResults = SearchObjects "(&(objectCategory=group)(|(name=$groupIdentity)(distinguishedName=$groupIdentity)(sAMAccountName=$groupIdentity)))"

        if ($searchResults.Length -eq 0)
        {
            $Context.LogMessage("Group '$groupIdentity' not found.", "Warning")
            continue
        }
        elseif ($searchResults.Length -gt 1)
        {
            $Context.LogMessage("Found more than one group with the following identity '$groupIdentity'", "Warning")
            continue
        }

        # Add user to the group
        $group = $Context.BindToObject($searchResults[0].AdsPath)
        $group.Add($Context.TargetObject.AdsPath)
    }
}

In the script:

  • $csvFilePath – Specifies the path to the CSV file;
  • $countryColumnName – Specifies the name of the CSV file column that contains values for the Country property;
  • $jobTitleColumnName - Specifies the name of the CSV file column that contains values for the Job Title property;
  • $groupIdentityColumnName - Specifies the name of the CSV file column that contains groups the user should be added to.
0

I really appreciate the quick replies!

Let me play around with this and I'll post my results.

Thanks!

0

@Support2

Just so i am reading this correctly, we can setup a CSV file with all the attributes we set in a Business rule and NOT have to create a seperate section in a business rule for each jobCode? We currently have a ton setup through a business rule and would love to configure it through a CSV. Can this happen for Creation and Changing jobcodes?

0

Hello,

The script we provided just adds users to corresponding groups based on Country and Job Title upon creation. You can create and modify users from CSV files. Have a look at the following script from our repository: https://www.adaxes.com/script-repositor ... e-s246.htm.

Related questions

0 votes
1 answer

In a business rule, I'd like to pass Adaxes variables into a powershell script that I'll run. For example, pass %username% into the script so it can be used inside the script.

asked Sep 5 by P-Sysadmin (20 points)
0 votes
1 answer

The closest operation I figure is "modfying exchange properties" of a user but not sure how I can filter the conditions to match. It's possible I could ... ? Was also looking at adm-MsExchMailboxCalendarPermissions but havent played around with that yet.

asked May 17 by ZoomGhost (280 points)
0 votes
1 answer

Rule 1. we have a business rule which disables a user account after updating a user. It then does some other actions. Rule 2. we have a business rule which performs ... 2 then triggered immediately and the flow of control handed back to rule 1 to continue?

asked Apr 3 by i*windows (280 points)
0 votes
1 answer

Hi team, I have a follow up to this question https://www.adaxes.com/questions/14234/business-after-adding-members-powershell-script-executed Let me explain my setup A rule- ... area% failed due to the following exception: $($_.Exception.Message)", "Error") }

asked Feb 13 by wintec01 (1.5k points)
0 votes
1 answer

Hi, I have a business rule setup to perform actions after user creation. First action is to run a powershell script which works and it sets a required AD attribute ( ... new user sits in the original OU and does not move Am i missing something here?

asked Feb 6 by Lewis (40 points)
3,550 questions
3,241 answers
8,236 comments
547,827 users