[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.Net DirectoryService connection to Novell eDirectory (LDAP)

Posted on 2006-03-30
15
Medium Priority
?
1,849 Views
Last Modified: 2008-01-09
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;
    }
0
Comment
Question by:Nobletucky2004
  • 8
  • 7
15 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 16333343
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
 

Author Comment

by:Nobletucky2004
ID: 16333441
I substitued the first "," with a "/" and received the following:


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

0
 

Author Comment

by:Nobletucky2004
ID: 16333449
also reversed the forward to back slash and received the first error.
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
LVL 20

Expert Comment

by:ihenry
ID: 16333762
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
 
LVL 20

Expert Comment

by:ihenry
ID: 16333877
Also try this line.
entry.Path= @"LDAP://ldap.mycompaniesname.com/o=baseOrg, ou=scopeUnit";
0
 

Author Comment

by:Nobletucky2004
ID: 16334006
   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
 
LVL 20

Expert Comment

by:ihenry
ID: 16334036
Try to change the AuthenticationType property to none.
0
 

Author Comment

by:Nobletucky2004
ID: 16334060
getting the same error as before...should the user name have teh full dn or just the cn?
0
 
LVL 20

Expert Comment

by:ihenry
ID: 16334210
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
 

Author Comment

by:Nobletucky2004
ID: 16334339
for this above to work anonymous login would have to be allowed on the LDAP correct?
0
 
LVL 20

Expert Comment

by:ihenry
ID: 16334382
Yup, you meant your directory server does not allow anonymous login to the ou?
0
 

Author Comment

by:Nobletucky2004
ID: 16334404
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
 
LVL 20

Expert Comment

by:ihenry
ID: 16334497
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
 
LVL 20

Accepted Solution

by:
ihenry earned 2000 total points
ID: 16334724
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
 

Author Comment

by:Nobletucky2004
ID: 16335370
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question