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 = "Server1";
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());
}
}
}
}