protected function getRdnFromAttributes(array $attributes) {
        $rdn = [];
        $rdnAttributes = array_map('strtolower', $this->schema->getRdn());

        foreach ($rdnAttributes as $rdnAttribute) {
            $rdnAttribute = $this->schema->getAttributeToLdap($rdnAttribute);
            foreach ($attributes as $attribute) {
                if (strtolower($attribute) === $rdnAttribute) {
                    $rdn[] = $attribute;
                }
            }
        }
        if (empty($rdn)) {
            throw new LogicException(sprintf(
                'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'
                . ' the distinguished name. Expected one, or more, of these attributes: %s',
                implode(', ', $this->schema->getRdn())
            ));
        }

        return $rdn;
    }