Get certain objects from AD

Started by Orionbelt, February 17, 2015, 01:34:56 PM

Previous topic - Next topic

Orionbelt

Hi all,
   I am trying to get objects from AD. But i would like to get only computers which start as L,D,USD,USL,P.


;  Get the domain DN with a server-less ADSI path.
domain = dsGetProperty("LDAP://rootDSE"  , "defaultNamingContext")      ; DC=microsoft,DC=mill,DC=com
sPath = "LDAP://CN=Computers,":domain              ; LDAP://CN=Computers,DC=microsoft,DC=mill,DC=com
lValues = dsGetChldPath(sPath, "")                              ; ALL Objects from path sPath

i can loop valuse of IValues and extract single object. but how can i say that if computer starts with L OR D OR USD OR USL OR R than continue otherwise keep looping.

td

The dsFindPath function is your ADSi extender friend

Code (winbatch) Select
lComputers = dsFindPath(strYourContainerPath, "(&(objectCategory=Computer)(| (cn=l*)(cn=d*)(cn=usd*)(cn=usl*)(cn=r*)))")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Orionbelt