0 votes

Hello

I have a piece of code that troubles me:

Import-Module Adaxes

# $Server = $Context.GetObjectDomain("%distinguishedName%")
$Advisgruppe = "%distinguishedName%"
$Member = $Context.BindToObject("Adaxes://%member%")
$UserFullName = $Member.Get("name")
$TheUserCpr = $Member.Get("employeeNumber")
$TheUserOffice = $Member.Get("physicalDeliveryOfficeName")

# For debug
$Context.LogMessage("Bruger: " + $UserFullName, "Information")
$Context.LogMessage("AdvisGruppe: " + $Advisgruppe, "Information")

-----

If executed directly as a Powershell part of a Business Rule, that fires before adding a user to a group, it works okay (the target user is the right one):

If executed from the same Business Rule, but now as a Custom Command (Object type: group) , the target user is wrong:

I've reused the code from another BR/CC combination, except for one thing. In the other combinations, the Activity Scope is an OU (subtree).
In the case above, it is a specific security group.

- Thanks

by (2.6k points)

1 Answer

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

Hello,

By default, the %member% value reference returns a member you've just added or removed only in Business Rules triggered on adding or removing members from groups. In other Business Rules, and also in Custom Commands and Scheduled Tasks this value reference is substituted with the DN of the 1st member of the group returned by Active Directory, and there's absolutely no guarantee that AD returns the last added user first.

Thus, in your case, the option to use a Business Rule is correct, and the option to use a Custom Command is not.

0

Thanks. That cleared out some other issues too.
You can add [SOLVED] to this one too :-)

- Regards

0

Hi

Come to think about it......

Is there another method - in Custom Commands - to determine the target user, to be/has been added og removed ??

I am asking, because I have several similar scripts (to maintain) in different Business Rules, that do the same job.

- Thanks

0

Hello,

Could you specify why you need multiple Business Rules to execute this script? What are the differences between the use cases? Can you provide as much detail as possible?

0

Hi

The learning curve rise, as we develop in Adaxes ...... ;)

No problem here after all.

- Thanks for your patience and understanding.

Related questions

0 votes
1 answer

We have a series of transforms we use for users including moving to different OU's. Is there a way to open the user's object after the command completes much in the same way a user creation does?

asked 1 day ago by msheppard (470 points)
0 votes
1 answer

When we create a new user in Adaxes, we can select the job title in a dropdown because we have defined it in the property pattern. Now I would like to create a custom ... How can I bring the same dropdown from "create user" into my custom command? Thank you!

asked Sep 25, 2023 by DRiVSSi (300 points)
0 votes
1 answer

I had a business rules that had a PowerShell script to update User properties in a SQL table. It was working fine. I moved the PowerShell to a custom command so I could ... in the custom command does get the values for the User object. Am I missing something?

asked Jun 2, 2014 by sdavidson (730 points)
0 votes
1 answer

The use case we are looking for is providing a list of titles for users to choose from when initiating a re-hire. We already have a title property pattern established and would ... that we can manage the list in one place. Let me know and as always, thanks.

asked 1 day ago by msheppard (470 points)
0 votes
1 answer

Is it possible during a custom command to prompt input from the user initiating the command and to take a different action depending on their answer? For example, ... provide the automatic reply text If No - proceed with predetermined reply text. Thanks

asked Oct 28 by msheppard (470 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users