@@ 62-83 (lines=22) @@ | ||
59 | $records = $this->ldap->search($filter, $baseDn, $scope, $attributes, $sort); |
|
60 | ||
61 | $results = []; |
|
62 | foreach ($records as $record) { |
|
63 | foreach ($record as $attribute => $value) { |
|
64 | // if the value is an array with a single value, e.g. 'samaccountname' => array(0 => 'myusername') |
|
65 | // then make sure it's just set in the results as 'samaccountname' => 'myusername' so that it |
|
66 | // can be used directly by ArrayData |
|
67 | if (is_array($value) && count($value) == 1) { |
|
68 | $value = $value[0]; |
|
69 | } |
|
70 | ||
71 | // ObjectGUID and ObjectSID attributes are in binary, we need to convert those to strings |
|
72 | if ($attribute == 'objectguid') { |
|
73 | $value = LDAPUtil::bin_to_str_guid($value); |
|
74 | } |
|
75 | if ($attribute == 'objectsid') { |
|
76 | $value = LDAPUtil::bin_to_str_sid($value); |
|
77 | } |
|
78 | ||
79 | $record[$attribute] = $value; |
|
80 | } |
|
81 | ||
82 | $results[] = $record; |
|
83 | } |
|
84 | ||
85 | return $results; |
|
86 | } |
@@ 117-138 (lines=22) @@ | ||
114 | { |
|
115 | $records = self::$data; |
|
116 | $results = []; |
|
117 | foreach ($records as $record) { |
|
118 | foreach ($record as $attribute => $value) { |
|
119 | // if the value is an array with a single value, e.g. 'samaccountname' => array(0 => 'myusername') |
|
120 | // then make sure it's just set in the results as 'samaccountname' => 'myusername' so that it |
|
121 | // can be used directly by ArrayData |
|
122 | if (is_array($value) && count($value) == 1) { |
|
123 | $value = $value[0]; |
|
124 | } |
|
125 | ||
126 | // ObjectGUID and ObjectSID attributes are in binary, we need to convert those to strings |
|
127 | if ($attribute == 'objectguid') { |
|
128 | $value = LDAPUtil::bin_to_str_guid($value); |
|
129 | } |
|
130 | if ($attribute == 'objectsid') { |
|
131 | $value = LDAPUtil::bin_to_str_sid($value); |
|
132 | } |
|
133 | ||
134 | $record[$attribute] = $value; |
|
135 | } |
|
136 | ||
137 | $results[] = $record; |
|
138 | } |
|
139 | ||
140 | return $results; |
|
141 | } |