Example #1
0
 public function get_selection()
 {
     // CODE FOR ADLDAP
     // $this->entries = array();
     // foreach ($this->group_filter as $grp) {
     //     $data = Yii::app()->ldap->group()->members($grp, true);
     //     $members = array();
     //     if (is_array($data)) {
     //         foreach ($data as $mem) {
     //             $d = Yii::app()->ldap->user()->info($mem, array("samaccountname", "dn"));
     //             $name = explode(',', $d[0]['dn']);
     //             // username -> display name
     //             $members[$d[0]['samaccountname'][0]] = substr($name[0], 3);
     //         }
     //         asort($members);
     //     }
     //     $this->entries[$grp] = $members;
     // }
     // ksort($this->entries);
     // CODE FOR LDAP
     $this->entries = false;
     $query = new LDAPQuery();
     $list = $query->get_groups();
     if ($list !== false) {
         $this->entries = array();
         foreach ($list as $l) {
             $this->entries[$l["cn"][0]] = $this->add_members($query, $l["uniquemember"]);
         }
     }
 }
 public function testNullTokens()
 {
     $q = new LDAPQuery();
     $this->assertEquals($q->prepare('%d', NULL), 'NULL');
     $this->assertEquals($q->prepare('%c', NULL), 'NULL');
 }
Example #3
0
 public function searchWithSizeLimitOne()
 {
     with($query = new LDAPQuery('ou=People,dc=OpenLDAP,dc=Org', '(objectClass=*)'));
     $query->setSizelimit(1);
     $query->setScope(LDAP_SCOPE_SUB);
     $res = $this->lc->searchBy($query);
     $this->assertClass($res, 'peer.ldap.LDAPSearchResult');
     $this->assertEquals(1, $res->numEntries());
     $this->assertClass($res->getFirstEntry(), 'peer.ldap.LDAPEntry');
     $this->assertFalse($res->getNextEntry());
 }
 /**
  * Perform an LDAP search specified by a given filter.
  *
  * @param   peer.ldap.LDAPQuery filter
  * @return  peer.ldap.LDAPSearchResult search result object
  */
 public function searchBy(LDAPQuery $filter)
 {
     static $methods = array(LDAP_SCOPE_BASE => 'ldap_read', LDAP_SCOPE_ONELEVEL => 'ldap_list', LDAP_SCOPE_SUB => 'ldap_search');
     if (empty($methods[$filter->getScope()])) {
         throw new IllegalArgumentException('Scope ' . $args[0] . ' not supported');
     }
     if (FALSE === ($res = @call_user_func_array($methods[$filter->getScope()], array($this->_hdl, $filter->getBase(), $filter->getFilter(), $filter->getAttrs(), $filter->getAttrsOnly(), $filter->getSizeLimit(), $filter->getTimelimit(), $filter->getDeref())))) {
         throw new LDAPException('Search failed', ldap_errno($this->_hdl));
     }
     // Sort results by given sort attributes
     if ($filter->getSort()) {
         foreach ($filter->getSort() as $sort) {
             ldap_sort($this->_hdl, $res, $sort);
         }
     }
     return new LDAPSearchResult($this->_hdl, $res);
 }