8

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?

Terry Gardner
  • 10,957
  • 2
  • 28
  • 38
bigfatron
  • 81
  • 1

1 Answers1

4

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.
micahtan
  • 18,530
  • 1
  • 38
  • 33
JPBlanc
  • 70,406
  • 17
  • 130
  • 175
  • 1
    In the euphoria of figuring this out I forgot to update it for several months! The issue appears to be some quirk where the host name in the uri being used had to be the full LDAP://myserver.ourdomain.local rather just LDAP://myserver. Odd, and especially so as everything is on the same domain but seems to work sweet as a nut afterwards. We also had a similar thing come up for uris used in WCF calls. – bigfatron Aug 09 '12 at 09:05
  • I had the same exact problems occurring every minutes. I've searched for hours until I found your post. Thanks a whole lot !!!!!!! – Vincent Jan 21 '15 at 09:35
  • So you can click the question as useful even if you don't click the answer as usefull. – JPBlanc Jan 21 '15 at 11:05