Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 广告测试工具_C#_Active Directory_Ldap - Fatal编程技术网

C# 广告测试工具

C# 广告测试工具,c#,active-directory,ldap,C#,Active Directory,Ldap,我们使用sharepoint,在SP中,我们有一个人员选择器,可以搜索samaccountname,也可以搜索name。在dev上它工作正常,但在prod上它有时返回重复的结果 我想知道那里是否有一个简单的应用程序,我可以对广告进行查询并查看结果。(可能复制用户真的在一个广告林或其他地方的不同域中 我发现了这个,但它没有c语言的工作示例# 我有两个片段: using System.DirectoryServices.AccountManagement; using System.Director

我们使用sharepoint,在SP中,我们有一个人员选择器,可以搜索samaccountname,也可以搜索name。在dev上它工作正常,但在prod上它有时返回重复的结果

我想知道那里是否有一个简单的应用程序,我可以对广告进行查询并查看结果。(可能复制用户真的在一个广告林或其他地方的不同域中

我发现了这个,但它没有c语言的工作示例#

我有两个片段:

using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;

// Authentication
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, sDn))
{
   // validate the credentials
   bIsValid = pc.ValidateCredentials(sUsr, sPassword);
}

//List users
DirectorySearcher adsSearcher = new DirectorySearcher();
adsSearcher.Filter = string.Format(Parameters.ActiveDirectoryFilter, "*");
try
{
   foreach (SearchResult sr in adsSearcher.FindAll())
   {
       string sUsrName = sr.GetDirectoryEntry().Properties["UserPrincipalName"].Value as string;
       Console.WriteLine(string.Format("User : {0}", sUsrName));
   }
}

当然,它需要两个引用(System.DirectoryServices和System.DirectoryServices.AccountManagement).

您应该使用
ldapsearch
。它是查询目录服务器的标准命令行工具。
ldapsearch
与目录服务器软件一起分发,并且广泛可用。有关更多信息,请参阅。在编写任何其他代码之前,应使用此工具验证参数和假设。