Link to home
Start Free TrialLog in
Avatar of GurcanK
GurcanK

asked on

LDAP Problem in ASP.Net Application

Dear Experts,

We have an ASP.Net application and this application uses LDAP for authentication. In other words, the application is authenticated by users from Windows Active Directory. Our application uses system.directoryservices.dll. By the way, when we install the application on a non-domain controller, we are unable to get domain user list although we are able to get domain user list using ldp.exe (MS LDAP Tool) on the same computer. Both for application and LDP.exe, we use port 389, along with DNS name of DC with valid domain user name and password. While LDP.exe (Microsoft LDAP tool) is working correctly, the application is unable to get anything from domain even we use the same LDAP filter rule for both.

Example Code Segments from Application:

// ActiveDirectory.cs
      
 public List<SearchResult> getAllByQuery(string query)
{
      List<SearchResult> result = new List<SearchResult>();

      // entry is an ActiveDirectory's "DirectoryEntry" attribute -> (*1)
      
      DirectorySearcher srch = new DirectorySearcher(entry, query); // System.DirectoryServices.dll, v2.0.50727

      SearchResultCollection results = srch.FindAll();
      foreach (SearchResult item in results)
      {
            result.Add(item);
      }
      return result;

*****************************

if (byUsername)
      return ldapLogin.getUserClassByQuery("(&(|(objectclass=user)(objectclass=person))(sAMAccountName=" + name + ")(!userAccountControl:1.2.840.113556.1.4.803:=2))"); //( selected one *)
else
      return ldapLogin.getUserClassByQuery("(&(|(objectclass=user)(objectclass=person))(displayName=" + name + ")(!userAccountControl:1.2.840.113556.1.4.803:=2))");


if (byUsername)
      return ldapLogin.getUserClassByQuery("(&(objectCategory=person)(objectClass=user)(sAMAccountName=" + name + ")(!userAccountControl:1.2.840.113556.1.4.803:=2))"); //( selected one *)
else
      return ldapLogin.getUserClassByQuery("(&(objectCategory=person)(objectClass=user)(displayName=" + name + ")(!userAccountControl:1.2.840.113556.1.4.803:=2))");


Could you please help us?

Best Regards
ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial