AD LDS slow on first access - Why?

1k views Asked by At

I have an ADLDS instance setup on a local machine (Windows Server 2008 R2 box) for a new application and have knocked up some .Net code to access it. This is one of the functions i'm testing, as you can see its fairly simple stuff.

Dim MyLdapUri As New Uri(searchRoot)

Using MyContext As New PrincipalContext(ContextType.ApplicationDirectory,
                                         MyLdapUri.Authority,
                                         MyLdapUri.LocalPath.Substring(1), ContextOptions.SimpleBind,
                                         strUsername, strPassword)
        Return UserPrincipal.FindByIdentity(MyContext, IdentityType.Name, username)
    End Using

One thing i'm finding happening repeatedly is a ~18s delay on the first time I call this or any other function to access the instance from a test bed application. Subsequent calls made to the AD LDS instance are in the order of 40ms. Once you leave the instance unqueried for a few minutes then calls go back to taking 18s on the first call.

I can't find anything untoward in the event logs. I've also tried connecting to the instance different ways (simple bind to a user defined in the instance as above, using both local and domain Windows accounts) and this 18s additional delay on the first hit always happens. Can anyone give me any pointers to what causes this and/or how I might go about diagnosing/fixing it?

1

There are 1 answers

3
JPBlanc On

This can be due to the way you authenticate to your server.

Is the server on which you install ADLDS in a domain controller?

Is your client computer in the same domain as your server?

How you client computer resolve the DNS part of your URI?

  • In your case you replace LDAP://myserver by LDAP://myserver.ourdomain.local.