2

我在两台不同的机器上安装了 AD LDS。其中一台是 Windows 8,另一台是 win 2008。我安装的 AD LDS 配置完全相同。上面的代码适用于 Windows 8,但不适用于 Windows 2008 R2 Server。我需要做什么才能在 Windows 2008 中启用匿名搜索?

DirectoryEntry userEntry = new DirectoryEntry(DIRECTORY_SERVER); // intentionally without user name and password

DirectorySearcher ds = new DirectorySearcher(userEntry);
string accountName = userName.Split(new char[] { Convert.ToChar("\\") })[1];
ds.Filter = ("SAMAccountName=" + accountName);
SearchResult results = null;
try
   {
      results = ds.FindOne();
   }
catch (Exception)
   {
      return false;
   }
4

0 回答 0