Re: LDAP query for the entire domain

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm using a proprietary tool that expects the LDAP query to conform to
syntax standards which is one of the reasons I'm having problems with the
structure.

Thanks.

"Paul Williams [MVP]" <ptw2001@xxxxxxxxxxx> wrote in message
news:OuOS2RD2GHA.3476@xxxxxxxxxxxxxxxxxxxxxxx
What are you using to perform the search?

If via ADO, you'd do something like this (VB Script):

set oRootDse=getObject("LDAP://RootDSE";)
set oConn=createObject("ADODB.Connection")
set oComm=createObject("ADODB.Command")

oConn.provider="ADsDSOObject"
oConn.open"Active Directory Provider"
oComm.activeConnection=oConn

sADsPath= "<LDAP://"&oRootDse.get("defaultNamingContext")&">;"
sFilter = "(&(objectCategory=person)(objectClass=user)(pager=123321));"
sAttrs = "ADsPath,sAMAccountName,cn,distnguishedName;"
sScope = "SubTree"

sQuery = sADsPath & sFilter & sAttrs & sScope

oComm.commandText = sQuery
oComm.properties("Page Size") = 100
oComm.properties("Size Limit") = 10000
oComm.properties("Cache Results") = false

set oRs=oComm.execute

if(isNull(oRs))then
' nothing came back
else
if(not oRs.eOF)then
' whatever
end if
end if


If using LDP, you simply provide the base DN and the query and ensure
subtree is seleced.

If using ADFIND, you run:

adfind -default -f
"&(objectCategory=person)(objectClass=user)(pager=123321)" samaccountname
cn


--
Paul Williams
Microsoft MVP - Windows Server - Directory Services
http://www.msresource.net | http://forums.msresource.net





.



Relevant Pages

  • Re: LDAP query for the entire domain
    ... you'd do something like this (VB Script): ... oConn.open"Active Directory Provider" ... subtree is seleced. ... If using ADFIND, you run: ...
    (microsoft.public.windows.server.active_directory)
  • Re: Creating a custom query in AD Users and Computers
    ... I've used joeware utilities. ... Computers, if possible. ... So in a tool like adfind (www.joeware.net - go download it now, ... >> Trying to create a custom LDAP query in ADUC that returns all computer ...
    (microsoft.public.windows.server.active_directory)
  • Re: List LegacyExchangeDN for each mailbox store
    ... do an LDAP query with the tool of your choice and filter on ... LegacyExchangeDn ... I prefer adfind ...
    (microsoft.public.exchange.admin)