locked
Active Directory Searching Error (0x80005000) RRS feed

  • Question

  • Hi,

         I am getting some information from LDAP directory some times it's work but some times it simply throws exceptions such  of (0x80005000) or 

    System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at 

    My IIS is 7 

    code as given below

     using (System.Security.Principal.WindowsIdentity.GetCurrent().Impersonate())
                    {

                        using (DirectoryEntry entry = new DirectoryEntry("LDAP://" + pstrDomain))
                        {
                            entry.RefreshCache();
                            //entry.AuthenticationType = AuthenticationTypes.Delegation;
                            using (DirectorySearcher dirSearch = new DirectorySearcher(
                                entry,
                                string.Concat("(&(objectClass=user)(mailnickname=" + LanID + "))")
                                ))
                            {
                                try
                                {
                                    SearchResult result = dirSearch.FindOne();
                                    if (result != null)
                                        return getProperty(result, ObjType);
                                    else
                                        return null;
                                }
                                catch (SoapException ex)
                                {
                                    throw ex;
                                }
                                catch (Exception ex)
                                {
                                    throw new System.Security.SecurityException("Access denied.");
                                }
                            }
                        }

    Pls help to get rid this problem

    Thursday, January 3, 2013 8:46 AM

All replies

  • Errors starting with 0x8 are either access priviledge violations or null pointers.  Some expcetion will normally occur if you don't have the authorization to access a file.  Your code isn''t capturing all the places where the exception can occur.  I made some minor changes to catch all the possible exceptions.

           static void Main(string[] args)
            {
                   try
                   {
                      System.Security.Principal.WindowsImpersonationContext identity = System.Security.Principal.WindowsIdentity.GetCurrent().Impersonate();
                      using (identity)
                      {
                          DirectoryEntry entry = new DirectoryEntry("LDAP://" + pstrDomain);
                          using (entry)
                          {
                              entry.RefreshCache();
                              //entry.AuthenticationType = AuthenticationTypes.Delegation;
                              using (DirectorySearcher dirSearch = new DirectorySearcher(
                                  entry,
                                  string.Concat("(&(objectClass=user)(mailnickname=" + LanID + "))")
                                  ))
                              {
                                  try
                                  {
                                      SearchResult result = dirSearch.FindOne();
                                      if (result != null)
                                          return getProperty(result, ObjType);
                                      else
                                          return null;
                                  }
                                  catch (SoapException ex)
                                  {
                                      throw ex;
                                  }
                                  catch (Exception ex)
                                  {
                                      throw new System.Security.SecurityException("Access denied.");
                                  }
                              }
                          }
                      }
                   }
                   catch (Exception ex)
                   {
                         throw new System.Security.SecurityException("Access denied.");
                   }
                   
            }


    jdweng

    Thursday, January 3, 2013 10:42 AM
  • hi

    It is something about case-sensitive processing of strings in

    Active Directory Service Interfaces

    http://forums.asp.net/t/1026497.aspx/1

    regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

    Thursday, January 3, 2013 12:02 PM
  • I applied those changes 

    but any way to come over this problem

    first thing it is not comes every time some time only

    Thursday, January 3, 2013 12:22 PM
  • no i am already using LDAP only all in caps
    Thursday, January 3, 2013 12:23 PM