0 votes

When a new user account is created by copying an existing one, is it possible to prevent the new account from becoming a member of security groups in a specific OU (when the copy group membership option is selected)?

Currently I use a script in the "After creating a user" business rule to remove them from those security groups. However, the removal is not reflected in the Adaxes log in the same way as the account being added to the group, which I need for audit purposes.

by (70 points)

1 Answer

0 votes
by (292k points)

Hello Mark,

When a new user account is created by copying an existing one, is it possible to prevent the new account from becoming a member of security groups in a specific OU (when the copy group membership option is selected)?

Unfortunately, there is no such possibility. Removing users from groups in a Business Rule triggering After crating a user is the correct approach to achieve what you need.

However, the removal is not reflected in the Adaxes log in the same way as the account being added to the group, which I need for audit purposes.

Most probably, the script performs the updates in AD directly and thus they are not reflected in Adaxes logs. Please, post your script here or send to us (support[at]adaxes.com) and we will update it to log group membership updates.

0

This is the (asyncronous) script I use to remove them after user creation:

$UserDN = "%distinguishedName%"

Start-Sleep -Seconds 60

#remove from all appropriate groups
$groups = Get-ADPrincipalGroupMembership -Identity $UserDN | ? {$_.distinguishedname -like "*OU=SpecificOU*"}

foreach ($group in $groups) {
    $GroupDN = $group.distinguishedName
    $Context.LogMessage("Removing from: $GroupDN", "Information")
    Remove-AdmGroupMember -Identity $GroupDN -Members $UserDN -Confirm:$false
}
+1

Hello Mark,

As we mentioned in the previous post, the script performs removal from group directly in AD avoiding Adaxes pipeline. For the pipeline to be applied, you need to specify the -AdaxesService and -Server parameters when executing the Remove-AdmGroupMember cmdlet. For details, have a look at the following SDK article: http://adaxes.com/sdk/Remove-AdmGroupMember. We updated the script accordingly, find it below. In the script, you need to replace the value of the -Server parameter with the required one.

$UserDN = "%distinguishedName%"

# Get DNs of current groups the user is member of
try
{
    $groupDNs = $Context.TargetObject.GetEx("memberOf")
}
catch
{
    $Context.LogMessage("User %name% is not a member of any groups.", "Information")
    return
}

# Remove from all appropriate groups
foreach ($groupDN in $groupDNs)
{
    if (-not($groupDN -like "*OU=SpecificOU*"))
    {
        continue
    }

    $Context.LogMessage("Removing from: $groupDN", "Information")
    Remove-AdmGroupMember -Identity $GroupDN -Members $UserDN -AdaxesService localhost -Server "dc.domain.com" -Confirm:$false
}
0

That works! The log is now showing the removals as well.

Thank you very much!

Related questions

0 votes
1 answer

Can you please advise on the best way to do this? We have a forest with four domains. In one of those domains we keep consultants, partners, and vendors (lets call ... Adaxes users from adding users from Domain X to any groups outside of Domain X. Thanks

asked Jan 29, 2013 by jiambor (1.2k points)
0 votes
1 answer

Hi there, I've created a Delete User feature in the Web Interface Configurator. I am trying to restrict object selection via a User Criteria. Need to exclude Service ... won't appear when selecting target user for the 'Delete User' feature. Thanks, David

asked Sep 19 by dshortall (80 points)
0 votes
1 answer

A little bit of context: There are 3 departments that share 1 Active Directory. Now each department has its own OU. I would like to have an email sent when a user is ... if this is possible without Powershell? If not, is there a pre-existing script for this?

asked Oct 3, 2023 by Cas (200 points)
0 votes
1 answer

Hello, We would like to implement a form / extend one where a user (eventually created before) is made member of a security group defining his/her role, and ... guarantee the membership to a single role? Apologize if the question seems convoluted. Thanks!

asked Jun 6, 2023 by IT Division (20 points)
0 votes
1 answer

How can I create a script that does these things For internal audit. objective Even removing all groups of a disconnected user, we will still know which groups the ... in the created group (audit)-sAMAccountName-access add the (user)-sAMAccountName in members

asked Jul 2, 2022 by alancardoso (40 points)
3,564 questions
3,255 answers
8,264 comments
547,915 users