Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Find all users of a given usergroup without timing out...? How to avoid timing out?

Last post 02-26-2010, 10:19 AM by ghost. 2 replies.
Sort Posts: Previous Next
  •  02-25-2010, 3:25 PM 7874

    Find all users of a given usergroup without timing out...? How to avoid timing out?

    I realize that Active Directory's defalt and max timout is set to 2 minutes (120 seconds) and that you can only configure that to be shorter, not longer.
    However, I'm polling Active Directory for all the users within a given group.
    This is recursive as I must also scan through nested groups.

    I have the process working thanks to this code: http://www.myrocode.com/post/2009/09/14/using-Active-directory-with-C-LDAP-query-to-get-all-users-in-a-specific-Group.aspx

    However, I keep timing out because the search is obviously taking longer than 2 minutes.

    How do I go about completing a lengthier search within the default 120 second timeout?

    Thank you.
  •  02-25-2010, 10:59 PM 7876 in reply to 7874

    Re: Find all users of a given usergroup without timing out...? How to avoid timing out?

    Did you look at the code sample from ch 11 in the book samples that shows group membership expansion? You might try that instead.

    One thing I saw with the sample you referenced is that it calls GetDirectoryEntry in a loop simply to read a single attribute. NEVER do this. You should never call GetDirectoryEntry from the SearchResult unless you need to modify. Always read attributes from the ResultPropertyValueCollection on the SearchResult. Calling GetDirectoryEntry causes 1 (or usually 2) additional searches to be submitted to the server for each call. In the example shown, it was being used to read a value that was already in memory. Not good.

    There may be other approaches you want to try as well but start with the ch 11 sample and see if that gets you further.

  •  02-26-2010, 10:19 AM 7883 in reply to 7876

    Re: Find all users of a given usergroup without timing out...? How to avoid timing out?

    You mean in the "GerUsersFromAdGroup" method?
    I changed it from using

    DirectoryEntry group = searchResult.GetDirectoryEntry();
    group.Properties["distinguishedName"].Value.ToString();

    to using:

    searchResult.Properties["distinguishedName"].ToString()

    I'll give that a shot and then check out Ch11 in the sample book. Thanks.

    If anyone else has any thoughts, please don't hesitate!
View as RSS news feed in XML