473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Speeding up a Directory Search Process


I having trouble querying for users that have changed, when I have a node that have over 750 users. It takes way to long over 1 hour, if it does return users. How can I improve this?

objADSDirEntry = New DirectoryEntry(sInADSADsPath, strADSUserName, strADSPassword, AuthenticationTypes.ServerBind)
ObjADSDirSearcher = New DirectoryServices.DirectorySearcher(objADSDirEntry )
Err.Clear()
ObjADSDirSearcher.Filter = "(&(|(objectClass=user)(objectClass=group)(objectC lass=contact))(&(uSNChanged>=" & LastMod & ")(uSNChanged<=" & NewLastMod & ")))"
'ObjADSDirSearcher.PageSize = 1000
ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)
For Each objSearchResult In ObjADSDirSearcher.FindAll
objadsDirEntry2 = objSearchResult.GetDirectoryEntry
Thanks

Robert
Nov 20 '05 #1
4 1726
Take a look at this whitepaper:

http://msdn.microsoft.com/library/en...ientadapps.asp

--
Dmitri Gavrilov
SDE, Active Directory Core

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Robert Barnett" <rl*****@att.net> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...

I having trouble querying for users that have changed, when I have a node
that have over 750 users. It takes way to long over 1 hour, if it does
return users. How can I improve this?

objADSDirEntry = New DirectoryEntry(sInADSADsPath, strADSUserName,
strADSPassword, AuthenticationTypes.ServerBind)
ObjADSDirSearcher = New DirectoryServices.DirectorySearcher(objADSDirEntry )
Err.Clear()
ObjADSDirSearcher.Filter =
"(&(|(objectClass=user)(objectClass=group)(objectC lass=contact))(&(uSNChange
d>=" & LastMod & ")(uSNChanged<=" & NewLastMod & ")))"
'ObjADSDirSearcher.PageSize = 1000
ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)
For Each objSearchResult In ObjADSDirSearcher.FindAll
objadsDirEntry2 = objSearchResult.GetDirectoryEntry
Thanks

Robert
Nov 20 '05 #2
I tried a lot of this. It is still pausing after about 500 results. It waits
a long time, for new results. Much more then it intially did.
"Dmitri Gavrilov [MSFT]" <dm*****@online.microsoft.com> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...
Take a look at this whitepaper:

http://msdn.microsoft.com/library/en...ientadapps.asp

--
Dmitri Gavrilov
SDE, Active Directory Core

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Robert Barnett" <rl*****@att.net> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...

I having trouble querying for users that have changed, when I have a node
that have over 750 users. It takes way to long over 1 hour, if it does
return users. How can I improve this?

objADSDirEntry = New DirectoryEntry(sInADSADsPath, strADSUserName,
strADSPassword, AuthenticationTypes.ServerBind)
ObjADSDirSearcher = New DirectoryServices.DirectorySearcher(objADSDirEntry ) Err.Clear()
ObjADSDirSearcher.Filter =
"(&(|(objectClass=user)(objectClass=group)(objectC lass=contact))(&(uSNChange d>=" & LastMod & ")(uSNChanged<=" & NewLastMod & ")))"
'ObjADSDirSearcher.PageSize = 1000
ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)
For Each objSearchResult In ObjADSDirSearcher.FindAll
objadsDirEntry2 = objSearchResult.GetDirectoryEntry
Thanks

Robert

Nov 20 '05 #3
THis is my current code.

ObjADSDirSearcher.Filter =
"(&(|(objectCategory=Person)(objectCategory=Group) )(&(uSNChanged>=" &
LastMod & ")(uSNChanged<=" & NewLastMod & ")))"

ObjADSDirSearcher.SearchScope = SearchScope.OneLevel

sw.WriteLine(ObjADSDirSearcher.Filter)

ObjADSDirSearcher.PageSize = 500

' ObjADSDirSearcher.CacheResults = F

'ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)

' ObjADSDirSearchResults = ObjADSDirSearcher.FindAll

'sw.WriteLine(ObjADSDirSearchResults.Count)

' Parse Users

For Each objSearchResult In ObjADSDirSearcher.FindAll

"Robert Barnett" <rl*****@att.net> wrote in message
news:#S**************@TK2MSFTNGP11.phx.gbl...
I tried a lot of this. It is still pausing after about 500 results. It waits a long time, for new results. Much more then it intially did.
"Dmitri Gavrilov [MSFT]" <dm*****@online.microsoft.com> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...
Take a look at this whitepaper:

http://msdn.microsoft.com/library/en...ientadapps.asp
--
Dmitri Gavrilov
SDE, Active Directory Core

This posting is provided "AS IS" with no warranties, and confers no

rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Robert Barnett" <rl*****@att.net> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...

I having trouble querying for users that have changed, when I have a node that have over 750 users. It takes way to long over 1 hour, if it does
return users. How can I improve this?

objADSDirEntry = New DirectoryEntry(sInADSADsPath, strADSUserName,
strADSPassword, AuthenticationTypes.ServerBind)
ObjADSDirSearcher = New

DirectoryServices.DirectorySearcher(objADSDirEntry )
Err.Clear()
ObjADSDirSearcher.Filter =

"(&(|(objectClass=user)(objectClass=group)(objectC lass=contact))(&(uSNChange
d>=" & LastMod & ")(uSNChanged<=" & NewLastMod & ")))"
'ObjADSDirSearcher.PageSize = 1000
ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)
For Each objSearchResult In ObjADSDirSearcher.FindAll
objadsDirEntry2 = objSearchResult.GetDirectoryEntry
Thanks

Robert


Nov 20 '05 #4
One thing you might consider doing is not using the Count property on the
SearchResultCollection object. The way it works, the collection needs to
enumerate the entire result to get the number of results returned because it
doesn't know the count in advance, so you are basically enumerating twice.
I would avoid using it. It looks like you have the commented out, but it
was sitting there in the code...However, setting CacheResults to False is a
good idea as you only need that if you needed to go back through the
collection.

Otherwise, your filter is not searching on only indexed attributes, so that
part is good. Just out of curiosity, does it go faster if don't use the
upper bound condition on uSNChanged and just look for things newer than the
LastMod value? I'm not sure if your query will work correctly that way or
not.

Another idea to try would be to remove the objectCategory clauses in the
filter and just skip the objects that are returned that aren't the right
type. I'm not sure if that would be faster or not, but it is worth a shot.

Joe K.

"Robert Barnett" <rl*****@att.net> wrote in message
news:e7**************@TK2MSFTNGP11.phx.gbl...
THis is my current code.

ObjADSDirSearcher.Filter =
"(&(|(objectCategory=Person)(objectCategory=Group) )(&(uSNChanged>=" &
LastMod & ")(uSNChanged<=" & NewLastMod & ")))"

ObjADSDirSearcher.SearchScope = SearchScope.OneLevel

sw.WriteLine(ObjADSDirSearcher.Filter)

ObjADSDirSearcher.PageSize = 500

' ObjADSDirSearcher.CacheResults = F

'ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)

' ObjADSDirSearchResults = ObjADSDirSearcher.FindAll

'sw.WriteLine(ObjADSDirSearchResults.Count)

' Parse Users

For Each objSearchResult In ObjADSDirSearcher.FindAll

"Robert Barnett" <rl*****@att.net> wrote in message
news:#S**************@TK2MSFTNGP11.phx.gbl...
I tried a lot of this. It is still pausing after about 500 results. It

waits
a long time, for new results. Much more then it intially did.
"Dmitri Gavrilov [MSFT]" <dm*****@online.microsoft.com> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...
Take a look at this whitepaper:

http://msdn.microsoft.com/library/en...ientadapps.asp
--
Dmitri Gavrilov
SDE, Active Directory Core

This posting is provided "AS IS" with no warranties, and confers no

rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Robert Barnett" <rl*****@att.net> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...

I having trouble querying for users that have changed, when I have a node that have over 750 users. It takes way to long over 1 hour, if it does
return users. How can I improve this?

objADSDirEntry = New DirectoryEntry(sInADSADsPath, strADSUserName,
strADSPassword, AuthenticationTypes.ServerBind)
ObjADSDirSearcher = New

DirectoryServices.DirectorySearcher(objADSDirEntry )
Err.Clear()
ObjADSDirSearcher.Filter =

"(&(|(objectClass=user)(objectClass=group)(objectC lass=contact))(&(uSNChange
d>=" & LastMod & ")(uSNChanged<=" & NewLastMod & ")))"
'ObjADSDirSearcher.PageSize = 1000
ObjADSDirSearcher.ServerTimeLimit = TimeSpan.FromMinutes(3)
For Each objSearchResult In ObjADSDirSearcher.FindAll
objadsDirEntry2 = objSearchResult.GetDirectoryEntry
Thanks

Robert



Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
1
by: Spamtrap | last post by:
I only do occasional Perl programming and most things I write are short processes. I have something I'm working on that is scanning a text file with about 15 million lines and trying to extract...
2
by: Anna Koloskova | last post by:
Hi, I'm referring to the question of Amadelle (13 october 2004), please see ...
9
by: mfyahya | last post by:
Hi, I'm new to databases :) I need help speeding up select queries on my data which are currently taking 4-5 seconds. I set up a single large table of coordinates data with an index on the fields...
2
by: ALI-R | last post by:
I am using the follwoing code to get all files which have txt as an extension but I get an error that your search pattern is not correct.it seems this fuction dosn't accept "*.txt" as search...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
18
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.