Ejemplo n.º 1
0
	/**
	 * Checks whether a user exists in the LDAP directory.
	 *
	 * @return  boolean  True if user exists.
	 *
	 * @since   2.0
	 */
	private function _checkUserExists()
	{
		try
		{
			$this->client->getUserDn($this->username, null, false);

			return true;
		}
		catch (Exception $e)
		{
			return false;
		}
	}
Ejemplo n.º 2
0
 /**
  * @covers SHLdap::__get
  */
 public function testMagicGetMethod()
 {
     $user = TestsHelper::getUserCreds('shaun.maunder');
     $ldap = new SHLdap(TestsHelper::getLdapConfig(214));
     $ldap->connect();
     // Test Bind Status
     $this->assertEquals(SHLdap::AUTH_NONE, $ldap->bindStatus);
     $ldap->proxyBind();
     $this->assertEquals(SHLdap::AUTH_PROXY, $ldap->bindStatus);
     $ldap->bind('asdasdas', 'asdasdas');
     $this->assertEquals(SHLdap::AUTH_NONE, $ldap->bindStatus);
     $ldap->bind($user['dn'], $user['password']);
     $this->assertEquals(SHLdap::AUTH_USER, $ldap->bindStatus);
     // Rinse and Go
     $ldap = new SHLdap(TestsHelper::getLdapConfig(214));
     $ldap->connect();
     // Test Last User DN
     $this->assertNull($ldap->lastUserDn);
     $ldap->getUserDn($user['username'], $user['password']);
     $this->assertEquals($user['dn'], $ldap->lastUserDn);
     // Test All user Filter
     $this->assertEquals('(objectclass=user)', $ldap->allUserFilter);
     // Rinse and Go
     $ldap = new SHLdap(TestsHelper::getLdapConfig(216));
     $ldap->connect();
     // Test Key for Name Attribute
     $this->assertEquals('cn', $ldap->keyName);
     $this->assertEquals('mail', $ldap->keyEmail);
     $this->assertEquals('uid', $ldap->keyUid);
     $this->assertEquals('uid', $ldap->ldap_uid);
     // Test Information
     $this->assertEquals('ldap1.shmanic.net:389', $ldap->info);
     // Test something that doesn't exist
     $this->assertNull($ldap->doesntexist);
 }