return not breaking loop (c#)
<p>I'm trying to determine if a user is a member of a group or not in AD.  However, the following doesn't seem to be working for some reason...</p>

<pre><code>public bool MemberOf(string sObjectName, string sGroup, bool bIsGroup)
{
    DirectoryEntry dEntry = CreateDirectoryEntry();
    DirectorySearcher dSearcher = new DirectorySearcher(dEntry);
    if (bIsGroup) dSearcher.Filter = "(distinguishedName=" + sObjectName + ")";
    else dSearcher.Filter = "(&amp;(sAMAccountName=" + sObjectName + ")(objectClass=user))";  
    SearchResult sResult = dSearcher.FindOne();
    if (sResult != null)
    {
        foreach (object oGroup in sResult.Properties["MemberOf"])
        {
            if (oGroup.ToString() == sGroup) return true;
            else this.MemberOf(oGroup.ToString(), sGroup, true);
        }
    }
    return false;
}
</code></pre>

<p>Another variation: <a href="http://users.business.uconn.edu/dwick/work/wtf/6-14-2010%201-15-15%20PM.png" rel="nofollow">http://users.business.uconn.edu/dwick/work/wtf/6-14-2010%201-15-15%20PM.png</a></p>

<p>Doesn't work either.  This seems like a really dumb question... but shouldn't it break the loop upon "return true;"</p>
