Re: Querying AD with the LIKE operator



I guess I will just have to return all computers then parse them out.
Thanks!

Dan
"Richard Mueller [MVP]" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:u46Kd8xjFHA.3608@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> Wildcards are not allowed when filtering/querying on distinguishedName.
Only
> exact matches are recognized. This is true of any attribute with "DN"
> syntax.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
> "Dan White" <Dan.White@xxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:e922DOwjFHA.3656@xxxxxxxxxxxxxxxxxxxxxxx
> > I have a weird problem querying AD for computer accounts.
> >
> > I am trying to query AD for any computer in any OU that contains
"server"
> in
> > the name of the OU.
> >
> > EG: CN=cdecitrix9,OU=CAN,OU=!Citrix,OU=Servers,DC=MyDomain,DC=com
> > CN=abccwrk1,OU=CAN,OU=Servers,DC=MyDomain,DC=com
> >
> > We have several nested OU's that I need to enumerate.
> >
> > Here code that searches the "name" attribute of AD computers:
> > '<><><><><><><><><><><><><><><><><><><><><><>
> > Const ADS_SCOPE_SUBTREE = 2
> >
> > Set objConnection = CreateObject("ADODB.Connection")
> > Set objCommand = CreateObject("ADODB.Command")
> > objConnection.Provider = "ADsDSOObject"
> > objConnection.Open "Active Directory Provider"
> >
> > Set objCommand.ActiveConnection = objConnection
> > objCommand.CommandText = "Select distinguishedName,Name from
> > 'LDAP://DC=MyDomain,DC=com' where objectClass='computer' and name =
> > '*MyComp*'"
> > objCommand.Properties("Page Size") = 1000
> > objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> > Set objRecordSet = objCommand.Execute
> > objRecordSet.MoveFirst
> >
> > Do Until objRecordSet.EOF
> > Wscript.Echo objRecordSet.Fields("distinguishedName").Value
> > objRecordSet.MoveNext
> > Loop
> > '<><><><><><><><><><><><><><><><><><><><><><>
> >
> > The above looks (starting at the root of the domain) for computers that
> have
> > the string "MyComp" somewhere in their name. The above script works as
> > expected.
> >
> > If I change the query command to:
> >
> > objCommand.CommandText = "Select distinguishedName,Name from
> > 'LDAP://DC=MyDomain,DC=com' where objectClass='computer' and
> > distinguishedName = '*MyComp*'"
> >
> > It doesn't work. You would think "distinguishedName" would return the
same
> > set of computers but it only returns and empty data set.
> >
> > Any ideas?
> >
> > Thanks,
> >
> > Dan
> >
> >
>
>


.



Relevant Pages

  • Re: Local Security Settings
    ... > properties and that all the domain computers point only to the domain ... > controller as their preferred dns server. ... > dcdiag [domain controller only] and netdiag to check for the health of your ... > "Dan" wrote in message ...
    (microsoft.public.win2000.security)
  • Re: file sharing
    ... Two wireless laptops running XP Home, ... >>All the computers access the internet properly. ... >>service is running, firewall is off, guest account is active. ...
    (microsoft.public.windowsxp.network_web)
  • RE: Home network inter-connectivity
    ... "Dan N" wrote: ... > and attempted to set up a Home/Small business network set up as I have ... > I've done this seemlessly in the past using the same computers. ... The laptop (which I have not changed anything on for ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Cell phones and safety.
    ... I taught myself a lot about computers when I got my first one ... in 1994 by reading computer newsgroups and learning about operating ... believe Bill, and that he might not be telling the truth here. ... So Bill appears and then Dan follows and warns us not to believe Bill. ...
    (soc.senior.issues)
  • Re: xp home rds password
    ... Dan wrote: ... as I am only a home user and only use the computers for home ... The domain is not required but an Administrator account and password is. ...
    (microsoft.public.internet.netmeeting)