| <?php |
|
|
| namespace Kanboard\Core\Ldap; |
|
|
| use LogicException; |
| use Kanboard\Group\LdapGroupProvider; |
|
|
| |
| |
| |
| |
| |
| |
| class Group |
| { |
| |
| |
| |
| |
| |
| |
| protected $query; |
|
|
| |
| |
| |
| |
| |
| |
| public function __construct(Query $query) |
| { |
| $this->query = $query; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public static function getGroups(Client $client, $query) |
| { |
| $self = new static(new Query($client)); |
| return $self->find($query); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function find($query) |
| { |
| $this->query->execute($this->getBaseDn(), $query, $this->getAttributes()); |
| $groups = array(); |
|
|
| if ($this->query->hasResult()) { |
| $groups = $this->build(); |
| } |
|
|
| return $groups; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| protected function build() |
| { |
| $groups = array(); |
|
|
| foreach ($this->query->getEntries()->getAll() as $entry) { |
| $groups[] = new LdapGroupProvider($entry->getDn(), $entry->getFirstValue($this->getAttributeName())); |
| } |
|
|
| return $groups; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function getAttributes() |
| { |
| return array_values(array_filter(array( |
| $this->getAttributeName(), |
| ))); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getAttributeName() |
| { |
| if (! LDAP_GROUP_ATTRIBUTE_NAME) { |
| throw new LogicException('LDAP full name attribute empty, check the parameter LDAP_GROUP_ATTRIBUTE_NAME'); |
| } |
|
|
| return strtolower(LDAP_GROUP_ATTRIBUTE_NAME); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getBaseDn() |
| { |
| if (! LDAP_GROUP_BASE_DN) { |
| throw new LogicException('LDAP group base DN empty, check the parameter LDAP_GROUP_BASE_DN'); |
| } |
|
|
| return LDAP_GROUP_BASE_DN; |
| } |
| } |
|
|