开发者

Active directory server is not operational. error code 2147016646

New to C#. I am trying to browse AD for a particular OU. I get the following error. error code 2147016646. I tried running the program with higher privl. acct. But still get the same error.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
             string objectPath = "Se开发者_如何转开发rver1";
             try
             {
                if (DirectoryEntry.Exists("LDAP://" + objectPath))
                    Console.WriteLine(objectPath + "exists");
                else
                    Console.WriteLine(objectPath + " does not exists");
            }
            catch (DirectoryServicesCOMException e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }      
    }
}


You will probably have to use something more than just "Server1" for your LDAP path.

Try something like:

string objectPath = "Server1/cn=Users,dc=yourcompany,dc=som";
try
{
   if (DirectoryEntry.Exists("LDAP://" + objectPath))
      Console.WriteLine(objectPath + "exists");
   else
      Console.WriteLine(objectPath + " does not exists");
}

This would check if the default "Users" container on your server exists (or not).

Marc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜