使用 NetBios 名称的受信任域的 PrincipalContext.ValidateCredentials 速度较慢

编程入门 行业动态 更新时间:2024-10-26 14:33:10
本文介绍了使用 NetBios 名称的受信任域的 PrincipalContext.ValidateCredentials 速度较慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个使用 System.DirectoryServices.AccountManagement 针对 Active Directory 验证凭据的服务.我需要针对本地域和受信任域验证凭据.在我的计算机上运行时,本地域和受信任域的验证凭据的响应时间都很快.当我将此服务移至我们的服务器时,本地域响应很快,但受信任域响应非常慢(20 - 30 秒).

I've created a service that validates credentials against Active Directory using System.DirectoryServices.AccountManagement. I need to validate credentials against the local domain as well as a trusted domain. The response time for validating credentials is fast for both the local and trusted domain when run on my computer. When I move this service to our server, the local domain response is fast however, the trusted domain response is very slow (20 - 30 seconds).

我还发现,如果我将 PrincipalContext 中的域名从 NetBios 名称更改为 DNS 名称,它可以纠正服务器上的性能问题.

I've also found that if I change the domain name in the PrincipalContext from the NetBios name to the DNS name it corrects the the performance problem on the server.

这里有一些例子

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

在服务器上,使用 NetBios 名称执行上述操作需要 20-30 秒

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)

使用 DNS 名称,响应时间为 0-2 秒

Using the DNS name the response is 0-2 seconds

关于需要在服务器上设置什么以使用 NetBios 名称加速此操作的任何想法?

Any ideas on what needs to be setup on the server to speed this up using the NetBios name?

推荐答案

众所周知,NetBIOS 在大网络中速度很慢.这里解释 NetBIOS 名称解析的工作原理.通常,Windows 会按以下顺序解析 NETBIOS 名称.

NetBIOS is notoriously slow in the big network. Here explains how the NetBIOS name resolution works. Normally, Windows tris to resolve the NETBIOS name in the following order.

  • 本地缓存
  • lmhosts 文件
  • WINS 服务器
  • 网络广播
  • 因此,您可以看到可以提高 NetBIOS 名称解析速度的一件事是编辑服务器上的 lmhosts 文件,这样您就可以完全摆脱网络问题.按照这个 Microsoft KB 将您的域和 PDC 添加到您的 lmhosts 文件中.

    So, you can see one thing that you can improve the NetBIOS name resolution speed is to edit the lmhosts file on your server, so that you can take the network completely out of the equation. Follow this Microsoft KB to add your domain and PDC to your lmhosts file.

    更多推荐

    使用 NetBios 名称的受信任域的 PrincipalContext.ValidateCredentials 速度较慢

    本文发布于:2023-11-17 05:16:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1608955.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:较慢   速度   名称   NetBios   ValidateCredentials

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!