private bool IsUserInRoleRecursive(string distinguishedUserName, DirectoryData roleEntry)
        {
            if (roleEntry == null)
            {
                return false;
            }

            string[] members;
            if (!roleEntry.TryGetValue(_membersAttribute, out members))
            {
                // The membership attribute does not exists for this item, cannot be a member here
                return false;
            }

            foreach (string distinguishedMemberName in members)
            {
                if (String.Compare(distinguishedMemberName, distinguishedUserName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return true;
                }

                DirectoryData member = this._factory.GetEntry(distinguishedMemberName);
                if (member == null)
                {
                    continue;
                }

                if (member.SchemaClassName == "group")
                {
                    return IsUserInRoleRecursive(distinguishedUserName, member);
                }
            }

            return false;
        }
        private List<string> GetRolesForUserRecursive(DirectoryData entry)
        {
            var subtree = new List<string>();
            string[] propertyValue;
            if (entry.TryGetValue(_memberOfAttribute, out propertyValue))
            {
                foreach (string role in propertyValue)
                {
                    DirectoryData roleEntry = this._factory.GetEntry(role);
                    if (roleEntry == null || roleEntry.SchemaClassName != "group")
                    {
                        continue;
                    }
                    string[] roleName;
                    if (roleEntry.TryGetValue(this._roleNameAttribute, out roleName))
                    {
                        subtree.Add(roleName[0]);
                    }
                    subtree.AddRange(GetRolesForUserRecursive(roleEntry));
                }
            }

            return subtree;
        }