首页 > 解决方案 > 使用 DirectoryEntry / DirectorySearcher 实例化域

问题描述

我想Domain通过DirectoryEntry. 理想情况下,像 -

      private static DirectoryEntry MakeDirectoryEntry(string target)
      {
         return new DirectoryEntry(target)
         {
            AuthenticationType = AuthenticationTypes.Secure | AuthenticationTypes.SecureSocketsLayer
         };
      }

      private static Domain GetDomain(string path)
      {
         var entry = MakeDirectoryEntry(path);
         var searcher = new DirectorySearcher(entry);

         // what to put here? cannot use Domain.GetDomain

         return null;
      }

不能使用Domain.GetDomain,因为默认情况下它通过端口389默认的非 SSL LDAP 端口)进行通信,并且我将在这个远程端口被客户端机器阻止作为出站防火墙规则的环境中工作.

有人知道如何在Domain不利用的情况下以某种方式实例化 aDomain.GetDomain(DirectoryContext)吗?

标签: c#.netactive-directory

解决方案


推荐阅读