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

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 (240 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

To the left of the user object there are several custom commands showing. I don't want our service desk to see them. Why are they showing? How do I remove them. Must be something simple. They only see these when looking at a user Object.

asked Jan 17 by mightycabal (1.0k points)
0 votes
1 answer

Then I could put the approval on the custom command.

asked Dec 4, 2023 by mightycabal (1.0k points)
0 votes
1 answer

Here is my issue, When I use this code: $DNs = %param-GroupsInRole% $Groups = $DNs -split "|" %Param-GroupsInRole% can have multiple groups. When setting up the parameter I am ... I just need to be able to do a foreach with the groups picked by the initiator.

asked Mar 23, 2023 by mightycabal (1.0k points)
3,326 questions
3,026 answers
7,727 comments
544,678 users