PrincipalContext.ValidateCredentials slows down with a trusted domain using the NetBios name

I created a service that validates credentials in Active Directory using System.DirectoryServices.AccountManagement. I need to check the credentials for the local domain as well as the trusted domain. The response time for credential verification is fast for both the local and the trusted domain when running on my computer. When I transfer this service to our server, the response of the local domain is fast, the response of the trusted domain is very slow (20-30 seconds).

I also found that if I change the domain name in PrincipalContext from NetBios to DNS, it fixes a performance problem on the server.

Here are some examples.

PrincipalContext context = new PrincipalContext(ContextType.Domain, sNetBiosName)
context.ValidateCredentials(sUsername, sPassword)

On the server, the above will take 20-30 seconds using the NetBios name

PrincipalContext context = new PrincipalContext(ContextType.Domain, sDNSName)
context.ValidateCredentials(sUsername, sPassword)

Using a DNS name, the response is 0-2 seconds

Any ideas on what you need to configure on the server to speed this up using the NetBios name?

+3
source share
2 answers

NetBIOS is obviously slower in a large network. This explains how NetBIOS name resolution works. Typically, Windows tris resolves the NETBIOS name in the following order.

  • local cache
  • Lmhosts file
  • WINS Server
  • network broadcasting

So, you can see that you can improve the speed of NetBIOS name resolution by editing the lmhosts file on your server so that you can completely disconnect the network from the equation. Follow this Microsoft KB to add your domain and PDC to the lmhosts file.

+5

, WINS .

0

All Articles