• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ldap_free_result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ldap_free_result函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_free_result函数的具体用法?PHP ldap_free_result怎么用?PHP ldap_free_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: search_uidspip

function search_uidspip ($filter,$ldap_server, $ldap_port, $dn) {
  global  $ldap_grp_attr;
  
  // LDAP attributs
  $ldap_grp_attr = array (
    "cn",
    "memberuid"  );

  $ds = @ldap_connect ( $ldap_server, $ldap_port );
  if ( $ds ) {
    $r = @ldap_bind ( $ds ); // Bind anonyme
    if ($r) {
      $result=@ldap_list ($ds, $dn["groups"], $filter, $ldap_grp_attr);
      if ($result) {
        $info = ldap_get_entries( $ds, $result );
        if ($info["count"]) {
          // Stockage des logins des membres des classes
          //  dans le tableau $ret
          $init=0;
          for ($loop=0; $loop < $info["count"]; $loop++) {
            $group=split ("[\_\]",$info[$loop]["cn"][0],2);
            for ( $i = 0; $i < $info[$loop]["memberuid"]["count"]; $i++ ) {
              $ret[$init]["uid"] = $info[$loop]["memberuid"][$i];
              $ret[$init]["cat"] = $group[0];
              $init++;
            }
          }
        }
        ldap_free_result ( $result );
      }
    } 
    @ldap_close ( $ds );
  } 
  return $ret;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:35,代码来源:accorder_comptes_lcs.php


示例2: checkGroupMembership

 /**
  * Validate group membership
  *
  * Searches the LDAP server for group membership of the
  * supplied username.  Quotes all LDAP filter meta characters in
  * the user name before querying the LDAP server.
  *
  * @param  string Distinguished Name of the authenticated User
  * @return boolean
  */
 public function checkGroupMembership($user)
 {
     if (!is_resource($this->_resource)) {
         $this->connect();
     }
     $userDn = $this->_getAccountDn($user);
     foreach ($this->_options['groups'] as $group) {
         // make filter
         $filter = sprintf('(&(%s=%s)(%s=%s)%s)', $this->_options['groupAttr'], $group, $this->_options['memberAttr'], $this->_quoteFilterString($userDn), $this->_options['groupFilter']);
         // make search base dn
         $search_basedn = $this->_options['groupDn'];
         if ($search_basedn != '' && substr($search_basedn, -1) != ',') {
             $search_basedn .= ',';
         }
         $search_basedn .= $this->_options['baseDn'];
         $func_params = array($this->_resource, $search_basedn, $filter, array($this->_options['memberAttr']));
         $func_name = 'ldap_search';
         //echo "Searching with $func_name and filter $filter in $search_basedn";
         // search
         if (($result_id = @call_user_func_array($func_name, $func_params)) != false) {
             if (@ldap_count_entries($this->_resource, $result_id) == 1) {
                 @ldap_free_result($result_id);
                 //echo 'User is member of group';
                 return true;
             }
         }
     }
     // default
     throw new Zend_Ldap_Exception(null, 'User is NOT member of any group!', BDBLdap::LDAP_USER_NOT_MEMBER_OF_GROUP);
     return false;
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:41,代码来源:BDBLdap.php


示例3: login

 function login($uid, $pwd, $ip = 0)
 {
     $this->groups = array();
     $this->uid = $uid;
     if (!($ds = ldap_connect($this->host))) {
         return false;
     }
     if (!($r = @ldap_bind($ds, "uid={$uid},{$this->basedn}", $pwd))) {
         ldap_unbind($ds);
         sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 0);
         return false;
     }
     $filter = "(&(objectclass=posixGroup)(memberuid={$uid}))";
     $retvals = array("cn");
     $sr = ldap_search($ds, $this->basedn, $filter, $retvals);
     $entries = ldap_get_entries($ds, $sr);
     $this->groups = array();
     for ($i = 0; $i < $entries["count"]; $i++) {
         for ($j = 0; $j < $entries[$i]["cn"]["count"]; $j++) {
             $this->groups[] = $entries[$i]["cn"][$j];
         }
     }
     ldap_free_result($sr);
     ldap_unbind($ds);
     //	print_r( $this->groups );
     sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 1);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:28,代码来源:authLDAP2307User.class.php


示例4: _free

 /**
  * free and close the bound ressources
  */
 function _free()
 {
     if (isset($this->_sr) and is_resource($this->_sr)) {
         ldap_free_result($this->_sr);
     }
     if (isset($this->_ldap) and is_resource($this->_ldap)) {
         ldap_close($this->_ldap);
     }
     unset($this->_sr);
     unset($this->_ldap);
 }
开发者ID:hugcoday,项目名称:wiki,代码行数:14,代码来源:LDAP.php


示例5: studentid2uid

 public function studentid2uid($pStudentId)
 {
     if (empty($pStudentId)) {
         throw new Exception("No parameter given", E_PARAM);
     }
     $dn = LDAP_OU . ", " . LDAP_O . ", " . LDAP_C;
     $filter = "(&(objectclass=" . LDAP_OBJECTCLASS_STUDENT . ")(" . LDAP_ATTRIBUTE_STUDID . "=" . $pStudentId . "))";
     $search = ldap_search($this->ldap_conn, $dn, $filter, array("uid"));
     $entry = ldap_first_entry($this->ldap_conn, $search);
     $result = @ldap_get_values($this->ldap_conn, $entry, "uid");
     ldap_free_result($search);
     return $result[0];
 }
开发者ID:rolwi,项目名称:koala,代码行数:13,代码来源:lms_ldap.class.php


示例6: __destruct

 public function __destruct()
 {
     $con = $this->connection->getResource();
     $this->connection = null;
     if (null === $this->search || false === $this->search) {
         return;
     }
     $success = ldap_free_result($this->search);
     $this->search = null;
     if (!$success) {
         throw new LdapException(sprintf('Could not free results: %s', ldap_error($con)));
     }
 }
开发者ID:symfony,项目名称:ldap,代码行数:13,代码来源:Query.php


示例7: ldapSearchUser

function ldapSearchUser($filter, $required)
{
    global $AUTHCFG;
    $conn = ldapConnectServer();
    if ($conn == NULL) {
        return NULL;
    }
    $ident = @ldap_search($conn, $AUTHCFG['ldap_basedn'], $filter, $required);
    if ($ident) {
        $result = ldap_get_entries($conn, $ident);
        ldap_free_result($ident);
    }
    ldap_unbind($conn);
    return $result;
}
开发者ID:braybaut,项目名称:ldap-vtiger,代码行数:15,代码来源:Ldap.php


示例8: execute

 /**
  * {@inheritdoc}
  */
 public function execute(LdapOperationInterface $operation)
 {
     $allEntries = [];
     /** @var QueryOperation $operation */
     $this->paging()->setIsEnabled($this->shouldUsePaging($operation));
     $this->paging()->start($operation->getPageSize(), $operation->getSizeLimit());
     do {
         $this->paging()->next();
         $result = @call_user_func($operation->getLdapFunction(), $this->connection->getConnection(), ...$operation->getArguments());
         $allEntries = $this->processSearchResult($result, $allEntries);
         $this->paging()->update($result);
     } while ($this->paging()->isActive());
     $this->paging()->end();
     @ldap_free_result($result);
     return $allEntries;
 }
开发者ID:ldaptools,项目名称:ldaptools,代码行数:19,代码来源:QueryOperationHandler.php


示例9: getValuesFromCas

 public function getValuesFromCas($cas)
 {
     $result = ldap_search($this->conn, "ou=People,o=cwru.edu,o=isp", "uid=" . $cas);
     if ($entries = ldap_first_entry($this->conn, $result)) {
         $firstName = ldap_get_values($this->conn, $entries, "givenName");
         $surname = ldap_get_values($this->conn, $entries, "SN");
         $mail = ldap_get_values($this->conn, $entries, "mail");
         ldap_free_result($result);
         $return['firstName'] = $firstName[0];
         $return['lastName'] = $surname[0];
         $return['mail'] = $mail[0];
         return $return;
     } else {
         return false;
     }
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:16,代码来源:class.ldap.php


示例10: search

 public function search(array $params)
 {
     $this->connect();
     $ref = array('base_dn' => '', 'filter' => '');
     if (count($diff = array_diff_key($ref, $params))) {
         throw new \Exception(sprintf('You must defined %s', print_r($diff, true)));
     }
     $attrs = isset($params['attrs']) ? $params['attrs'] : array();
     $this->info(sprintf('ldap_search base_dn %s, filter %s', print_r($params['base_dn'], true), print_r($params['filter'], true)));
     $search = @ldap_search($this->ress, $params['base_dn'], $params['filter'], $attrs);
     $this->checkLdapError();
     if ($search) {
         $entries = ldap_get_entries($this->ress, $search);
         @ldap_free_result($search);
         return is_array($entries) ? $entries : false;
     }
     return false;
 }
开发者ID:pedroresende,项目名称:LdapBundle,代码行数:18,代码来源:LdapConnection.php


示例11: find

 /**
  * {@inheritdoc}
  */
 public function find($dn, $query, $filter = '*')
 {
     if (!is_array($filter)) {
         $filter = array($filter);
     }
     $search = ldap_search($this->connection, $dn, $query, $filter);
     if (false === $search) {
         throw new LdapException(ldap_error($this->connection));
     }
     $infos = ldap_get_entries($this->connection, $search);
     if (false === @ldap_free_result($search)) {
         throw new LdapException(ldap_error($this->connection));
     }
     if (0 === $infos['count']) {
         return;
     }
     return $infos;
 }
开发者ID:WilBenShu,项目名称:digital_pilot,代码行数:21,代码来源:LdapClient.php


示例12: phamm_search

 /**
  * Generic LDAP search
  *
  * @author Alessandro De Zorzi <[email protected]>
  *
  * @todo add attrsonly, sizelimit, timelimit
  *
  * @param string $base_dn
  * @param string $filter
  * @param array $attributes
  * @return array $entries
  **/
 static function phamm_search($base_dn, $filter, $attributes = null, $sort = null)
 {
     global $connect;
     // Do a LDAP search
     if (isset($attributes)) {
         $search = ldap_search($connect, $base_dn, $filter, $attributes);
     } else {
         $search = ldap_search($connect, $base_dn, $filter);
     }
     // Order the results if possible
     if (version_compare(phpversion(), "4.2.0", ">=")) {
         ldap_sort($connect, $search, $sort);
     }
     // Get entries
     $entries = ldap_get_entries($connect, $search);
     // Free the memory
     ldap_free_result($search);
     // Return the entry
     return $entries;
 }
开发者ID:steveblamey,项目名称:phamm,代码行数:32,代码来源:ldap.php


示例13: ldap_authenticate

function ldap_authenticate($user_id, $password)
{
    $ldap_server = LDAP_SERVER;
    $ldap_port = LDAP_PORT;
    $ldap_id = LDAP_ID;
    $ldap_pwd = LDAP_PWD;
    $ldap_root_dn = LDAP_DN;
    $ldap_proto = LDAP_PROTOCOL;
    //$ldap_user = '(&(lmaccessstatusid=active)(uid=' . $user_id . '))';
    $ldap_user = '(uid=' . $user_id . ')';
    $ldapconn = ldap_connect($ldap_server, $ldap_port);
    if (!$ldapconn) {
        error_report_show("login.php", LDAP_CONNECTION_FAILED);
    }
    if (!ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, $ldap_proto)) {
        error_report_show("login.php", LDAP_CONNECTION_FAILED);
    }
    $ldapbind = ldap_bind($ldapconn, $ldap_id, $ldap_pwd);
    if (!$ldapbind) {
        error_report_show("login.php", INVALID_LOGIN);
    }
    $ldapsearch = ldap_search($ldapconn, $ldap_root_dn, $ldap_user);
    $ldapentries = ldap_get_entries($ldapconn, $ldapsearch);
    $authenticated = false;
    if ($ldapentries) {
        # Try to authenticate to each until we get a match
        for ($i = 0; $i < $ldapentries['count']; $i++) {
            $dn = $ldapentries[$i]['dn'];
            # Attempt to bind with the DN and password
            if (@ldap_bind($ldapconn, $dn, $password)) {
                $authenticated = true;
                break;
            }
        }
    }
    ldap_close($ldapconn);
    ldap_free_result($ldapsearch);
    return $authenticated;
}
开发者ID:nourchene-benslimane,项目名称:rth_backup,代码行数:39,代码来源:ldap_api.php


示例14: getChildrenDns

 /**
  * Retrieve the immediate children DNs of the given $parentDn
  *
  * This method is used in recursive methods like {@see delete()}
  * or {@see copy()}
  *
  * @param  string|Dn $parentDn
  * @throws Exception\LdapException
  * @return array of DNs
  */
 protected function getChildrenDns($parentDn)
 {
     if ($parentDn instanceof Dn) {
         $parentDn = $parentDn->toString();
     }
     $children = array();
     ErrorHandler::start(E_WARNING);
     $search = ldap_list($this->getResource(), $parentDn, '(objectClass=*)', array('dn'));
     for ($entry = ldap_first_entry($this->getResource(), $search); $entry !== false; $entry = ldap_next_entry($this->getResource(), $entry)) {
         $childDn = ldap_get_dn($this->getResource(), $entry);
         if ($childDn === false) {
             ErrorHandler::stop();
             throw new Exception\LdapException($this, 'getting dn');
         }
         $children[] = $childDn;
     }
     ldap_free_result($search);
     ErrorHandler::stop();
     return $children;
 }
开发者ID:Rovak,项目名称:zf2,代码行数:30,代码来源:Ldap.php


示例15: getUserData

 /**
  * Return user info
  *
  * Returns info about the given user needs to contain
  * at least these fields:
  *
  * name string  full name of the user
  * mail string  email addres of the user
  * grps array   list of groups the user is in
  *
  * This LDAP specific function returns the following
  * addional fields:
  *
  * dn     string  distinguished name (DN)
  * uid    string  Posix User ID
  * inbind bool    for internal use - avoid loop in binding
  *
  * @author  Andreas Gohr <[email protected]>
  * @author  Trouble
  * @author  Dan Allen <[email protected]>
  * @author  <[email protected]>
  * @author  Stephane Chazelas <[email protected]>
  * @return  array containing user data or false
  */
 function getUserData($user, $inbind = false)
 {
     global $conf;
     if (!$this->_openLDAP()) {
         return false;
     }
     // force superuser bind if wanted and not bound as superuser yet
     if ($this->cnf['binddn'] && $this->cnf['bindpw'] && $this->bound < 2) {
         // use superuser credentials
         if (!@ldap_bind($this->con, $this->cnf['binddn'], $this->cnf['bindpw'])) {
             if ($this->cnf['debug']) {
                 msg('LDAP bind as superuser: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
             }
             return false;
         }
         $this->bound = 2;
     } elseif ($this->bound == 0 && !$inbind) {
         // in some cases getUserData is called outside the authentication workflow
         // eg. for sending email notification on subscribed pages. This data might not
         // be accessible anonymously, so we try to rebind the current user here
         $pass = PMA_blowfish_decrypt($_SESSION[DOKU_COOKIE]['auth']['pass'], auth_cookiesalt());
         $this->checkPass($_SESSION[DOKU_COOKIE]['auth']['user'], $pass);
     }
     $info['user'] = $user;
     $info['server'] = $this->cnf['server'];
     //get info for given user
     $base = $this->_makeFilter($this->cnf['usertree'], $info);
     if (!empty($this->cnf['userfilter'])) {
         $filter = $this->_makeFilter($this->cnf['userfilter'], $info);
     } else {
         $filter = "(ObjectClass=*)";
     }
     $sr = $this->_ldapsearch($this->con, $base, $filter, $this->cnf['userscope']);
     $result = @ldap_get_entries($this->con, $sr);
     if ($this->cnf['debug']) {
         msg('LDAP user search: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
         msg('LDAP search at: ' . htmlspecialchars($base . ' ' . $filter), 0, __LINE__, __FILE__);
     }
     // Don't accept more or less than one response
     if (!is_array($result) || $result['count'] != 1) {
         return false;
         //user not found
     }
     $user_result = $result[0];
     ldap_free_result($sr);
     // general user info
     $info['dn'] = $user_result['dn'];
     $info['gid'] = $user_result['gidnumber'][0];
     $info['mail'] = $user_result['mail'][0];
     $info['name'] = $user_result['cn'][0];
     $info['grps'] = array();
     // overwrite if other attribs are specified.
     if (is_array($this->cnf['mapping'])) {
         foreach ($this->cnf['mapping'] as $localkey => $key) {
             if (is_array($key)) {
                 // use regexp to clean up user_result
                 list($key, $regexp) = each($key);
                 if ($user_result[$key]) {
                     foreach ($user_result[$key] as $grp) {
                         if (preg_match($regexp, $grp, $match)) {
                             if ($localkey == 'grps') {
                                 $info[$localkey][] = $match[1];
                             } else {
                                 $info[$localkey] = $match[1];
                             }
                         }
                     }
                 }
             } else {
                 $info[$localkey] = $user_result[$key][0];
             }
         }
     }
     $user_result = array_merge($info, $user_result);
     //get groups for given user if grouptree is given
     if ($this->cnf['grouptree'] || $this->cnf['groupfilter']) {
//.........这里部分代码省略.........
开发者ID:kosenconf,项目名称:kcweb,代码行数:101,代码来源:ldap.class.php


示例16: _Net_LDAP2_Search

 /**
  * Destructor
  *
  * @access protected
  */
 public function _Net_LDAP2_Search()
 {
     @ldap_free_result($this->_search);
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:9,代码来源:Search.php


示例17: __destruct

 public function __destruct()
 {
     @ldap_free_result($this->result);
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:4,代码来源:class.ilLDAPResult.php


示例18: free

 /**
  * Frees the resources allocated for this result set.
  * @return  int     error code
  *
  * @access public
  */
 function free()
 {
     $this->_recordset = null;
     $this->_record = null;
     ldap_free_result($this->result);
     $this->result = null;
     return true;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:14,代码来源:ldap.php


示例19: _close

 function _close()
 {
     @ldap_free_result($this->_queryID);
     $this->_queryID = false;
 }
开发者ID:johnfelipe,项目名称:orfeo,代码行数:5,代码来源:adodb-ldap.inc.php


示例20: close

 /**
  * Closes the current result set
  *
  * @return bool
  */
 public function close()
 {
     $isClosed = false;
     if (is_resource($this->resultId)) {
         ErrorHandler::start();
         $isClosed = ldap_free_result($this->resultId);
         ErrorHandler::stop();
         $this->resultId = null;
         $this->current = null;
     }
     return $isClosed;
 }
开发者ID:GeeH,项目名称:zend-ldap,代码行数:17,代码来源:DefaultIterator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ldap_get_attributes函数代码示例发布时间:2022-05-15
下一篇:
PHP ldap_first_entry函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap