Hello everyone,
I have an application that I am trying to use to search multiple OU's and it fails. It will work fine if I define the OU I want to search, but if I try and search a subtree if fails producing an error of "Unknown error (0x80005000)". I really need help resolving this, as I need to search two separate OU's. The LDAP server is a Sun Java Enterprise Directory Server Version 5.2.
I am really hoping that someone can provide some insight.
I have an application that I am trying to use to search multiple OU's and it fails. It will work fine if I define the OU I want to search, but if I try and search a subtree if fails producing an error of "Unknown error (0x80005000)". I really need help resolving this, as I need to search two separate OU's. The LDAP server is a Sun Java Enterprise Directory Server Version 5.2.
I am really hoping that someone can provide some insight.
Code:
private string getDNFromLDAP(string strUID)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://ldapserver.orgname.edu/dc=orgname,dc=edu");
// Works if I use the following entry
//DirectoryEntry entry = new DirectoryEntry("LDAP://ldapserver.orgname.edu/ou=staff, dc=orgname,dc=edu");
entry.AuthenticationType = AuthenticationTypes.Encryption;
entry.Username = this.AdminUser;
entry.Password = this.AdminPassword;
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.SearchScope = SearchScope.Subtree;
mySearcher.Filter = "(&(objectclass=*)(uid=" + strUID + "))";
try
{
SearchResult result = mySearcher.FindOne();
int nIndex = result.Path.LastIndexOf("/");
string strDN = result.Path.Substring(nIndex + 1).ToString().TrimEnd();
this.lmsUID = result.Properties[this.xukContainer][0].ToString();
this.lmsPWD = result.Properties[this.pwdContainer][0].ToString();
return strDN;
}
catch(System.Exception ex)
{
this.errMsg = ex.Message.toString();
}
finally
{
mySearcher.Dispose();
entry.Close();
entry.Dispose();
}
}