How to improve execution of web service using System.DirectoryServies.AccountManagement that runs very slow? This method runs in just under two minutes.  I would like to optimize it to run in less than 15 seconds. Using a LAMDA filter on my list before iterating it's elements and removing one conditional statement in the method shaved off 30 seconds.  Any ideas to improve performance?

c# .net 4.0

[SecurityCritical]
        [SecurityPermissionAttribute(SecurityAction.Demand)] 
        private static void GetGroupMembership(List&lt;ActiveDirectoryPrincipalProperties&gt; userGroupProperties)
        {
            List&lt;ActiveDirectoryPrincipalProperties&gt; groupProperties = new List&lt;ActiveDirectoryPrincipalProperties&gt;();

            foreach (ActiveDirectoryPrincipalProperties gProperties in userGroupProperties.FindAll(token =&gt; token.groupYesNo.Equals(true)))
            {

                PrincipalContext ctx = new PrincipalContext(ContextType.Domain, gProperties.groupDomain);
                try
                {

                    GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, gProperties.groupName);

                    foreach (Principal member in group.GetMembers(true))
                    {
                        ActiveDirectoryPrincipalProperties memberProperties = new ActiveDirectoryPrincipalProperties();
                        memberProperties.fullGroupName = gProperties.fullGroupName;
                        memberProperties.groupDomain = gProperties.groupDomain;
                        memberProperties.groupName = gProperties.groupName;
                        memberProperties.groupType = gProperties.groupType;
                        memberProperties.groupYesNo = false;
                        memberProperties.memberDomain = member.Context.Name.ToString();
                        memberProperties.memberName = member.SamAccountName.ToString();
                        memberProperties.memberType = member.StructuralObjectClass.ToString();
                        memberProperties.sqlUserOnlyYesNo = false;

                        groupProperties.Add(memberProperties);
                    }
                    group.Dispose();
                }
                finally
                {
                    ctx.Dispose();
                }


            }

            userGroupProperties.AddRange(groupProperties);
        }
If you are writing this in Visual Studio 2010, it would be worth profiling your code to find out exactly what method calls take the longest.

Here is a link where you can watch a video from Channel9 about using the built in performance analyser tool in Visual Studio 2010 to perform CPU Sampling on your code: http://channel9.msdn.com/Blogs/wriju/CPU-Sampling-using-Visual-Studio-2010-Performance-Analyzer-Tool

Once you've identified the methods that take the longest to execute, you can start to work out if you're making any redundant or excessive calls and remove them, or research each call to find ways of optimising each.