/**
  * @dataProvider configurationDataProvider
  */
 public function testSetValue($key, $input, $expected)
 {
     $configuration = new \OCA\User_LDAP\Configuration('t01', false);
     $settingsInput = array('ldapBaseUsers' => array('cn=someUsers,dc=example,dc=org', '  ', ' cn=moreUsers,dc=example,dc=org '));
     $configuration->setConfiguration([$key => $input]);
     $this->assertSame($configuration->{$key}, $expected);
 }
Beispiel #2
0
 */
// Check user and app status
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\LDAP();
$configuration = new \OCA\User_LDAP\Configuration($prefix);
$con = new \OCA\User_LDAP\Connection($ldapWrapper, '', null);
$con->setConfiguration($configuration->getConfiguration());
$con->ldapConfigurationActive = true;
$con->setIgnoreValidation(true);
$userManager = new \OCA\User_LDAP\User\Manager(\OC::$server->getConfig(), new \OCA\User_LDAP\FilesystemHelper(), new \OCA\User_LDAP\LogWrapper(), \OC::$server->getAvatarManager(), new \OCP\Image(), \OC::$server->getDatabaseConnection(), \OC::$server->getUserManager());
$access = new \OCA\User_LDAP\Access($con, $ldapWrapper, $userManager);
$wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access);
switch ($action) {
    case 'guessPortAndTLS':
    case 'guessBaseDN':
    case 'detectEmailAttribute':
    case 'detectUserDisplayNameAttribute':
    case 'determineGroupMemberAssoc':
    case 'determineUserObjectClasses':
    case 'determineGroupObjectClasses':
Beispiel #3
0
$wControls = new OCP\Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
$sControls = new OCP\Template('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
$l = \OC::$server->getL10N('user_ldap');
$wizTabs = array();
$wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server'));
$wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('Users'));
$wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Attributes'));
$wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Groups'));
$wizTabsCount = count($wizTabs);
for ($i = 0; $i < $wizTabsCount; $i++) {
    $tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']);
    if ($i === 0) {
        $tab->assign('serverConfigurationPrefixes', $prefixes);
        $tab->assign('serverConfigurationHosts', $hosts);
    }
    $tab->assign('wizardControls', $wControls);
    $wizardHtml .= $tab->fetchPage();
    $toc['#ldapWizard' . ($i + 1)] = $wizTabs[$i]['cap'];
}
$tmpl->assign('tabs', $wizardHtml);
$tmpl->assign('toc', $toc);
$tmpl->assign('settingControls', $sControls);
// assign default values
$config = new \OCA\User_LDAP\Configuration('', false);
$defaults = $config->getDefaults();
foreach ($defaults as $key => $default) {
    $tmpl->assign($key . '_default', $default);
}
return $tmpl->fetchPage();
 * 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, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
// Check user and app status
OCP\JSON::checkAdminUser();
OCP\JSON::checkAppEnabled('user_ldap');
OCP\JSON::callCheck();
$helper = new \OCA\User_LDAP\Helper();
$serverConnections = $helper->getServerConfigurationPrefixes();
sort($serverConnections);
$lk = array_pop($serverConnections);
$ln = intval(str_replace('s', '', $lk));
$nk = 's' . str_pad($ln + 1, 2, '0', STR_PAD_LEFT);
$resultData = array('configPrefix' => $nk);
$newConfig = new \OCA\User_LDAP\Configuration($nk, false);
if (isset($_POST['copyConfig'])) {
    $originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']);
    $newConfig->setConfiguration($originalConfig->getConfiguration());
} else {
    $configuration = new \OCA\User_LDAP\Configuration($nk, false);
    $newConfig->setConfiguration($configuration->getDefaults());
    $resultData['defaults'] = $configuration->getDefaults();
}
$newConfig->saveConfiguration();
OCP\JSON::success($resultData);