diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2016-07-28 10:14:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-28 10:14:34 +0200 |
commit | 73311091bf27fc3f0bbc16652c73d1cf7dfb7586 (patch) | |
tree | 249e6225b2a234f3940a18af203e312b4de336ce /lib | |
parent | abdf8c2c841832d79914f4e245e9466e6d3dd2c5 (diff) | |
parent | bd65a17203a8eef4efa542c9d72dc3316008d9a6 (diff) | |
download | nextcloud-server-73311091bf27fc3f0bbc16652c73d1cf7dfb7586.tar.gz nextcloud-server-73311091bf27fc3f0bbc16652c73d1cf7dfb7586.zip |
Merge pull request #519 from GitHubUser4234/master
New LDAPProvider for user_ldap
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Server.php | 19 | ||||
-rw-r--r-- | lib/public/LDAP/IDeletionFlagSupport.php | 45 | ||||
-rw-r--r-- | lib/public/LDAP/ILDAPProvider.php | 105 | ||||
-rw-r--r-- | lib/public/LDAP/ILDAPProviderFactory.php | 53 |
4 files changed, 222 insertions, 0 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index 41092ceae6e..fd6ecdc297e 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -21,6 +21,7 @@ * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Tanghus <thomas@tanghus.net> * @author Vincent Petry <pvince81@owncloud.com> + * @author Roger Szabo <roger.szabo@web.de> * * @license AGPL-3.0 * @@ -584,6 +585,16 @@ class Server extends ServerContainer implements IServerContainer { $this->getLogger() ); }); + $this->registerService('LDAPProvider', function(Server $c) { + $config = $c->getConfig(); + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); + if(is_null($factoryClass)) { + throw new \Exception('ldapProviderFactory not set'); + } + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ + $factory = new $factoryClass($this); + return $factory->getLDAPProvider(); + }); $this->registerService('LockingProvider', function (Server $c) { $ini = $c->getIniWrapper(); $config = $c->getConfig(); @@ -1406,4 +1417,12 @@ class Server extends ServerContainer implements IServerContainer { return $this->query('ShareManager'); } + /** + * Returns the LDAP Provider + * + * @return \OCP\LDAP\ILDAPProvider + */ + public function getLDAPProvider() { + return $this->query('LDAPProvider'); + } } diff --git a/lib/public/LDAP/IDeletionFlagSupport.php b/lib/public/LDAP/IDeletionFlagSupport.php new file mode 100644 index 00000000000..5f7d3909195 --- /dev/null +++ b/lib/public/LDAP/IDeletionFlagSupport.php @@ -0,0 +1,45 @@ +<?php +/** + * + * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de) + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\LDAP; + +/** + * Interface IDeletionFlagSupport + * + * @package OCP\LDAP + * @since 9.2.0 + */ +interface IDeletionFlagSupport { + /** + * Flag record for deletion. + * @param string $uid user id + * @since 9.2.0 + */ + public function flagRecord($uid); + + /** + * Unflag record for deletion. + * @param string $uid user id + * @since 9.2.0 + */ + public function unflagRecord($uid); +} diff --git a/lib/public/LDAP/ILDAPProvider.php b/lib/public/LDAP/ILDAPProvider.php new file mode 100644 index 00000000000..473afb13885 --- /dev/null +++ b/lib/public/LDAP/ILDAPProvider.php @@ -0,0 +1,105 @@ +<?php +/** + * + * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de) + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\LDAP; + +/** + * Interface ILDAPProvider + * + * @package OCP\LDAP + * @since 9.2.0 + */ +interface ILDAPProvider { + /** + * Translate a user id to LDAP DN. + * @param string $uid user id + * @return string + * @since 9.2.0 + */ + public function getUserDN($uid); + + /** + * Translate a LDAP DN to an internal user name. + * @param string $dn LDAP DN + * @return string with the internal user name + * @throws \Exception if translation was unsuccessful + * @since 9.2.0 + */ + public function getUserName($dn); + + /** + * Convert a stored DN so it can be used as base parameter for LDAP queries. + * @param string $dn the DN + * @return string + * @since 9.2.0 + */ + public function DNasBaseParameter($dn); + + /** + * Sanitize a DN received from the LDAP server. + * @param array $dn the DN in question + * @return array the sanitized DN + * @since 9.2.0 + */ + public function sanitizeDN($dn); + + /** + * Return a new LDAP connection resource for the specified user. + * @param string $uid user id + * @return resource of the LDAP connection + * @since 9.2.0 + */ + public function getLDAPConnection($uid); + + /** + * Get the LDAP base for users. + * @param string $uid user id + * @return string the base for users + * @throws \Exception if user id was not found in LDAP + * @since 9.2.0 + */ + public function getLDAPBaseUsers($uid); + + /** + * Get the LDAP base for groups. + * @param string $uid user id + * @return string the base for groups + * @throws \Exception if user id was not found in LDAP + * @since 9.2.0 + */ + public function getLDAPBaseGroups($uid); + + /** + * Check whether a LDAP DN exists + * @param string $dn LDAP DN + * @return bool whether the DN exists + * @since 9.2.0 + */ + public function dnExists($dn); + + /** + * Clear the cache if a cache is used, otherwise do nothing. + * @param string $uid user id + * @since 9.2.0 + */ + public function clearCache($uid); +} diff --git a/lib/public/LDAP/ILDAPProviderFactory.php b/lib/public/LDAP/ILDAPProviderFactory.php new file mode 100644 index 00000000000..99e7b8d27ea --- /dev/null +++ b/lib/public/LDAP/ILDAPProviderFactory.php @@ -0,0 +1,53 @@ +<?php +/** + * + * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de) + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\LDAP; + +use OCP\IServerContainer; + +/** + * Interface ILDAPProviderFactory + * + * This class is responsible for instantiating and returning an ILDAPProvider + * instance. + * + * @package OCP\LDAP + * @since 9.2.0 + */ +interface ILDAPProviderFactory { + + /** + * Constructor for the LDAP provider factory + * + * @param IServerContainer $serverContainer server container + * @since 9.2.0 + */ + public function __construct(IServerContainer $serverContainer); + + /** + * creates and returns an instance of the ILDAPProvider + * + * @return ILDAPProvider + * @since 9.2.0 + */ + public function getLDAPProvider(); +} |