+1 vote

I would like to possibly add a timestamp to a user custom attribute when added to a specific group. The reason for this is because I'd like to display the value of days spent in the group in a report column.

Trying to think of ways to accomplish this via conditions and actions and haven't found the right combo.

Let me know if I am missing something or if it must be done by script or if there is another way I am not thinking of.

Thanks!

by (720 points)

1 Answer

+1 vote
by (298k points)

Hello,

The only option is using a business rule triggering After adding a member to a group and the below PowerShell script. There is no possibility to use built-in actions as the target object is the group itself while you need to update the member. In the script, $dateProperty specifies the schema name of the custom attribute to save the current date to.

$dateProperty = "adm-CustomAttributeDate1" # TODO: modify me

# Bind to new member
$member = $Context.BindToObject("Adaxes://%member%")

# Update new member
$member.Put($dateProperty, "%datetime%")
$member.SetInfo()
0

Thank you, that will work. Can I use the same script to clear that custom attribute after being removed from the group? Would I set the variable to $null?

0

Hello,

Can I use the same script to clear that custom attribute after being removed from the group?

Yes, it will work just fine.

Would I set the variable to $null?

No, you will need to replace "%datetime%" with $Null.

0

Perfect and thank you

0

I can also handle this with an update user action to clear the field, but I would like to know how to modify the script to be relevant to the user removed as well.

I believe this statement would need to be revised as well because the user is no longer a member, is that correct?

# Bind to new member
$member = $Context.BindToObject("Adaxes://%member%")

In the event that the user is being removed what would this be? Or would this work before the user is removed from the group?

I'd also like to remove the user from another group

0

Hello,

I can also handle this with an update user action to clear the field, but I would like to know how to modify the script to be relevant to the user removed as well.

As it was mentioned above, you can use the very same script with "%datetime%" replaced by $Null.

I believe this statement would need to be revised as well because the user is no longer a member, is that correct?

That is not correct. This code will work just fine.

I'd also like to remove the user from another group

You can use the below script. In the script, the $targetGroupDN variable specifies the distinguished name (DN) of the group to remove the member from. For details on how to get an object DN, see https://adaxes.com/sdk/HowDoI.GetDnOfObject.

$targetGroupDN = "CN=My Group,OU=Groups,DC=example,DC=com" # TODO: modify me

$group = $Context.BindToObjectByDN($targetGroupDN)

if ($group.IsMember("Adaxes://%member%"))
{
    $group.Remove("Adaxes://%member%")
}
0

OK confirmed all works as expected.

My issue was I quote encapsulated the null "$Null" instead of just $Null

That gets me more than I like.

Thanks again.

Related questions

0 votes
1 answer

How to grant someone access to see logging in Adaxes Admin Console?

asked Nov 30, 2022 by sra98a (120 points)
0 votes
1 answer

Our audits require us to provide a report of who has access in applications. Most applications provide a way to produce this access report. Can Adaxes add this feature?

asked Nov 7, 2024 by lavonnabalo (40 points)
0 votes
1 answer

I have to do a weekly Inactiviy Report for Accounts that have not logged in for 30 days or more. 1 of the reports is for Internal users BUT there is an Account ... Adaxes and working on the product, and i need to get all my reporting done through Adaxes

asked Nov 14, 2022 by dtorannini (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

Is it possible to provide a reason to the group owner when adding a user to a group that requires approval? Currently, after the owner approves or denies the request, they ... for their approval or denial actions. Let me know if this is possible, thanks.

asked Dec 12, 2024 by KoleArmstrong (120 points)
3,628 questions
3,315 answers
8,392 comments
548,712 users