FindByIdentity

编程入门 行业动态 更新时间:2024-10-25 21:22:19
本文介绍了FindByIdentity - 性能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

下面code正常工作,从各种对我们的域的机器。

The following code works fine from a variety of machines on our domain.

var context = new PrincipalContext(ContextType.Domain); var principal = UserPrincipal.FindByIdentity(context, @"domain\username")

但是,如果我运行一个机器,是不是在域在此类似code,它的工作原理,但FindByIdentity线采用2 +秒。

However, if I run this similar code on a machine that is not on a domain, it works but the FindByIdentity line takes 2+ seconds.

var context = new PrincipalContext(ContextType.Machine); var principal = UserPrincipal.FindByIdentity(context, @"machinename\username")

可以这样性能上的差异通过提供特殊参数的PrincipalContext构造和/或FindByIdentity方法来解决?是否有可能被调整在IIS或Windows设置?

最起码,有谁能够告诉我,为什么它可能是在第二个方案中慢?

在code是从ASP.NET MVC 3应用程序在Windows Server 2008上的IIS中承载7.5(综合管线)运行R2。

The code is running from an ASP.NET MVC 3 app hosted in IIS 7.5 (Integrated Pipeline) on Windows Server 2008 R2.

推荐答案

我有同样的问题。试试下面的块code。我不知道为什么,但它的速度更快(忽略第一次登录缓慢建立后VS - 后续登录都被迅速)。看到类似SO质疑Why将使用PrincipalSearcher比FindByIdentity快()?

I had the same problem. Try the below block of code. I don't know why but it's much faster (ignore first time slow login after build in VS - subsequent logins are speedy). See similar SO question Why would using PrincipalSearcher be faster than FindByIdentity()?

var context = new PrincipalContext( ContextType.Machine ); var user = new UserPrincipal(context); user.SamAccountName = username; var searcher = new PrincipalSearcher(user); user = searcher.FindOne() as UserPrincipal;

根本的问题可能有事情做与NetBIOS调用。请参阅ADLDS很慢(往返为\服务器* \ MAILSLOT \ NET \ NETLOGON)

更多推荐

FindByIdentity

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

发布评论

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

>www.elefans.com

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