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.InteropSer vices.COME xception: 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://lda p.mycompan iesname.co m, 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;
}
Here is my code I'm using:
...
using System.DirectoryServices;
public static DirectoryEntry getDirectoryEntry()
{
return new DirectoryEntry("LDAP://lda
}
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;
}
ASKER
I substitued the first "," with a "/" and received the following:
System.Runtime.InteropServ ices.COMEx ception: An invalid dn syntax has been specified.
System.Runtime.InteropServ
ASKER
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.mycompaniesn ame.com, o=baseOrg, ou=scopeUnit";
entry.AuthenticationTypes = AuthenticationTypes.None;
string name = entry.Name;
Just for troubleshooting, if you run this piece of code alone, does this work?
DirectoryEntry entry = new DirectoryEntry();
entry.Path= @"LDAP://ldap.mycompaniesn
entry.AuthenticationTypes = AuthenticationTypes.None;
string name = entry.Name;
Also try this line.
entry.Path= @"LDAP://ldap.mycompaniesn ame.com/o= baseOrg, ou=scopeUnit";
entry.Path= @"LDAP://ldap.mycompaniesn
ASKER
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.Server Bind;
return e;
}
get the following: System.DirectoryServices.D irectorySe rvicesCOME xception: 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.
{
DirectoryEntry e = new DirectoryEntry();
e.Path = @"LDAP://ldap.companyname.
e.Username = "cn=UserName,ou=OrgUnit,o=
e.Password = "password";
e.AuthenticationType = AuthenticationTypes.Server
return e;
}
get the following: System.DirectoryServices.D
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.
ASKER
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.
DirectoryEntry entry = new DirectoryEntry();
entry.Path= @"LDAP://ldap.companyname.
entry.AuthenticationTypes = AuthenticationTypes.None;
string name = entry.Name;
If the above code works than the user name will be likely the culprit.
ASKER
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?
ASKER
yea the above code gave me an
System.DirectoryServices.D irectorySe rvicesCOME xception: There is no such object on the server.
error.
Is the object is is looking for dependent on the AuthType.?
System.DirectoryServices.D
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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!!
LDAP://ldap.mycompaniesnam
Henry