2
votes

The above gives:

PS C:\EndurAutomation\powershell\bin> C:\EndurAutomation\powershell\bin\ets_update_constring.ps1 Exception calling "FindAll" with "0" argument(s): "An operations error occurred. " At C:\EndurAutomation\powershell\bin\ets_update_constring.ps1:20 char:30 + $result = $ldapSearch.FindAll <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

$ldapDN = "dc=<masked>,dc=<masked>"
$ldapURI = "ldap://<masked>/$ldapDN"


$env = "sqlplus -S <masked> ``@env.sql > env.list"
Invoke-Expression $env
$envData = (Get-Content "env.list")

$envFilter = "(|"
foreach ($env in $envData) {
    $envFilter += "(cn=$env)"
}
$envFilter += ")"

$ldapEntry = New-Object System.DirectoryServices.DirectoryEntry($ldapUR, $null, $null,         [System.DirectoryServices.AuthenticationTypes]::Anonymous)
$ldapSearch = New-Object System.DirectoryServices.DirectorySearcher($ldapEntry)
$ldapSearch.PageSize = 1000
$ldapSearch.Filter = $envFilter

$result = $ldapSearch.FindAll($envFilter)
2

2 Answers

1
votes

You already set $ldapSearch.Filter = $envFilter so you don't need to call FindAll by passing in the filter again. Try doing this instead as your very last line of code, as it will still have your filter built into it:

$result = $ldapSearch.FindAll()
0
votes

I think it's a typo:

$ldapEntry = New-Object System.DirectoryServices.DirectoryEntry(
        **$ldapUR**, $null, $null, 
        [System.DirectoryServices.AuthenticationTypes]::Anonymous
    )

Try

$ldapURI 

instead of

$ldapUR