.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;
    }
Nobletucky2004Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ihenryCommented:
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
0
Nobletucky2004Author Commented:
I substitued the first "," with a "/" and received the following:


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

0
Nobletucky2004Author Commented:
also reversed the forward to back slash and received the first error.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

ihenryCommented:
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;
0
ihenryCommented:
Also try this line.
entry.Path= @"LDAP://ldap.mycompaniesname.com/o=baseOrg, ou=scopeUnit";
0
Nobletucky2004Author Commented:
   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.
0
ihenryCommented:
Try to change the AuthenticationType property to none.
0
Nobletucky2004Author Commented:
getting the same error as before...should the user name have teh full dn or just the cn?
0
ihenryCommented:
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.
0
Nobletucky2004Author Commented:
for this above to work anonymous login would have to be allowed on the LDAP correct?
0
ihenryCommented:
Yup, you meant your directory server does not allow anonymous login to the ou?
0
Nobletucky2004Author Commented:
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.?
0
ihenryCommented:
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.
0
ihenryCommented:
I see something not quite right in the code. Which one is correct?

The original code:
e.Path = @"LDAP://ldap.companyname.com/o=Org, ou=OrgUnit";
e.Username = "cn=UserName,ou=OrgUnit,o=Org";

this?
e.Path = @"LDAP://ldap.companyname.com/o=Org,ou=OrgUnit";
e.Username = "cn=UserName,o=Org,ou=OrgUnit";

or this?
e.Path = @"LDAP://ldap.companyname.com/ou=OrgUnit,o=Org;
e.Username = "cn=UserName,ou=OrgUnit,o=Org";

Sequence of dn syntax does matter for ldap path syntax and no spaces.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nobletucky2004Author Commented:
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!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.