Very slow directory services lookup

Posted on 2009-12-30
Last Modified: 2013-11-07
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


        Dim strDNPath As String = ""

        Dim strDN As String

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

        Dim entry As New DirectoryServices.DirectoryEntry(strDNPath)


            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"




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


        End Try

    End Function

Open in new window

Question by:mooka
    LVL 35

    Expert Comment

    by:Miguel Oz
    Change line 9 to:
    String.Format("GC://<GUID={0}>", GUID )

    Change line 11 to:
    Dim entry As New DirectoryServices.DirectoryEntry(strDNPath)
    Dim entry As DirectoryEntry = New DirectoryEntry(_path,
     domainAndUsername, pwd, _
    LVL 29

    Expert Comment

    by:Kumaraswamy R

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now