コード例 #1
0
ファイル: connection.php プロジェクト: stweil/owncloud-core
 public function testUseBackupServer()
 {
     $mainHost = 'ldap://nixda.ldap';
     $backupHost = 'ldap://fallback.ldap';
     $config = ['ldapConfigurationActive' => true, 'ldapHost' => $mainHost, 'ldapPort' => 389, 'ldapBackupHost' => $backupHost, 'ldapBackupPort' => 389, 'ldapAgentName' => 'uid=agent', 'ldapAgentPassword' => 'SuchASecret'];
     $this->connection->setIgnoreValidation(true);
     $this->connection->setConfiguration($config);
     $this->ldap->expects($this->any())->method('isResource')->will($this->returnValue(true));
     $this->ldap->expects($this->any())->method('setOption')->will($this->returnValue(true));
     $this->ldap->expects($this->exactly(3))->method('connect')->will($this->returnValue('ldapResource'));
     // Not called often enough? Then, the fallback to the backup server is broken.
     $this->connection->expects($this->exactly(4))->method('getFromCache')->with('overrideMainServer')->will($this->onConsecutiveCalls(false, false, true, true));
     $this->connection->expects($this->once())->method('writeToCache')->with('overrideMainServer', true);
     $isThrown = false;
     $this->ldap->expects($this->exactly(3))->method('bind')->will($this->returnCallback(function () use(&$isThrown) {
         if (!$isThrown) {
             $isThrown = true;
             throw new \OC\ServerNotAvailableException();
         }
         return true;
     }));
     $this->connection->init();
     $this->connection->resetConnectionResource();
     // with the second init() we test whether caching works
     $this->connection->init();
 }
コード例 #2
0
ファイル: access.php プロジェクト: olucao/owncloud-core
 /**
  * creates a unique name for internal ownCloud use.
  * @param string $name the display name of the object
  * @param boolean $isUser whether name should be created for a user (true) or a group (false)
  * @return string with with the name to use in ownCloud or false if unsuccessful
  */
 private function createAltInternalOwnCloudName($name, $isUser)
 {
     $originalTTL = $this->connection->ldapCacheTTL;
     $this->connection->setConfiguration(array('ldapCacheTTL' => 0));
     if ($isUser) {
         $altName = $this->_createAltInternalOwnCloudNameForUsers($name);
     } else {
         $altName = $this->_createAltInternalOwnCloudNameForGroups($name);
     }
     $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL));
     return $altName;
 }
コード例 #3
0
ファイル: testconfig.php プロジェクト: olucao/owncloud-core
 /**
  * tests the specified connection
  * @param string $configID
  * @return int
  */
 protected function testConfig($configID)
 {
     $lw = new \OCA\user_ldap\lib\LDAP();
     $connection = new Connection($lw, $configID);
     //ensure validation is run before we attempt the bind
     $connection->getConfiguration();
     if (!$connection->setConfiguration(array('ldap_configuration_active' => 1))) {
         return 1;
     }
     if ($connection->bind()) {
         return 0;
     }
     return 2;
 }
コード例 #4
0
	/**
	 * sets up the LDAP configuration to be used for the test
	 */
	private function initConnection() {
		$this->connection = new \OCA\user_ldap\lib\Connection($this->ldap, '', null);
		$this->connection->setConfiguration([
			'ldapHost' => $this->server['host'],
			'ldapPort' => $this->server['port'],
			'ldapBase' => $this->base,
			'ldapAgentName' => $this->server['dn'],
			'ldapAgentPassword' => $this->server['pwd'],
			'ldapUserFilter' => 'objectclass=inetOrgPerson',
			'ldapUserDisplayName' => 'displayName',
			'ldapGroupDisplayName' => 'cn',
			'ldapLoginFilter' => 'uid=%uid',
			'ldapCacheTTL' => 0,
			'ldapConfigurationActive' => 1,
		]);
	}
コード例 #5
0
 /**
  * sets up the LDAP configuration to be used for the test
  */
 protected function initConnection()
 {
     $this->connection = new Connection($this->ldap, '', null);
     $this->connection->setConfiguration(['ldapHost' => $this->server['host'], 'ldapPort' => $this->server['port'], 'ldapBase' => $this->base, 'ldapAgentName' => $this->server['dn'], 'ldapAgentPassword' => $this->server['pwd'], 'ldapUserFilter' => 'objectclass=inetOrgPerson', 'ldapUserDisplayName' => 'cn', 'ldapGroupDisplayName' => 'cn', 'ldapLoginFilter' => '(|(uid=%uid)(samaccountname=%uid))', 'ldapCacheTTL' => 0, 'ldapConfigurationActive' => 1]);
 }