l l

l l

  • NA
  • 2
  • 0

always throw exception using DirectoryEntry.RefreshCache()

May 12 2006 1:18 AM

i want to validate user and password.
i code below:
     DirectoryEntry de = new DirectoryEntry(LDAPPath);
            DirectorySearcher search = new DirectorySearcher(de);
            search.Filter = "(&(objectclass=user)(cn=" + userID + "))";

            SearchResult sr = search.FindOne();
            if (sr != null)
            {
                string userDN = sr.Properties["distinguishedname"][0].ToString();
                DirectoryEntry de2 = new DirectoryEntry(sr.Path, userDN, password);
                try
                {
                    de2.RefreshCache();

                    Console.WriteLine("success");
                   }
                catch (System.Exception a)
                {

                    Console.WriteLine(a.Message);
  
                }
            }
it always output the error message even userid and password were matched

appreciated for helping