在我的开发机器上,我有一系列 VM。其中之一是域控制器。域控制器确实在工作,因为如果不对其进行身份验证,我就无法登录到其他 VM。
我正在尝试针对此 DC 测试 LDAP 查询,但一直失败
我的域控制器树看起来像:
- 直流机器名称
= ESDEV-DC01
- 活动目录名称 =
ESDEV.COM
- 目标节点的规范名称 =
ESDEV.COM/Users
我的子树目标看起来像:
- 属性名称 = objectCategory
- 属性值 = CN=Person,CN=Schema,CN=Configuration,DC=ESDEV,DC=COM
我的参数是:
- 目录路径 =
"LDAP://OU=Users, DC=ESDEV-DC01,DC=ESDEV,DC=Com"
- 搜索过滤器 =
"(&(objectCategory=Person))"
问题:
我不断收到“服务器上没有这样的对象”。
- 这是否意味着它正在查找服务器目录?
- 为什么查询失败?
- LDAP 查询是否区分大小写?
我的控制台应用程序代码如下所示:
我认为没有这篇文章可以回答我的问题,但是对于那些关心我用来测试查询的代码的人......
namespace LDAPQueryTester
{
class Program
{
static void Main(string[] args)
{
try
{
string directoryPath = ConfigurationManager.AppSettings["DirectoryPath"];
string searchFilter = ConfigurationManager.AppSettings["SearchFilter"];
DirectoryEntry rootEntry = new DirectoryEntry(directoryPath);
DirectorySearcher srch = new DirectorySearcher(rootEntry);
srch.SearchScope = SearchScope.Subtree;
if (searchFilter.Length > 0)
{
srch.Filter = searchFilter;
}
SearchResultCollection res = srch.FindAll();
if (res.Count <= 0)
{
Console.WriteLine("Your query did NOT return results");
}
else
{
Console.WriteLine("Your query returned results");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
Console.ReadLine();
}
}
}