userPrincipalName登录时LDAP连接速度慢

时间:2013-07-01 08:32:53

标签: c# active-directory ldap

在应用程序中,我们最近将登录名从sAMAccountname更改为UserPrincipaleName。 (原因:20个字符的限制)

一切正常,但连接到AD / ldap时速度很慢。但是如果我在DirectoryEntry路径中使用ip地址,它的连接速度非常快。

请看一下这段代码示例。我确实测试了不同顺序的代码块,以排除缓存。但结果保持不变。对于故障转移和负载平衡,我想使用域名而不是IP地址。

有人知道是什么原因造成了我所面临的延迟吗?

 //login with sAMAccountname + FQDN => 1 second
DirectoryEntry d1 = new DirectoryEntry("LDAP://abc.local/CN=AdminF,OU=Users,DC=abc,DC=local", "admin.123f", "password");
Console.WriteLine("d1 {0} {1}", d1.Properties["DisplayName"][0], DateTime.Now - sttime);

sttime= DateTime.Now;
//login with userPrincipaleName + ip address => 1 second
DirectoryEntry d2 = new DirectoryEntry("LDAP://10.xx.xx.1/CN=AdminF,OU=Users,DC=abc,DC=local", "admin.f@abc.local", "password");
Console.WriteLine("d2 {0} {1}", d2.Properties["DisplayName"][0], DateTime.Now - sttime);

sttime= DateTime.Now;
//login with userPricipaleName + FQDN //=> 30-63 seconds!!!!
DirectoryEntry d3 = new DirectoryEntry("LDAP://abc.local/CN=AdminF,OU=Users,DC=abc,DC=local", "admin.f@abc.local", "password");
Console.WriteLine("d3 {0} {1}", d3.Properties["DisplayName"][0], DateTime.Now - sttime); 

// user admin.f@abc.local is the same user as admin.123f. 

0 个答案:

没有答案