0 votes

Hi,

Not sure if I'm asking the right question but here we go..!

I am looking to run a PowerShell Script that remotely triggers an Adaxes Custom Command and I would like to get direct feedback on the success\failure of the command to use in my pipeline.

In my simple test the Custom Command tests if the supplied user is a member of a group, and if so runs a PS script that logs the message 'True'.

Using the below PS script remotely I can execute this Command by passing it a user DN and then return the log message as my 'feedback', but was wondering if there was a more elegant way of doing this?

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("server")

$user = $admService.OpenObject("Adaxes:/CN=Joe Bloggs,DC=network,DC=net", $NULL, $NULL, 0)
$user.ExecuteCustomCommand({command GUID})

$operationInfo = $user.GetLastOperationInfo()
$executionLog = $operationInfo.ExecutionLog
$executionLog.SubEntries.SubEntries.Message
by (250 points)
0

I could add, in this precise scenario I was trying to make the membership search in the most efficient way possible. This may not actually be it.

I could use the following:-

Get-AdmPrincipalGroupMembership -Identity "user"-AdaxesService "server"
$groups.Name -contains 'Domain Users'

But this is quite inefficient when the user is a member of a lot of groups. What way would you recommend to efficiently search if a member is a member of a specific group?

1 Answer

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

Hello,

To check whether a user is a member of a specific group via Windows PowerShell, you can use the below script. It will output True if the user is a member and False if the user is not a member of the group. In the script:

  • $groupDN - specifies the distinguished name (DN) of the group;
  • $userDN - specifies the distinguished name (DN) of the user.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the group
$groupDN = "CN=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Check whether user is member of the group
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
Write-Host $group.IsMember("Adaxes://$userDN")

Related questions

0 votes
1 answer

Hi team, I have a business rule which is triggered, after an approval request was updated. Is it possible to read the reason somehow (if entered by the ... possible to run these actions only against specific approval or commands which create approvals?

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

Is there a way to enable/code a successful or unsuccessful popup window for a password change that was completed via the "change password" link on the MyProperties ... on a successful password change but an in-page notification would be extremely helpful.

asked Aug 29, 2014 by Phoenix7C7 (20 points)
0 votes
1 answer

Hi, we are running Adaxes in hybrid setup and on-prem as O365 is connected. My business rules looks like this Based on articles I have read here, the local mailbox should ... with a mailbox size of 2GB. Onprem: Online: Anything I am missing or misunderstood?

asked Jul 17, 2023 by wintec01 (1.5k points)
0 votes
1 answer

Are the logs still accessable using the "logging" link in the administrator console? What about the web console? What is the recommended setting for local log ... function within ADAXES to cleanup remote logs after they are past our retention requirements?

asked Jul 12, 2023 by stevehalvorson (110 points)
0 votes
1 answer

Hello! We have an Business Rule that should enable the remote Mailbox after an User is created but that does not work. The Powershell Script that we have in an Custom Command does ... now. What can i do to make it work like we intend to? Thanks in advance!

asked Jun 21, 2023 by eww ag (140 points)
3,552 questions
3,242 answers
8,243 comments
547,829 users