473,395 Members | 1,442 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,395 software developers and data experts.

AD DirectorySearcher problem with SearchResultCollection class

I have 2 containers with objects. The veterans container contains
unique objects. Each of those objects can have 1 or more corresponding
card objects in the cards container.

VeteranCN is formatted (SSN-LastName)
CardsCN is formatted (SSN-LastName-# OR SSN-LastName-#CNFblahblahblah)
(the # is the card number)

I have the following code, which searches a container for objects. It
creates the value that will be used for the next card object by
querying the cards for that user and adding 1 to it which will be a new
object (the creation of the object is done in other code not shown -
this is just to figure out what the new object will be called). Right
now, I am just getting a count of the number of results from the query
and adding 1 to it - the problem with that is the results may include
error objects (formatted SSN-LastName-#CNF) so using the Count of the
results will give me the wrong number. For example:
The query results could be:
123456789-Smith-1
123456789-Smith-2
123456789-Smith-3
123456789-Smith-3CNFnjrgnelrkjgne489t3hth
123456789-Smith-4
123456789-Smith-5

If the above were the LDAP query results, my code would name the new
object 123456789-Smith-7 and NOT 123456789-Smith-6 which it SHOULD be.

So basically I need to modify my code to pull the highest number from
the results. I think you would use the Item member to somehow loop
through the SearchResultsCollection, but I'm clueless how to do that.
Any suggestions or how this can be done would be appreciated. Thanks


Dim oSearcher As DirectorySearcher = New DirectorySearcher(oroot)
Dim oResults As SearchResultCollection
Dim oResult As SearchResult

'gets the AD objects
oSearcher.PropertiesToLoad.Add("cn")

oSearcher.Filter = "(cn=" & AllRecords.Rows(currentrow)("VeteranCN") &
"*" & ")"
oResults = oSearcher.FindAll

'create Cards CN based on what the highest current Cards CN is
If oResults.Count < 1 Then
AllRecords.Rows(currentrow)("NewCardsCN") =
AllRecords.Rows(currentrow)("VeteranCN") & "-1"
End If

If oResults.Count = 1 Then
AllRecords.Rows(currentrow)("NewCardsCN") =
AllRecords.Rows(currentrow)("VeteranCN") & "-2"
End If

If oResults.Count > 1 Then
AllRecords.Rows(currentrow)("NewCardsCN") =
AllRecords.Rows(currentrow)("VeteranCN") & "-" & (oResults.Count + 1)
End If

Mar 22 '06 #1
1 1987
If it possible to create a search filter that excludes results where
CNF is anywhere in the CN, but still contains the search criteria?

Mar 22 '06 #2

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

Similar topics

0
by: Jayant Sane | last post by:
I am trying to search a user object that is located in a domain that is sub-ordinate to the one from where I begin my search. For eg. I have the domains as DC=corp,DC=company,DC=com and...
1
by: Sezgin Rafed | last post by:
Hi everyone, I need to select Users from 2 Domains - one the User has logged into and a second one, which is a trusted Domain. There is no problem selecting Users from the Domain the User has...
2
by: Jason S | last post by:
Group, I'm hoping someone can shed some light on active directory search pagination for me. For the DirectorySearcher class there are several methods for paging (.PageSize,...
4
by: cameron | last post by:
I have always been under the impression that LDAP was optimized for speed. Fast queries, fast access, slower writes. I have a block of data in LDAP and in SQL. Exact same data. The query is fast...
1
by: Jay | last post by:
I need to add a parameter to a directorysearcher.filter rather than using hard-coded text. I have the following code that finds all members of an AD group and then for each of those results tries...
0
by: Andrew124 | last post by:
Can anyone tell me why the code below returnes oX80005000 Unknown Error on W2K Advanced Server but doesn't work on W2K SBS: DirectoryEntry tmproot = new DirectoryEntry(ADPrefix +...
2
by: dhnriverside | last post by:
Hi I'm getting the following error in my code... "Exception Details: System.Runtime.InteropServices.COMException: The server does not support the requested critical extension" Here's the...
6
by: Celldss | last post by:
I'm doing a standard AD query to retrieve a list of workstations that match certain criteria. I would like to iterate through that list and see if the workstations are still on the network and have...
2
by: Jim in Arizona | last post by:
I'm trying to do a check to see if a specific active directory user account exists in active directory AND a specific group. I can't seem to get the filter down right. I can do this to find a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.