Counting results in Object

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
I have a small application that I am using to get some information out of Active Directory. I am running this task on a different thread because sometimes it can be a timely process. I need a way to count all the results in the .findone() function before
I start looping through the results of the search so that I can report this number to my application main form. Thanks so much for any help in advance.





<div style="color:black; background-color:white
<pre><span style="color:blue Private <span style="color:blue Sub BackgroundWorker1_DoWork(<span style="color:blue ByVal sender <span style="color:blue As System.Object, <span style="color:blue ByVal e <span style="color:blue As System.ComponentModel.DoWorkEventArgs) <span style="color:blue Handles BackgroundWorker1.DoWork
<span style="color:blue Dim GroupSearcher <span style="color:blue As <span style="color:blue New DirectorySearcher
<span style="color:blue Dim resultsarray(6) <span style="color:blue As <span style="color:blue String

<span style="color:blue Dim GroupSearchRoot <span style="color:blue As <span style="color:blue New DirectoryEntry(<span style="color:#a31515 "LDAP://DC=root,DC=domain,DC=org")

<span style="color:blue With GroupSearcher
.SearchRoot = GroupSearchRoot
.Filter = <span style="color:#a31515 "(&(ObjectClass=Group)(CN=" & TextBox1.Text & <span style="color:#a31515 "))" <span style="color:green <<<Group Name
<span style="color:blue End <span style="color:blue With

<span style="color:blue Dim Members <span style="color:blue As <span style="color:blue Object = GroupSearcher.FindOne.GetDirectoryEntry.Invoke(<span style="color:#a31515 "Members", <span style="color:blue Nothing) <span style="color:green <<< Get members




<span style="color:blue For <span style="color:blue Each Member <span style="color:blue As <span style="color:blue Object <span style="color:blue In <span style="color:blue CType(members, IEnumerable) <span style="color:green <<< loop through members
<span style="color:blue Dim CurrentMember <span style="color:blue As <span style="color:blue New DirectoryEntry(Member) <span style="color:green <<< Get directoryentry for user

resultsarray(0) = CurrentMember.Properties.Item(<span style="color:#a31515 "displayName").Value
resultsarray(1) = CurrentMember.Properties.Item(<span style="color:#a31515 "samAccountName").Value
resultsarray(2) = CurrentMember.Properties.Item(<span style="color:#a31515 "mail").Value
resultsarray(3) = CurrentMember.Properties.Item(<span style="color:#a31515 "department").Value
resultsarray(4) = CurrentMember.Properties.Item(<span style="color:#a31515 "title").Value
resultsarray(5) = CurrentMember.Properties.Item(<span style="color:#a31515 "manager").Value
resultsarray(6) = CurrentMember.Properties.Item(<span style="color:#a31515 "company").Value
BackgroundWorker1.ReportProgress(0, resultsarray)
<span style="color:blue Next
<span style="color:blue End <span style="color:blue Sub
[/code]

<br/>
<br/>

<br/>
<br/>

View the full article
 
Back
Top