public function testOriginalAgentUnchangedOnClone() { //background: upon login a bind is done with the user credentials //which is valid for the whole LDAP resource. It needs to be reset //to the agent's credentials $lw = $this->getMock('\\OCA\\user_ldap\\lib\\ILDAPWrapper'); $connection = new \OCA\user_ldap\lib\Connection($lw, '', null); $agent = array('ldapAgentName' => 'agent', 'ldapAgentPassword' => '123456'); $connection->setConfiguration($agent); $testConnection = clone $connection; $user = array('ldapAgentName' => 'user', 'ldapAgentPassword' => 'password'); $testConnection->setConfiguration($user); $agentName = $connection->ldapAgentName; $agentPawd = $connection->ldapAgentPassword; $this->assertSame($agentName, $agent['ldapAgentName']); $this->assertSame($agentPawd, $agent['ldapAgentPassword']); }
OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $l = \OC::$server->getL10N('user_ldap'); if (!isset($_POST['action'])) { \OCP\JSON::error(array('message' => $l->t('No action specified'))); } $action = (string) $_POST['action']; if (!isset($_POST['ldap_serverconfig_chooser'])) { \OCP\JSON::error(array('message' => $l->t('No configuration specified'))); } $prefix = (string) $_POST['ldap_serverconfig_chooser']; $ldapWrapper = new \OCA\user_ldap\lib\LDAP(); $configuration = new \OCA\user_ldap\lib\Configuration($prefix); $con = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null); $con->setConfiguration($configuration->getConfiguration()); $con->ldapConfigurationActive = true; $con->setIgnoreValidation(true); $userManager = new \OCA\user_ldap\lib\user\Manager(\OC::$server->getConfig(), new \OCA\user_ldap\lib\FilesystemHelper(), new \OCA\user_ldap\lib\LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), \OC::$server->getDatabaseConnection()); $access = new \OCA\user_ldap\lib\Access($con, $ldapWrapper, $userManager); $wizard = new \OCA\user_ldap\lib\Wizard($configuration, $ldapWrapper, $access); switch ($action) { case 'guessPortAndTLS': case 'guessBaseDN': case 'detectEmailAttribute': case 'detectUserDisplayNameAttribute': case 'determineGroupMemberAssoc': case 'determineUserObjectClasses': case 'determineGroupObjectClasses': case 'determineGroupsForUsers': case 'determineGroupsForGroups':
* License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library 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 library. If not, see <http://www.gnu.org/licenses/>. * */ // Check user and app status OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $l = OC_L10N::get('user_ldap'); $ldapWrapper = new OCA\user_ldap\lib\LDAP(); $connection = new \OCA\user_ldap\lib\Connection($ldapWrapper, '', null); //needs to be true, otherwise it will also fail with an irritating message $_POST['ldap_configuration_active'] = 1; if ($connection->setConfiguration($_POST)) { //Configuration is okay if ($connection->bind()) { OCP\JSON::success(array('message' => $l->t('The configuration is valid and the connection could be established!'))); } else { OCP\JSON::error(array('message' => $l->t('The configuration is valid, but the Bind failed. Please check the server settings and credentials.'))); } } else { OCP\JSON::error(array('message' => $l->t('The configuration is invalid. Please have a look at the logs for further details.'))); }