/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify | ||||
/** | /** | ||||
* Return the username for the given LDAP DN, if available. | * Return the username for the given LDAP DN, if available. | ||||
* @param string $dn | * @param string $dn | ||||
* @return string|false with the name to use in ownCloud | |||||
* @return string|false with the username | |||||
*/ | */ | ||||
public function dn2UserName($dn); | public function dn2UserName($dn); | ||||
} | } |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify | ||||
} | } | ||||
/** | /** | ||||
* Translate an ownCloud user id to LDAP DN | |||||
* @param string $uid ownCloud user id | |||||
* Translate an user id to LDAP DN | |||||
* @param string $uid user id | |||||
* @return string with the LDAP DN | * @return string with the LDAP DN | ||||
* @throws \Exception if translation was unsuccessful | * @throws \Exception if translation was unsuccessful | ||||
*/ | */ | ||||
} | } | ||||
/** | /** | ||||
* Translate a LDAP DN to an ownCloud user name. If there is no mapping between | |||||
* Translate a LDAP DN to an internal user name. If there is no mapping between | |||||
* the DN and the user name, a new one will be created. | * the DN and the user name, a new one will be created. | ||||
* @param string $dn LDAP DN | * @param string $dn LDAP DN | ||||
* @return string with the ownCloud user name | |||||
* @return string with the internal user name | |||||
* @throws \Exception if translation was unsuccessful | * @throws \Exception if translation was unsuccessful | ||||
*/ | */ | ||||
public function getUserName($dn) { | public function getUserName($dn) { | ||||
$result = $this->backend->dn2UserName($dn); | $result = $this->backend->dn2UserName($dn); | ||||
if(!$result){ | if(!$result){ | ||||
throw new \Exception('Translation to ownCloud user name unsuccessful'); | |||||
throw new \Exception('Translation to internal user name unsuccessful'); | |||||
} | } | ||||
return $result; | return $result; | ||||
} | } | ||||
/** | /** | ||||
* Return a new LDAP connection resource for the specified user. | * Return a new LDAP connection resource for the specified user. | ||||
* The connection must be closed manually. | * The connection must be closed manually. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return resource of the LDAP connection | * @return resource of the LDAP connection | ||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
*/ | */ | ||||
/** | /** | ||||
* Get the LDAP base for users. | * Get the LDAP base for users. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return string the base for users | * @return string the base for users | ||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
*/ | */ | ||||
/** | /** | ||||
* Get the LDAP base for groups. | * Get the LDAP base for groups. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return string the base for groups | * @return string the base for groups | ||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
*/ | */ | ||||
/** | /** | ||||
* Clear the cache if a cache is used, otherwise do nothing. | * Clear the cache if a cache is used, otherwise do nothing. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
*/ | */ | ||||
public function clearCache($uid) { | public function clearCache($uid) { | ||||
/** | /** | ||||
* Flag record for deletion. | * Flag record for deletion. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
*/ | */ | ||||
public function flagRecord($uid) { | public function flagRecord($uid) { | ||||
$this->deletedUsersIndex->markUser($uid); | $this->deletedUsersIndex->markUser($uid); | ||||
/** | /** | ||||
* Unflag record for deletion. | * Unflag record for deletion. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
*/ | */ | ||||
public function unflagRecord($uid) { | public function unflagRecord($uid) { | ||||
//do nothing | //do nothing |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify |
->getMock(); | ->getMock(); | ||||
$mocks['ocConfig'] = $this->getMock('\OCP\IConfig'); | $mocks['ocConfig'] = $this->getMock('\OCP\IConfig'); | ||||
$mocks['db'] = $this->getMock('\OCP\IDBConnection'); | $mocks['db'] = $this->getMock('\OCP\IDBConnection'); | ||||
$mocks['helper'] = new \OCA\User_LDAP\Helper(); | |||||
$mocks['helper'] = $this->getMock('\OCA\User_LDAP\Helper'); | |||||
return $mocks; | return $mocks; | ||||
} | } |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify | ||||
interface IDeletionFlagSupport { | interface IDeletionFlagSupport { | ||||
/** | /** | ||||
* Flag record for deletion. | * Flag record for deletion. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
public function flagRecord($uid); | public function flagRecord($uid); | ||||
/** | /** | ||||
* Unflag record for deletion. | * Unflag record for deletion. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
public function unflagRecord($uid); | public function unflagRecord($uid); |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify | ||||
*/ | */ | ||||
interface ILDAPProvider { | interface ILDAPProvider { | ||||
/** | /** | ||||
* Translate an ownCloud username to LDAP DN. | |||||
* @param string $uid ownCloud user id | |||||
* Translate a user id to LDAP DN. | |||||
* @param string $uid user id | |||||
* @return string | * @return string | ||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
public function getUserDN($uid); | public function getUserDN($uid); | ||||
/** | /** | ||||
* Translate a LDAP DN to an ownCloud user name. | |||||
* Translate a LDAP DN to an internal user name. | |||||
* @param string $dn LDAP DN | * @param string $dn LDAP DN | ||||
* @return string with the ownCloud user name | |||||
* @return string with the internal user name | |||||
* @throws \Exception if translation was unsuccessful | * @throws \Exception if translation was unsuccessful | ||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
/** | /** | ||||
* Return a new LDAP connection resource for the specified user. | * Return a new LDAP connection resource for the specified user. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return resource of the LDAP connection | * @return resource of the LDAP connection | ||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
/** | /** | ||||
* Get the LDAP base for users. | * Get the LDAP base for users. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return string the base for users | * @return string the base for users | ||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
* @since 9.2.0 | * @since 9.2.0 | ||||
/** | /** | ||||
* Get the LDAP base for groups. | * Get the LDAP base for groups. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @return string the base for groups | * @return string the base for groups | ||||
* @throws \Exception if user id was not found in LDAP | * @throws \Exception if user id was not found in LDAP | ||||
* @since 9.2.0 | * @since 9.2.0 | ||||
/** | /** | ||||
* Clear the cache if a cache is used, otherwise do nothing. | * Clear the cache if a cache is used, otherwise do nothing. | ||||
* @param string $uid ownCloud user id | |||||
* @param string $uid user id | |||||
* @since 9.2.0 | * @since 9.2.0 | ||||
*/ | */ | ||||
public function clearCache($uid); | public function clearCache($uid); |
/** | /** | ||||
* @author Roger Szabo <roger.szabo@web.de> | * @author Roger Szabo <roger.szabo@web.de> | ||||
* | * | ||||
* @copyright Copyright (c) 2016, ownCloud, Inc. | |||||
* @license AGPL-3.0 | * @license AGPL-3.0 | ||||
* | * | ||||
* This code is free software: you can redistribute it and/or modify | * This code is free software: you can redistribute it and/or modify |