1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
$strBase = "<LDAP://localhost:389>"
$strFilter = "(&(objectCategory=user)(name=Dupont))"
$strAttributes = "name,samaccountname"
$strScope = "subtree"
$strQuery = "$strBase;$strFilter;$strAttributes;$strScope"
$objConnection = New-Object -ComObject "ADODB.Connection"
$objCommand = New-Object -ComObject "ADODB.Command"
$objConnection.Open("Provider=ADsDSOObject;")
$objCommand.ActiveConnection = $objConnection
$objCommand.CommandText = $strQuery
$objRecordSet = $objCommand.Execute()
Do
{
$objRecordSet.Fields.item("name").Value
$objRecordSet.Fields.item("samaccountname").Value
$objRecordSet.MoveNext()
}
Until ($objRecordSet.eof)
$objConnection.Close() |
Partager