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"
}