Hello,
i'm german so sorry for my bad english. :D
I'm using the Bultin Report "Member of Groups:
# Get parameter values
$groupTypes = $Context.GetParameterValue("param-GroupTypes")
$memberTypes = $Context.GetParameterValue("param-MemberTypes")
$membersPropertyName = $Context.GetParameterValue("param-IndirectMembers")
# Custom column identifiers
$groupColumnID = "{b3292b44-9d91-4c84-a411-179dc0bf19d3}"
# IDs of primary groups to exclude from the report
$primaryGroupIDs = @{ 513="Domain Users"; 515="Domain Computers"; 516="Domain Controllers"; 521="RODCs" }
# Search filter
$filter = "(|" + $groupTypes + ")"
$Context.DirectorySearcher.AppendFilter($filter)
$filterMembers = "(|" + $memberTypes + ")"
# Add properties necessary to generate the report
$propertiesForMembers = $Context.DirectorySearcher.GetPropertiesToLoad()
$propertiesForGroups = @("objectClass", "objectGuid", "distinguishedName", "primaryGroupToken")
$Context.DirectorySearcher.SetPropertiesToLoad($propertiesForGroups)
# Create a hash table to map member GUIDs to search results
$guidComparer = $Context.CreatePropertyValueComparer("objectGuid")
$memberGuidToSearchResult = New-Object System.Collections.Hashtable @($guidComparer)
# Generate report
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator))
{
$searchResult = $searchIterator.Current
# Exclude well-known primary groups
$primaryGroupID = $searchResult.GetPropertyByName("primaryGroupToken").Values[0]
if ($primaryGroupIDs.Contains($primaryGroupID))
{
continue
}
$groupDN = $searchResult.GetPropertyByName("distinguishedName").Values[0]
# Get GUIDs of the group members
$group = $Context.BindToObjectBySearchResult($searchResult)
try
{
$memberGuids = $group.GetEx($membersPropertyName)
}
catch [System.Runtime.InteropServices.COMException]
{
if ($_.Exception.ErrorCode -eq 0x8000500D) # E_ADS_PROPERTY_NOT_FOUND
{
# The group doesn't have any members
$columnValues = @{ $groupColumnID = $groupDN; }
if ($styleNoMembers -eq $NULL)
{
$styleNoMembers = $Context.Items.CreateItemStyle("#3d3d3d", $NULL,
"ADM_LISTITEMFONTSTYLE_REGULAR")
}
$Context.Items.Add(-1, "<Keine Mitglieder>", "Information", $columnValues, $styleNoMembers)
continue
}
else
{
throw $_.Exception
}
}
# Add group members to the report
$guidsToSearch = $NULL
# Add already found objects
foreach ($memberGuid in $memberGuids)
{
if (-not $memberGuidToSearchResult.Contains($memberGuid))
{
if ($guidsToSearch -eq $NULL)
{
$guidsToSearch = New-Object System.Collections.ArrayList
}
$guidsToSearch.Add($memberGuid)
}
else
{
$memberSearchResult = $memberGuidToSearchResult[@(,$memberGuid)][0]
$clonedSearchResult = $memberSearchResult.Clone($False)
$columnValues = @{ $groupColumnID = $groupDN; }
$Context.Items.Add($clonedSearchResult, $columnValues, $NULL)
}
}
if ($guidsToSearch -eq $NULL)
{
continue
}
# Search for members
$memberSearcher = $Context.CreateGuidBasedSearcher($guidsToSearch)
$memberSearcher.SetPropertiesToLoad($propertiesForMembers)
$memberSearcher.AppendFilter($filterMembers)
try
{
$memberSearchIterator = $memberSearcher.ExecuteSearch()
while ($Context.MoveNext($memberSearchIterator))
{
$memberSearchResult = $memberSearchIterator.Current
# Remember the search result
$memberGuid = $memberSearchResult.GetPropertyByName("objectGuid").Values[0]
$memberGuidToSearchResult[$memberGuid] = $memberSearchResult.Clone($False)
# Add the object to the report
$columnValues = @{ $groupColumnID = $groupDN; }
$Context.Items.Add($memberSearchResult, $columnValues, $NULL)
}
}
finally
{
if ($memberSearchIterator) { $memberSearchIterator.Dispose() }
}
}
}
finally
{
if ($searchIterator) { $searchIterator.Dispose() }
}
The Result of this Report is exactly the same when executed in Adaxes Management Console and in the Web-Portal.
I modified the script so that not the Property "distinguishedName" but the Property "cn" or "name" is used.
The Result when executed inside the Management Console is as expected.
When executed inside the Web Portal than there is only one group "unspecified" with alle the users inside.
What am i doing wrong here?