Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Active Directory - Search filter optimization

Posted on 2010-08-17
4
Medium Priority
?
866 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

972 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