csharp 找到AD默认的defaultNamingContext

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 找到AD默认的defaultNamingContext相关的知识,希望对你有一定的参考价值。

using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryEntry deRoot = new DirectoryEntry("LDAP://10.10.2.11/RootDSE","administrator","P@ssw0rd");

            if (deRoot != null)
            {
                string defaultNamingContext = deRoot.Properties["defaultNamingContext"].Value.ToString();
                Console.WriteLine(defaultNamingContext);
                Console.WriteLine("成功输出了");
            }
            else
            {
                Console.WriteLine("找不到");
            }
            Console.ReadKey();
        }
    }
}

以上是关于csharp 找到AD默认的defaultNamingContext的主要内容,如果未能解决你的问题,请参考以下文章