I am working with a LDAP extension, it queries the Active Directory server and returns the result as a Yii2 ArrayDataProvider.
$attributes = Yii::$app->ldap->searchUserByLogin($this->username, ['mail', 'sn', 'givenname']);
A vardump of the returned info is as follows;
yii\data\ArrayDataProvider#1
(
[key] => null
[allModels] => [
0 => [
'mail' => ‘[email protected]
'sn' => ‘Surname’
'givenname' => ‘FirstName’
'middlename' => null
]
]
[modelClass] => null
[id] => null
[yii\data\BaseDataProvider:_sort] => null
[yii\data\BaseDataProvider:_pagination] => null
[yii\data\BaseDataProvider:_keys] => null
[yii\data\BaseDataProvider:_models] => null
[yii\data\BaseDataProvider:_totalCount] => null
[yii\base\Component:_events] => []
[yii\base\Component:_eventWildcards] => []
[yii\base\Component:_behaviors] => null
It was my understanding I could treat the data as objects and access them like;
$attributes->mail
But I get an error that the object isn't found. Then if I try and treat it like a traditional array I get;
Cannot use object of type yii\data\ArrayDataProvider as array yii2
Help would be much appreciated.
Thanks