summaryrefslogtreecommitdiff
path: root/app/Group/LdapBackendGroupProvider.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
commite9fedf3e5cd63aea4da7a71f6647ee427c62fa49 (patch)
treeabc2de5aebace4a2d7c94805552264dab6b10bc7 /app/Group/LdapBackendGroupProvider.php
parent346b8312e5ac877ce3192c2db3a26b500018bbb5 (diff)
Rewrite of the authentication and authorization system
Diffstat (limited to 'app/Group/LdapBackendGroupProvider.php')
-rw-r--r--app/Group/LdapBackendGroupProvider.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php
new file mode 100644
index 00000000..40273466
--- /dev/null
+++ b/app/Group/LdapBackendGroupProvider.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Kanboard\Group;
+
+use LogicException;
+use Kanboard\Core\Base;
+use Kanboard\Core\Group\GroupBackendProviderInterface;
+use Kanboard\Core\Ldap\Client as LdapClient;
+use Kanboard\Core\Ldap\ClientException as LdapException;
+use Kanboard\Core\Ldap\Group as LdapGroup;
+
+/**
+ * LDAP Backend Group Provider
+ *
+ * @package group
+ * @author Frederic Guillot
+ */
+class LdapBackendGroupProvider extends Base implements GroupBackendProviderInterface
+{
+ /**
+ * Find a group from a search query
+ *
+ * @access public
+ * @param string $input
+ * @return []LdapGroupProvider
+ */
+ public function find($input)
+ {
+ try {
+ $ldap = LdapClient::connect();
+ return LdapGroup::getGroups($ldap, $this->getLdapGroupPattern($input));
+
+ } catch (LdapException $e) {
+ $this->logger->error($e->getMessage());
+ return array();
+ }
+ }
+
+ /**
+ * Get LDAP group pattern
+ *
+ * @access public
+ * @param string $input
+ * @return string
+ */
+ public function getLdapGroupPattern($input)
+ {
+ if (empty(LDAP_GROUP_FILTER)) {
+ throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER');
+ }
+
+ return sprintf(LDAP_GROUP_FILTER, $input);
+ }
+}