LdapTools\Resolver\AttributeNameResolver::fromLdap PHP Method

fromLdap() public method

Transform the LDAP attribute names into what is expected given the current context (schema or not).
public fromLdap ( array $entry, array $selectedAttributes ) : array
$entry array The LDAP entry.
$selectedAttributes array The attributes that were selected.
return array
    public function fromLdap(array $entry, array $selectedAttributes)
    {
        $this->selectedAttributes = $this->getSelectedAttributes($selectedAttributes, $entry);
        $newEntry = [];
        foreach ($entry as $attribute => $value) {
            if ($this->schema) {
                $newEntry = $this->setMappedNames($newEntry, $attribute, $value);
            }
            // If the LDAP attribute name was also explicitly selected for, and is not already in the array, add it...
            if ($this->selectedButNotPartOfEntry($attribute, $newEntry)) {
                $newEntry[MBString::array_search_get_value($attribute, $this->selectedAttributes)] = $value;
            }
        }
        // The DN attribute must be present as it is used in many critical functions.
        $newEntry = $this->addDnFromLdapIfNotPresent($newEntry, $entry);
        return $newEntry;
    }