Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DirectorySearcher - Filter for wildcards

2,578 views
Skip to first unread message

Jase

unread,
Apr 14, 2007, 1:32:52 AM4/14/07
to
I am trying to make a short list of users matching a wildcard (eg : any
usernames that contain 'ab')

From what i can currently see the only way is to pull back all records and
then cycle through them doing a compare.
Unforuently this is dealing with around 9,000 records, so it adds a lot of
delay.

any known ways of applying a filter on
(Name/sAMAccountName/givenName/description) etc that coutain a string ?

Richard Mueller [MVP]

unread,
Apr 14, 2007, 10:06:24 AM4/14/07
to
Jase wrote:

You can use the "*" wildcard character in an LDAP query. For example:

(&(objectCategory=person)(objectClass=user)(givenName=*ab*))

This will work for the attributes you list. However, wildcards cannot be
used with DN attributes, like distinguishedName or memberOf. It's best to
use "*" only at the end of strings. Using "*" at the beginning or in the
middle requires more processing, but it can be done, and is still probably
faster than returning more records.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


Jase

unread,
Apr 16, 2007, 7:10:21 PM4/16/07
to
Thanks Heaps

It did the job

"Richard Mueller [MVP]" <rlmuelle...@ameritech.nospam.net> wrote in
message news:OF$446pfH...@TK2MSFTNGP04.phx.gbl...

0 new messages