deldzogeobhed
New Member
Please let me know how could I shorten response time of the following code.<BR>I have a DataGrid, a button and a textBox for the time result display.<BR>Thanks in advance!!!<BR>Ramiro<BR><BR>Imports System.DirectoryServices<BR>Public Class Form4<BR> Inherits System.Windows.Forms.Form<BR><BR> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<BR>Handles Button1.Click<BR><BR> Dim dt As New DataTable()<BR> Dim ss As DateTime = DateTime.Now<BR> TextBox1.Text = DateTime.Now<BR> dt.Columns.Add("UserName")<BR> dt.Columns.Add("FullName")<BR> dt.Columns.Add("OrgUnit")<BR> dt.Columns.Add("mail")<BR><BR> Dim entry As New DirectoryEntry("LDAP://FNDR_NT1/OU=FNDROrg,DC=FNDR_NT1")<BR> Dim mySearcher As New DirectorySearcher(entry)<BR> Dim res As SearchResult<BR><BR> Dim cc As String<BR> cc = "(objectClass=user)"<BR> mySearcher.Filter = (cc)<BR><BR> For Each res In mySearcher.FindAll<BR> Dim dr As DataRow<BR> dr("UserName") = res.GetDirectoryEntry.Properties("sAMAccountName").Value<BR> dr("FullName") = res.GetDirectoryEntry.Name.Substring(3)<BR> dr("OrgUnit") = res.GetDirectoryEntry.Parent.Name.Substring(3)<BR> dr("TipoObj") = res.GetDirectoryEntry.SchemaClassName<BR> dr("mail") = res.GetDirectoryEntry.Properties("mail").Value<BR> dt.Rows.Add(dr)<BR> Next<BR> Me.DataGrid1.DataSource = dt<BR> TextBox1.Text = DateTime.Now.Subtract(ss).ToString<BR> End Sub<BR>End Class<BR>