Access AD on 2003 DC with .NET

by i255d at 2013-02-07 13:39:11

I have 2003 DC’s and I am not in a position to upgrade them yet. I am trying to be able to pull out lists of computers or users from OU’s or by other filters. This is all I have been able to find so far, and it just gives me a return of 0.

I would like to get this working.

$strFilter = "(&(objectCategory=User)(Department=‘Operations’))"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

#$objOU = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Operations,OU=Internal,OU=Accounts,dc=ddd,dc=vvv,dc=com")

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher

$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{$objItem = $objResult.Properties; $objItem.name}
by Klaas at 2013-02-08 00:15:59
If you install RSAT on you client machine, you can use ADcmdlets against 2003 servers as well.
The account and priviliges matter too, are you a domain admin and did you start Powershell as administrator?
You could try with only the necessary lines and add the others one by one.
Do you get the output you expect with this?:
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher("LDAP://OU=Operations,OU=Internal,OU=Accounts,dc=ddd,dc=vvv,dc=com")
$objSearcher.filter = "(&(objectclass=user)(objectcategory=person))"
$colResults = $objSearcher.FindAll()
$colResults