locked
DirectorySearcher IIS Application Pool goes in hang RRS feed

  • Question

  • User-1845223160 posted

    Hi :)

    I have created a webservice that has CRUD operations against Active Directory. Im calling the webservice from a page buid on jQuery Ajax. Something has gone wrong and the  IIS Application Pool hangs after some amout of operations against the WebServices. Or all calls to Active Directory hangs it seems after a while. I created a small "stress page" to check closer what realy is the source of error. And I think I found something. When I did 10 calls a second aganst a service that collects a single user throu DirectoryServices.AccountManagement it seems to work well. I have some time responstime around 600 ms, and that is no problem. The problem starts when I ran the same test against a WebService operation collecting OrganizationalUnits to a List. It seems like for every time I collect the list, it does get slower and slower untill it does not respond at all. And then I have to Recycle the Application Pool.

    The code is right here:

    [WebMethod]
            public List<OrganizationalUnit> OUSubtree(String sRootDN)
            {
                DirectoryEntry de = new DirectoryEntry("LDAP://" + sRootDN);
                DirectorySearcher searcher = new DirectorySearcher();
                adprincipalhelper adds = new adprincipalhelper();
    
                searcher.Filter = "(objectCategory=organizationalUnit)";
                searcher.SearchScope = SearchScope.Subtree;
                searcher.SearchRoot = de;
    
                var ListOfOU = new List<OrganizationalUnit>();
                foreach (SearchResult result in searcher.FindAll())
                {
                    ListOfOU.Add(new OrganizationalUnit() { Name = adds.GetSearchResultPropertyValue(result, "name"), description = adds.GetSearchResultPropertyValue(result, "description"), Manager = adds.GetSearchResultPropertyValue(result, "managedBy"), distinguishedName = result.Properties["distinguishedName"][0].ToString(), Parent = result.GetDirectoryEntry().Parent.Properties["distinguishedName"][0].ToString() });
                }
                
                searcher.Dispose();
                de.Dispose();
    
                return ListOfOU;
    
            }
    
    //the OrganizationalUnit object looks like this:
    
    
    
        public class OrganizationalUnit
        {
            public string Name { get; set; }
            public string distinguishedName { get; set; }
            public string description { get; set; }
            public string Parent { get; set; }
            public string Manager { get; set; }
        }
    
    //the GetSearchResultPropertyValue function looks like this:
    
            public string GetSearchResultPropertyValue(SearchResult result, string propertyName)
            {
                try { return result.Properties[propertyName][0].ToString();}
                catch { return ""; }
            }
    
    
    Friday, January 10, 2014 11:26 AM

Answers

  • User-166373564 posted

    Hi larsbehner

    DirectorySearcher IIS Application Pool goes in hang

    Thanks for your feedback.

    For this issue, I’d like to suggest you to enable the failed Request Tracing in IIS, this will give me some hint on why this happens, we can enable this Failed Request Tracing in the IIS by steps below,

    1. Open Internet Information Services (IIS) Manager:
    2. In the Connections pane, select the server connection, site, application, or directory for which you want to configure failed request tracing.
    3. In the Actions pane, click Failed Request Tracing...
    4. In the Edit Web Site Failed Request Tracing Settings dialog box, select the Enable check box to enable tracing, leave the default value or type a new directory where you want to store failed request log files in the Directory box, type the number of failed request trace files you want to store in the Maximum number of trace files box, and then click OK.

    And you can check log files in C:\inetpub\logs\FailedReqLogFiles, it will give more details to troubleshoot this issue.

    Best regards

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 4:48 AM

All replies

  • User-166373564 posted

    Hi larsbehner

    DirectorySearcher IIS Application Pool goes in hang

    Thanks for your feedback.

    For this issue, I’d like to suggest you to enable the failed Request Tracing in IIS, this will give me some hint on why this happens, we can enable this Failed Request Tracing in the IIS by steps below,

    1. Open Internet Information Services (IIS) Manager:
    2. In the Connections pane, select the server connection, site, application, or directory for which you want to configure failed request tracing.
    3. In the Actions pane, click Failed Request Tracing...
    4. In the Edit Web Site Failed Request Tracing Settings dialog box, select the Enable check box to enable tracing, leave the default value or type a new directory where you want to store failed request log files in the Directory box, type the number of failed request trace files you want to store in the Maximum number of trace files box, and then click OK.

    And you can check log files in C:\inetpub\logs\FailedReqLogFiles, it will give more details to troubleshoot this issue.

    Best regards

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 13, 2014 4:48 AM
  • User-1845223160 posted

    Hi!

    Im sorry for the long time of replying! I testet out this and added some *.asmx and *.aspx logging. I got some logs and can probably analyse them. The problem is that now I have taken out the code i have written above and a imaga handler from the production environment. So I have to do the debugging in the developent or the test environment. Im almost 95% sure that the problem is either the image handler (collecting the thumbnailPhoto attribute from AD), or the OUSubtree Method. I will test and get back with the results.

    Thank you for your time Angie!

    Best regards

    Lars

    Saturday, January 25, 2014 4:04 AM