• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Very slow directory services lookup

I'm having poor performance with this code block and looking for some assistance on where to start troubleshooting it.

I pass a GUID such as: 781b2e1bf45c4045a48732b83de75e4e

It can take up to 11 seconds to return the DN from this.

From what I understand I'm directly binding to the object, no searching or enumeration.

This is in a lab domain with just a few dozen accounts and few hundred groups.



   
Public Shared Function GetDNfromGUID(ByVal GUID As String) As String
        Dim stopwatch As New Stopwatch
        stopwatch.Start()


        Dim strDNPath As String = ""
        Dim strDN As String

        strDNPath = "GC://<GUID=" & GUID & ">"

        Dim entry As New DirectoryServices.DirectoryEntry(strDNPath)

        Try

            strDN = entry.Properties("distinguishedName").Value.ToString

            Return strDN

        Catch ex As Exception
            Log.l("Error getting DN using GUID: " & GUID & " from path " & strDNPath, ex)
            Return "unknown"

        Finally
            entry.Close()
            entry.Dispose()

          Log.l1("GetDNfromGUID: " & stopwatch.ElapsedMilliseconds, "StopWatch.log", -3)
            stopwatch.Stop()

        End Try

    End Function

Open in new window

0
mooka
Asked:
mooka
1 Solution
 
Miguel OzSoftware EngineerCommented:
Change line 9 to:
String.Format("GC://<GUID={0}>", GUID )

Change line 11 to:
Dim entry As New DirectoryServices.DirectoryEntry(strDNPath)
to
Dim entry As DirectoryEntry = New DirectoryEntry(_path,
 domainAndUsername, pwd, _
 AuthenticationTypes.FastBind)
Check:
http://www.derkeiler.com/Newsgroups/microsoft.public.dotnet.framework.aspnet.security/2006-01/msg00155.html
0
 
mookaAuthor Commented:
Unfortunately these suggestions did not work. I added a new domain controller which responds much faster, I'm blaming hte problem on the DC itself and do not want to invesigate further. Thanks for the suggestions.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now