protected function _cleanGroups($memberships)
    {
        $groups = [];
        foreach ($memberships as $group) {
            $parts = explode(',', $group);

            foreach ($parts as $part) {
                if (substr($part, 0, 3) == 'CN=') {
                    $groups[] = substr($part, 3);
                    break;
                }
            }
        }

        return $groups;
    }