From 1f7b08bd19dd37bec73903679b3e0bfdaed71927 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 19 Jan 2017 15:19:20 +0100 Subject: LDAP OCS Api for show config Signed-off-by: Arthur Schiwon --- .../lib/Controller/ConfigAPIController.php | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'apps/user_ldap/lib/Controller') diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index 371ca899c26..5256b0d8aad 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -213,6 +213,100 @@ class ConfigAPIController extends OCSController { return new DataResponse(); } + /** + * retrieves a configuration + * + * + * + * + * ok + * 200 + * OK + * + * + * ldaps://my.ldap.server + * 7770 + * + * + * ou=small,dc=my,dc=ldap,dc=server + * ou=users,ou=small,dc=my,dc=ldap,dc=server + * ou=small,dc=my,dc=ldap,dc=server + * cn=root,dc=my,dc=ldap,dc=server + * clearTextWithShowPassword=1 + * 1 + * 0 + * + * displayname + * uid + * inetOrgPerson + * + * (&(objectclass=nextcloudUser)(nextcloudEnabled=TRUE)) + * 1 + * (&(|(objectclass=nextcloudGroup))) + * 0 + * nextcloudGroup + * + * cn + * memberUid + * (&(|(objectclass=inetOrgPerson))(uid=%uid)) + * 0 + * 0 + * 1 + * + * + * + * mail + * 20 + * auto + * auto + * + * 1 + * uid;sn;givenname + * + * 0 + * + * + * + * 1 + * uid + * uid + * + * 0 + * 0 + * 500 + * 1 + * + * + * + * + * @param string $configID + * @param bool|string $showPassword + * @return DataResponse + * @throws OCSException + */ + public function show($configID, $showPassword = false) { + $this->ensureConfigIDExists($configID); + + try { + $config = new Configuration($configID); + $data = $config->getConfiguration(); + if(!boolval(intval($showPassword))) { + $data['ldapAgentPassword'] = '***'; + } + foreach ($data as $key => $value) { + if(is_array($value)) { + $value = implode(';', $value); + $data[$key] = $value; + } + } + } catch (\Exception $e) { + $this->logger->logException($e); + throw new OCSException('An issue occurred when modifying the config.'); + } + + return new DataResponse($data); + } + /** * if the given config ID is not available, an exception is thrown * -- cgit v1.2.3