Myles

Myles

  • NA
  • 2
  • 0

Error message "The directory service is unavailable"

Apr 22 2008 12:34 PM

Hello,

I am building an asp.net website that does many things. One of them is to check if a particular group is a valid group in active directory. If it can be found then it returns a true boolean and if it can not be found it returns a false.

Unfortunately i have received various error's so far and have been able to get passed them but am now stuck with this

"

The directory service is unavailable.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The directory service is unavailable."

My code look like

public bool DLExists(string DLName)
    {

DirectoryEntry de = new DirectoryEntry(LDAP://OU=xxx,OU=xxx,OU=xxx,DC=xxx,DC=xxx,DC=xxx);

        DirectorySearcher ds = new DirectorySearcher(de);
        ds.SearchScope = SearchScope.Subtree;

        ds.Filter = "(objectCategory=group)(samaccountname= " + DLName + ")";
       

        SearchResultCollection results = ds.FindAll();
      
        if (results.Count > 0)
        {
            return true;
        }
        else
        {
            return false;
        }    

}

 

I am at a loss to think of what else i can do to get this to work having tried all manners of privilages and access rights.

Any help gratefully received.

Myles