• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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