Link to home
Create AccountLog in
Avatar of Nobletucky2004
Nobletucky2004

asked on

.Net DirectoryService connection to Novell eDirectory (LDAP)

Can anyone shed some light on to the reason I am getting this error. "System.Runtime.InteropServices.COMException: The specified domain either does not exist or could not be contacted."

 Here is my code I'm using:

...
using System.DirectoryServices;

    public static DirectoryEntry getDirectoryEntry()
    {
        return new DirectoryEntry("LDAP://ldap.mycompaniesname.com, o=baseOrg, ou=scopeUnit", "username", "password");
    }

  public string test()
    {
        string x = string.Empty;

        DirectoryEntry e = LdapUtil.getDirectoryEntry();
        DirectorySearcher src = new DirectorySearcher(e);
        SearchResultCollection r;
        src.Filter = "(*findMe*)";
        r = src.FindAll();

        x = r[1].ToString();
        e.Close();
        src.Dispose();
        r.Dispose();

       return x;
    }
Avatar of ihenry
ihenry

The ldap path seems to be the problem here. How about this one, does it work?

LDAP://ldap.mycompaniesname.com/o=baseOrg, ou=scopeUnit


Henry
Avatar of Nobletucky2004

ASKER

I substitued the first "," with a "/" and received the following:


System.Runtime.InteropServices.COMException: An invalid dn syntax has been specified.

also reversed the forward to back slash and received the first error.
mm..what verson of .NET Framework you are using now?

Just for troubleshooting, if you run this piece of code alone, does this work?

DirectoryEntry entry = new DirectoryEntry();
entry.Path= @"LDAP://ldap.mycompaniesname.com, o=baseOrg, ou=scopeUnit";
entry.AuthenticationTypes = AuthenticationTypes.None;
string name = entry.Name;
Also try this line.
entry.Path= @"LDAP://ldap.mycompaniesname.com/o=baseOrg, ou=scopeUnit";
   public static DirectoryEntry getDirectoryEntry()
    {
        DirectoryEntry e = new DirectoryEntry();
        e.Path = @"LDAP://ldap.companyname.com/o=Org, ou=OrgUnit";
        e.Username = "cn=UserName,ou=OrgUnit,o=Org";
        e.Password = "password";
        e.AuthenticationType = AuthenticationTypes.ServerBind;
        return e;
    }

get the following: System.DirectoryServices.DirectoryServicesCOMException: There is no such object on the server.
This did make the connection to the server though didn't it?

Sorry for the continuous questions and replies I'm a green horn when it comes to LDAP auth.
Try to change the AuthenticationType property to none.
getting the same error as before...should the user name have teh full dn or just the cn?
The error could be caused the ldap path or the user name has a wrong format or both. You can isolate and narrow down the problem by running the code piece by piece.

DirectoryEntry entry = new DirectoryEntry();
entry.Path= @"LDAP://ldap.companyname.com/o=Org, ou=OrgUnit";
entry.AuthenticationTypes = AuthenticationTypes.None;
string name = entry.Name;

If the above code works than the user name will be likely the culprit.
for this above to work anonymous login would have to be allowed on the LDAP correct?
Yup, you meant your directory server does not allow anonymous login to the ou?
yea the above code gave me an
System.DirectoryServices.DirectoryServicesCOMException: There is no such object on the server.
error.

Is the object is is looking for dependent on the AuthType.?
It is hard to know exactly the correct ldap path of the ou or the user name without seeing it directly. Do you have a tool or something that can browse objects in your directory server? you can try the free utility softerra ldap browser. With it you can easily get a complete ldap path of each ldap object.
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
That was actually it...the dn syntax was incorrect...in my haste "cut & paste" bug I actually put the ou value = o.  Thanks for all your help!!