Пример #1
0
 public function testSearchEntriesShortcutWithDnObjectAndFilterObject()
 {
     $dn = LDAP\DN::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE);
     $filter = Filter\Filter::equals('objectClass', 'organizationalUnit');
     $entries = $this->_getLDAP()->searchEntries($filter, $dn, LDAP\LDAP::SEARCH_SCOPE_SUB);
     $this->assertType("array", $entries);
     $this->assertEquals(9, count($entries));
 }
Пример #2
0
 /**
  * Checks the group membership of the bound user
  *
  * @param  Zend_Ldap $ldap
  * @param  string    $canonicalName
  * @param  string    $dn
  * @param  array     $adapterOptions
  * @return string|true
  */
 protected function _checkGroupMembership(\Zend\Ldap\Ldap $ldap, $canonicalName, $dn, array $adapterOptions)
 {
     if ($adapterOptions['group'] === null) {
         return true;
     }
     if ($adapterOptions['memberIsDn'] === false) {
         $user = $canonicalName;
     } else {
         $user = $dn;
     }
     $groupName = \Zend\Ldap\Filter\Filter::equals($adapterOptions['groupAttr'], $adapterOptions['group']);
     $membership = \Zend\Ldap\Filter\Filter::equals($adapterOptions['memberAttr'], $user);
     $group = \Zend\Ldap\Filter\Filter::andFilter($groupName, $membership);
     $groupFilter = $adapterOptions['groupFilter'];
     if (!empty($groupFilter)) {
         $group = $group->addAnd($groupFilter);
     }
     $result = $ldap->count($group, $adapterOptions['groupDn'], $adapterOptions['groupScope']);
     if ($result === 1) {
         return true;
     } else {
         return 'Failed to verify group membership with ' . $group->toString();
     }
 }
Пример #3
0
 public function testRealFilterString()
 {
     $f1 = Filter\Filter::orFilter(Filter\Filter::equals('sn', 'Gehrig'), Filter\Filter::equals('sn', 'Goerke'));
     $f2 = Filter\Filter::orFilter(Filter\Filter::equals('givenName', 'Stefan'), Filter\Filter::equals('givenName', 'Ingo'));
     $f = Filter\Filter::andFilter($f1, $f2);
     $this->assertEquals('(&(|(sn=Gehrig)(sn=Goerke))(|(givenName=Stefan)(givenName=Ingo)))', $f->toString());
 }