Hallo,
I'm trying to build a function that will have two parameters $Containrer and $Filter
$filter - is a LDAP filer that serach some specific objects
$Containrer - is a container in which $filter should looks for object
Function shoud return list of distinguishedNames ob finded objects
So at first I try make some simple code to transform it into function but I dosn't work.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
$userSAM = "%samaccountname%"
$searcher = $admService.OpenObject("Adaxes://$GroupsContainerDN", $NULL, $NULL, 0)
$searcher.SearchFilter = "(&(objectClass=group)(extensionAttribute1=$userSAM))"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.SetPropertiesToLoad(@("distinguishedName"))
$searchResults = $searcher.ExecuteSearch()
$array = @{}
foreach ($object in $searchResults.FetchAll())
{
$DN = $object.Properties["distinguishedName"].value
$array += $DN
}
$searchResults.Dispose()
The code should returned a list of DN's , but I got "You can add another hash table only to a hash table'
Seams that $DN is treated by powershell as a hash table, is it possible to workoroud it somhow?