Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Active Directory > Reading from LDAP searchresults

Reply
Thread Tools Display Modes

Reading from LDAP searchresults

 
 
Eric
Guest
Posts: n/a

 
      06-10-2010
Hi,

After I retrieved data from my companies AD, done in less then 1 sec, I want
to read that data into a dataset.

I do that with:
Dim cn() As Object

For Each src As SearchResult In sr
rw = dsData.Tables("managers").NewRow
If src.GetDirectoryEntry().Properties("cn").Value IsNot Nothing Then
cn = src.GetDirectoryEntry.Properties("cn").Value
rw("fullname") = cn(1).ToString
End If
If src.GetDirectoryEntry().Properties("mail").Value IsNot Nothing Then
rw("email") =
src.GetDirectoryEntry().Properties("mail").Value.T oString
End If
dsData.Tables("managers").Rows.Add(rw)
Next
Catch ex As Exception
Me.txtLijst.Text = ex.Message
End Try

It takes up to 20 seconds to read this information from the searchresults
and it's only 21 names.

How can I speed this up?

rg,
Eric

 
Reply With Quote
 
 
 
 
Chris Dent
Guest
Posts: n/a

 
      06-10-2010

If you're only reading values you do not need all those calls to
GetDirectoryEntry, it's quite a heavy operation and exactly why it takes
so long. You only need to call GetDirectoryEntry if you're making
changes to the object in AD.

For Each src As SearchResult In sr
' src.Properties("cn") is a PropertyValueCollection - better check
this test for null values though
If src.Properties("cn") IsNot Nothing Then
' Get the value at the first index, will be 0 for all single-value
properties
cn = src.Properties("cn")(0)
...

If the property is not loaded you would need to take a look at the
DirectorySearcher and the properties you've chosen to load (if any).
Some properties, canonicalName for instance, will not be available
unless you explicitly request it.

Chris

Eric wrote:
> Hi,
>
> After I retrieved data from my companies AD, done in less then 1 sec, I want
> to read that data into a dataset.
>
> I do that with:
> Dim cn() As Object
>
> For Each src As SearchResult In sr
> rw = dsData.Tables("managers").NewRow
> If src.GetDirectoryEntry().Properties("cn").Value IsNot Nothing Then
> cn = src.GetDirectoryEntry.Properties("cn").Value
> rw("fullname") = cn(1).ToString
> End If
> If src.GetDirectoryEntry().Properties("mail").Value IsNot Nothing Then
> rw("email") =
> src.GetDirectoryEntry().Properties("mail").Value.T oString
> End If
> dsData.Tables("managers").Rows.Add(rw)
> Next
> Catch ex As Exception
> Me.txtLijst.Text = ex.Message
> End Try
>
> It takes up to 20 seconds to read this information from the searchresults
> and it's only 21 names.
>
> How can I speed this up?
>
> rg,
> Eric
>
>

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CEICW freezes at configuring firewall John Windows Small Business Server 8 05-11-2010 03:33 AM
No network drive mapping after joining Active Directory ? Patrick Active Directory 29 05-05-2010 12:21 PM
LDAP Issue - LDAP BIND against Windows 2008 DC does not work QuesionVB Active Directory 1 03-24-2010 03:42 PM
Error: Agent failed detecting with reason: 0x80248008 (WSUS client AAM Windows Server 0 12-30-2009 03:26 AM
Performance Tab Reading Wrong? DamienMS Windows Vista Performance 7 06-14-2007 09:38 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59