0 votes

Hi there, I am trying creating a report in Adaxes a set of users and looking to add a few group names as column with value 'Yes' or 'No' based on if user is member of that group. below is the example

Name Department Group1
User1 Sales Yes

Adding my current non working script for teh column

$user = $context.GetADObject()

$memeberof = $user.Get("Memberof")

if($memberof.contains("CN=xxx,OU=Security Groups,DC=xxx,DC=xxx")){
$Context.Value = "Yes"
}
else{
$Context.Value = "No"
}

Would appreciate any help in this aspect.

by (460 points)
edited by

1 Answer

0 votes
by (294k points)

Hello,

The main thing here is that you are using the Get method for a multivalued property which will not work. To achieve the desired, use the below script for the custom column generation. In the script, the $groupDN variable specifies the distinguished name (DN) of the group to check. For information on how to get an object DN, see http://adaxes.com/sdk/HowDoI.GetDnOfObject.

$groupDN = "CN=my group,OU=Groups,DC=domain,DC=com" # TODO: modify me

# Bind to the group
$group = $Context.BindToObjectByDN($groupDN)

# Check membership
if($group.IsMember("Adaxes://%distinguishedName%"))
{
    $Context.Value = "Yes"
}
else
{
    $Context.Value = "No"
}
0

Thank you the response.

I tried the above code mentioned, it don't get any error but just the if condition is coming up as true for all the users.

I understand the %distinguishedName% is for adding the parameter,but it looks like this parameter is showing the DN of the user running the report. And thus shows the same value for all the users that come up in the report.

Also what does Adaxes://%distinguishedName% do?

0

Hello,

As we mentioned in the answer, the script should be used in the report custom column. The script will not work anywhere else. In this case, the %distinguishedName% value reference will resolve into the DN of the object being added to the report. image.png If this is not what you need, please, describe the desired behaviour in all the possible details with live examples.

As for Adaxes://%distinguishedName%, it forms the ADS Path of the object.

0

I am using the script as you mentioned exclusively for creating custom column, but the end result is that I am seeing the column value as 'Yes' for users int eh report who are not part of the group.

I tried to see the what is the value in %distinguishedName% as the context value in the if condition as shown below

$groupDN = "CN=my group,OU=Groups,DC=domain,DC=com" # TODO: modify me

# Bind to the group
$group = $Context.BindToObjectByDN($groupDN)

# Check membership
if($group.IsMember("Adaxes://%distinguishedName%"))
{
    $Context.Value = "%distinguishedName%"
}
else
{
    $Context.Value = "No"
}

What is see in the context value is my user DN showing up for all the users in report. I believe this is may be showing the DN for user running the report.

So I tried the below code, but got errors

$GroupDN = "CN=my group,OU=Groups,DC=domain,DC=com"
$User = $Context.GetADObject()
$UserDN = $User.Get("distinguishedName")


# Bind to the group
$group = $Context.BindToObjectByDN($groupDN)

# Check membership
if($group.IsMember("$UserDN"))
{
    $Context.Value = "Yes"
}
else
{
    $Context.Value = "No"
}
+1

Hello,

Sorry for the confusion. You are right, using a value reference will not work in this case. Here is the script that will do the trick.

$groupDN = "CN=my group,OU=Groups,DC=domain,DC=com" # TODO: modify me
# Get object DN
$object = $Context.GetADObject()
$objectDN = $object.Get("distinguishedName")

# Bind to the group
$group = $Context.BindToObjectByDN($groupDN)

# Check membership
if($group.IsMember("Adaxes://$objectDN"))
{
    $Context.Value = "Yes"
}
else
{
    $Context.Value = "No"
}
0

Thank you the above code worked. Would you be able to guide me to a documentation which lists more functions for custom column scripts.

Also I plan to add 10 columns/group check anychance will this affect the perfomance of the report?

0

Hello,

Would you be able to guide me to a documentation which lists more functions for custom column scripts.

Have a look at the following SDK article: http://adaxes.com/sdk/GenerateReportCustomColumns. Also, it is recommended to generate column values in the script generating the report itself. For details, see section Setting values for custom columns of the following SDK article: http://adaxes.com/sdk/GeneratingReports/#setting-values-for-custom-columns.

Also I plan to add 10 columns/group check anychance will this affect the perfomance of the report?

It depends on the number of users to be included into the report. Most probably, it will influence performance.

0

I see so rather than adding the custom columns (script), I create a report based on the Powershell script itself. I actually do have a powershell script which gives me the eaxct report I am trying to build.

Just trying to recreate the report so other team memebrs can check it anytime in Adaxes.

Related questions

0 votes
1 answer

Is it possible to add a user to a group based on hardware ? There are users with a Windows device and a MacOS device. I want to be able to choose this when ... the user via Adaxes and automatically link them to a specific group based on the chosen hardware.

asked Apr 16 by Cas (200 points)
0 votes
1 answer

Hi support, We have security groups named like Test-Group--Users, where is different for each group. I have a powershell query which gets a list of those Test-Group--Users" ... only Test-Group-<variable>-User that user is member of but it is an array

asked Oct 31 by Vish539 (460 points)
0 votes
1 answer

I want to add a custom column in a report that displays members of a group that shows the age of the user account in days. Is that possible?

asked Oct 23 by msheppard (610 points)
0 votes
1 answer

I created a group Business Rule that triggers "After adding or removing a member from a group". On its Activity Scope I added a test group, and set it for "The group ... does not trigger. What should I do to make the BR detect this (admittedly rare) case?

asked Mar 16, 2023 by alex.vanderwoude (60 points)
0 votes
1 answer

Hello, My question potentially piggy-backs off of the following URL: Automated Expiry of Group Membership We have the need to add/remove users frequently to/from a ... something like this in Adaxes? Thanks in advance for any replies or assistance. Jason

asked Jan 29, 2019 by slowllama (100 points)
3,588 questions
3,277 answers
8,303 comments
548,079 users