当前位置: 首页>>代码示例>>PHP>>正文


PHP Ldap::search方法代码示例

本文整理汇总了PHP中Zend\Ldap\Ldap::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Ldap::search方法的具体用法?PHP Ldap::search怎么用?PHP Ldap::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Ldap\Ldap的用法示例。


在下文中一共展示了Ldap::search方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find

 public function find($name, $value, $attr_name)
 {
     $this->bind();
     $filter = "{$attr_name}={$value}";
     $base_dn = $this->active_server['baseDn'];
     $this->log("Attempting to search for {$name}={$value} using basedn={$base_dn}");
     try {
         $hm = $this->ldap->search($filter, $base_dn, $this->scope);
         $this->log("Raw Ldap Object: " . var_export($hm, true), 7);
         if ($hm->count() == 0) {
             $this->log("Could not find an account for {$name}={$value}", 5);
             return false;
         } elseif ($hm->count() > 1) {
             $this->log("Found more than one user account for {$name}={$value}", 1);
             return false;
         }
         $this->user = $hm->current();
         $this->log("User entry response: " . var_export($this->user, true), 7);
         return $this->user;
     } catch (LdapException $exc) {
         return $exc->getMessage();
     }
 }
开发者ID:sha1,项目名称:zfcuser-ldap,代码行数:23,代码来源:AbstractAdapter.php

示例2: findUnit

 private function findUnit(Identity $identity)
 {
     if (null === $this->unit) {
         $filter = Filter::equals('mail', $identity->mail);
         $baseDn = Dn::factory($this->ldap->getBaseDn())->prepend(['ou' => 'people']);
         $result = $this->ldap->search($filter, $baseDn, Ldap::SEARCH_SCOPE_ONE, ['l']);
         if (1 !== $result->count()) {
             return;
         }
         $result = $result->current();
         $unitDn = $result['l'][0];
         $this->unit = $this->ldap->getNode($unitDn);
     }
     return $this->unit;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:15,代码来源:CreateSchool.php

示例3: findById

 public function findById($id)
 {
     $this->bind();
     $this->log("Attempting to search ldap by uidnumber for {$id} against the active ldap server");
     try {
         $hm = $this->ldap->search("uidnumber={$id}", $this->active_server['baseDn'], ZendLdap::SEARCH_SCOPE_ONE);
         $this->log("Raw Ldap Object: " . var_export($hm, true), 7);
         foreach ($hm as $item) {
             $this->log($item);
             return $item;
         }
         return false;
     } catch (LdapException $exc) {
         $msg = $exc->getMessage();
         $this->log($msg);
     }
 }
开发者ID:hlich,项目名称:zfcuser-ldap,代码行数:17,代码来源:Ldap.php

示例4: getComputers

 public function getComputers($computerService)
 {
     $domain = $this->options['accountDomainName'];
     $ldap = new Ldap($this->options);
     $ldap->bind();
     $result = $ldap->search('(&(objectCategory=computer))', 'dc=wr,dc=local', Ldap::SEARCH_SCOPE_SUB);
     foreach ($result as $item) {
         if ($item['name'][0] != '') {
             $hostname = $item['name'][0];
             $computer = $computerService->findByDNSName($hostname, $domain);
             if (!$computer) {
                 $computer = new Computer();
                 $computerService->setType($computer, 'Computer');
                 $computerService->setStatus($computer, 'In Use');
                 $computerService->setManufacturer($computer, 'Dell');
                 $computer->setHostname($hostname)->setDomain($domain);
             }
             // Operating system
             if (array_key_exists('operatingsystem', $item)) {
                 $computer->setOsName($item['operatingsystem'][0]);
             }
             // Operating system service pack
             if (array_key_exists('operatingsystemservicepack', $item)) {
                 $computer->setOsServicePack($item['operatingsystemservicepack'][0]);
             }
             // Operating system version.
             if (array_key_exists('operatingsystemversion', $item)) {
                 $computer->setOsVersion($item['operatingsystemversion'][0]);
             }
             //  die(var_dump($computer->getStatus()));
             $computerService->persist($computer);
         }
     }
 }
开发者ID:srayner,项目名称:cobalt,代码行数:34,代码来源:ActiveDirectory.php


注:本文中的Zend\Ldap\Ldap::search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。