public static function explodeExchangeLegacyDn($dn, $withAttributes = false)
    {
        preg_match(self::MATCH_LEGACY_DN, $dn, $matches);

        if (!isset($matches[2])) {
            throw new InvalidArgumentException(sprintf('Unable to parse legacy exchange dn "%s".', $dn));
        }
        $pieces = [];
        for ($i = 3; $i < count($matches); $i += 3) {
            $pieces[] = $withAttributes ? $matches[$i - 1].'='.$matches[$i] : $matches[$i];
        }

        return $pieces;
    }