Slow authentication to LDAP Server on initial login attempt

与世无争的帅哥 提交于 2021-01-29 02:14:53

问题


The application I setup uses an AspNetActiveDirectoryMembershipProvider to an LDAP server with Forms Authentication. The user authenticates properly, but the first time a user tries to log in a new browser window causes a delay of over one minute till it authenticates. If the user logs out of the application (but doesn't close the browser) and tries to log back in it only takes around 6-7 seconds to authenticate.

I figure the second authentication is using a cached connection or socket to make up the initial slow behavior. But how do I get around this problem for the first attempt? Can I somehow initiate a connection to the LDAP server during page load thus saving time during the login process?

Note: I've checked over the LDAP connection string and it's as direct as it's going to get.

        <add name="ADService" connectionString="LDAP://doctor.at.ad.cynwulfdesign.com/CN=Users,DC=at,DC=ad,DC=cynwulfdesign,DC=com" />

...

  <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
      <providers>
          <clear/>
          <add name="AspNetActiveDirectoryMembershipProvider"
               type="System.Web.Security.ActiveDirectoryMembershipProvider,  System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="ADService"
               attributeMapUsername="sAMAccountName"/>
      </providers>
  </membership>

回答1:


I happened across the reason why the LDAP was taking so long. At first, I thought it was a problem within the Active Directory database causing a slow response. But it appears that it needed the LDAP port number to speed things up. Once I added ":389" to the LDAP url it went from 1:07 down to :03 seconds to authenticate. It's amazing what adding a port number can do to increase response time. I would have figured it already knew what the default LDAP port was. Live and learn.

<add name="ADService" connectionString="LDAP://doctor.at.ad.cynwulfdesign.com:389/CN=Users,DC=at,DC=ad,DC=cynwulfdesign,DC=com" />


来源:https://stackoverflow.com/questions/24433182/slow-authentication-to-ldap-server-on-initial-login-attempt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!