Solved

Active Directory - Search filter optimization

Posted on 2010-08-17
4
839 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
  • 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 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