jjzjj

FindByIdentity

全部标签

c# - 为什么使用 PrincipalSearcher 会比 FindByIdentity() 更快?

我有这段代码:varcontext=newPrincipalContext(ContextType.Machine);varuser=UserPrincipal.FindByIdentity(context,username);运行大约需要2-3秒。我被推荐使用PrincipalSearcher类重写它:varcontext=newPrincipalContext(ContextType.Machine);varuser=newUserPrincipal(context);user.SamAccountName=username;varsearcher=newPrincipalSear

c# - UserPrincipal.FindByIdentity 权限

我正在尝试使用.NETSystem.DirectoryServices.AccountManagement库来获取特定ActiveDirectory用户的UserPrincipal。我有以下代码:PrincipalContextcontext=newPrincipalContext(ContextType.Domain,"DomainName");userPrincipal=UserPrincipal.FindByIdentity(context,IdentityType.SamAccountName,username);此代码以有效的域用户身份运行,但是当我执行它时出现以下异常:Sy

c# - 有没有办法为 UserPrincipal.FindByIdentity() 启用推荐追踪?

我有一个使用System.DirectoryServices.AccountManagement类的.NET3.5Web应用程序。当我搜索一些用户时,我得到一个PrincipalOperationException:服务器返回了推荐。如果我用我自己的LDAP代码以老派的方式执行此操作,我就可以启用追踪推荐。我需要重写我的代码吗?我的代码是这样的:using(varprincipalContext=newPrincipalContext(ContextType.Domain,null,adPath)){//Findtheprincipalobjectforwhichyouwishtoen

c# - .NET 4.5 UserPrincipal.FindByIdentity (System.DirectoryServices.AccountManagement) 中的错误

在.NET4.5下测试我们的.NET4.0应用程序时,我们遇到了UserPrincipal的FindByIdentity方法的问题。以下代码在.NET4.0运行时中运行时有效,但在.NET4.5下失败:[Test]publicvoidTestIsAccountLockedOut(){conststringactiveDirectoryServer="MyActiveDirectoryServer";conststringactiveDirectoryLogin="MyADAccount@MyDomain";conststringactiveDirectoryPassword="MyAD