Lines Matching defs:attribute

23  * Provides simple helper APIs for retrieving ranged results for an entry attribute.
25 * @see https://docs.microsoft.com/en-us/windows/desktop/adsi/attribute-range-retrieval
44 * Get a specific ranged attribute by name from an entry. If it does not exist it will return null.
46 * @param string|Attribute $attribute
48 public function getRanged(Entry $entry, $attribute): ?Attribute
50 $attribute = $attribute instanceof Attribute ? new Attribute($attribute->getName()) : new Attribute($attribute);
53 if ($rangedAttribute->equals($attribute)) {
72 foreach ($entry->getAttributes() as $attribute) {
73 if (!$attribute->hasOptions()) {
77 foreach ($attribute->getOptions() as $option) {
79 $ranged[] = $attribute;
89 * A simple check to determine if an entry contains any ranged attributes. Optionally pass an attribute
92 * @param Attribute|string|null $attribute
95 public function hasRanged(Entry $entry, $attribute = null): bool
97 return (bool) ($attribute !== null ? $this->getRanged($entry, $attribute) : $this->getAllRanged($entry));
101 * Check if an attribute has more range values that can be queried.
103 * @param Attribute $attribute
106 public function hasMoreValues(Attribute $attribute): bool
108 if (($range = $this->getRangeOption($attribute)) === null) {
116 * Given a specific Entry/DN and an attribute, get the next set of ranged values available. Optionally pass a third
120 * @param Attribute $attribute
125 public function getMoreValues($entry, Attribute $attribute, $amount = '*'): Attribute
127 if (($range = $this->getRangeOption($attribute)) === null || !$this->hasMoreValues($attribute)) {
128 return new Attribute($attribute->getName());
133 $attrReq = new Attribute($attribute->getName());
138 $attrResult = $result->get($attribute->getName());
141 'The attribute %s was not returned from LDAP',
142 $attribute->getName()
147 'No ranged option received for attribute "%s" on "%s".',
148 $attribute->getName(),
157 * Given a specific entry and attribute, range retrieve all values of the attribute.
160 * @param string|Attribute $attribute
164 public function getAllValues($entry, $attribute): Attribute
166 $attrResult = $attribute instanceof Attribute ? new Attribute($attribute->getName()) : new Attribute($attribute);
170 $attribute = $this->getRanged($entry, $attrResult);
171 if ($attribute === null) {
179 $attrResult->add(...$attribute->getValues());
180 while ($this->hasMoreValues($attribute)) {
181 $attribute = $this->getMoreValues($entry, $attribute);
182 $attrResult->add(...$attribute->getValues());
189 * @param Attribute $attribute
192 protected function getRangeOption(Attribute $attribute): ?Option
195 foreach ($attribute->getOptions() as $option) {