Solved

Active Directory - Search filter optimization

Posted on 2010-08-17
4
851 Views
Last Modified: 2012-08-14
Hello Experts,

I'm building an ASP.NET webpage that pulls the users info via Active Directory.  Right now it's working, but slower than I'd like.  So I'm trying to optimize my search filter in hopes of speeding up the search.  Right now my search filters is setup like so:

Mysearcher.Filter = "(&(objectCategory=person)(objectClass=user)(samAccountName=" & strNetworkID & "))"

Can anyone help me to tweak this for faster performance?

Thanks,
Moe
0
Comment
Question by:mauricerichard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:mrfixit584
ID: 33454818
The filter is pretty much as lean as it can be. The question is, how much of the tree are you searching, and do you need to search the entire tree? If all of your users are in a sub-OU, you could restrict your search to that OU instead of searching the entire structure.
0
 
LVL 1

Author Comment

by:mauricerichard
ID: 33464251
Hi Mrfixit584,

I'm struggling with Active Directory, so pardon any silly questions.  
Where would I indicate this, in the search filter or DirectoryEntry?

See code sample for examples

Thanks,
Moe
Mysearcher.Filter = "(&(objectCategory=person)(objectClass=user)(samAccountName=" & strNetworkID & "))"

'OR

Dim rootEntry As New DirectoryEntry("LDAP://domain/DC=domainDN,DC=com", "username", "password")

Open in new window

0
 
LVL 2

Accepted Solution

by:
mrfixit584 earned 500 total points
ID: 33562073
It would be part of the LDAP call. instead of LDAP://dc=domain,dc=com, make it more specific. LDAP://ou=myOU,dc=domain,dc=com. For some of my searches, this isn't possible, but if the objects you are searching are in a certain location, you can specify the location so the search doesn't include the entire domain.
0
 
LVL 1

Author Comment

by:mauricerichard
ID: 33599040
Sorry been away from the office.  Great info, thanks very much!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question