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

PHP ldap_count_entries函数代码示例

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

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



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

示例1: count

 /**
  * Get entries count
  */
 public function count()
 {
     if (!isset($this->count)) {
         $this->count = ldap_count_entries($this->conn, $this->ldap);
     }
     return $this->count;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:10,代码来源:rcube_ldap_result.php


示例2: ldap_authenticate

function ldap_authenticate($user, $pass)
{
    // Global variables
    global $ldap_base_DN, $ldap_server, $template, $admin_users, $ldap_user_cn;
    // Connect to the LDAP server
    $conn = ldap_connect($ldap_server) or die("Cannot connect");
    ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
    // Bind anonymously, query the server for the user, and error if it can't be found
    if (!($bind = ldap_bind($conn))) {
        $template['message'] = "<p>Anonymous bind failed.</p>";
        return;
    }
    // Do a search for the username and get the DN - this is easier than manually constructing it
    if (!($search = ldap_search($conn, $ldap_base_DN, "{$ldap_user_cn}={$user}"))) {
        $template['message'] = "<p><strong>Error:</strong> Could not find the username.</p>";
        return;
    }
    // If there isn't only one row.
    if (ldap_count_entries($conn, $search) != 1) {
        $template['message'] = "<p>There was an error processing the username, or it cannot be found.</p>";
        return;
    }
    // Extract the entries, and bind with the user's full DN, then unset the password for security
    $entries = @ldap_get_entries($conn, $search);
    $bind_auth = @ldap_bind($conn, $entries[0]['dn'], $pass);
    unset($pass);
    // If we have a successful bind, add the relevant session information
    if ($bind_auth) {
        $_SESSION['admin'] = in_array($user, $admin_users);
        $_SESSION['username'] = $user;
        header('Location: index.php');
    } else {
        $template['message'] = "<p><strong>Login failed.</strong> Please try again.</p>";
    }
}
开发者ID:smm13344331,项目名称:openbooking,代码行数:35,代码来源:functions_login.php


示例3: _encrypt

 function _encrypt($str_userpswd)
 {
     echo '&lt;h3>Prueba de consulta LDAP&lt;/h3>';
     echo 'Conectando ...';
     $ds = ldap_connect('localhost');
     echo 'El resultado de la conexi&oacute;n es ' . $ds . '&lt;p>';
     if ($ds) {
         echo 'Autentific&aacute;ndose  ...';
         $r = ldap_bind($ds);
         echo 'El resultado de la autentificaci&oacute;n es ' . $r . '&lt;p>';
         echo 'Buscando (sn=P*) ...';
         $sr = ldap_search($ds, 'o=halys, c=halys', 'sn=h*');
         echo 'El resultado de la b&uacute;squeda es ' . $sr . '&lt;p>';
         echo 'El n&uacute;mero de entradas devueltas es ' . ldap_count_entries($ds, $sr) . '&lt;p>';
         echo 'Recuperando entradas ...&lt;p>';
         $info = ldap_get_entries($ds, $sr);
         echo 'Devueltos datos de ' . $info['count'] . ' entradas:&lt;p>';
         for ($i = 0; $i < $info['count']; $i++) {
             echo 'dn es: ' . $info[$i]['dn'] . '&lt;br>';
             echo 'La primera entrada cn es: ' . $info[$i]['cn'][0] . '&lt;br>';
         }
         echo 'Cerrando conexi&oacute;n';
         ldap_close($ds);
     } else {
         echo '&lt;h4>Ha sido imposible conectar al servidor LDAP&lt;/h4>';
     }
 }
开发者ID:BackupTheBerlios,项目名称:migueloo,代码行数:27,代码来源:base_loginldap.class.php


示例4: 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


示例5: DoTest

 function DoTest($testname, $param, $hostname, $timeout, $params)
 {
     global $NATS;
     $url = $params[0];
     $bind = $params[1];
     $pasw = $params[2];
     $base = $params[3];
     $filter = $params[4];
     $ds = ldap_connect($url);
     if (!$ds) {
         return -2;
     }
     $ldap = $bind && $pasw ? ldap_bind($ds, $bind, $pasw) : ldap_bind($ds);
     if (!$ldap) {
         return -1;
     }
     if ($base && $filter) {
         $search = ldap_search($ds, $base, $filter);
         $val = ldap_count_entries($ds, $search);
     } else {
         $val = 1;
     }
     ldap_close($ds);
     return $val;
 }
开发者ID:alvunera,项目名称:FreeNats-PlugIn,代码行数:25,代码来源:ldap.inc.php


示例6: ajax_loadtags

/**
 * Load current tags of an entry
 */
function ajax_loadtags($dn, $type = 'plain')
{
    global $conf;
    global $LDAP_CON;
    global $FIELDS;
    if (!$FIELDS['_marker']) {
        return;
    }
    header('Content-Type: text/html; charset=utf-8');
    $sr = ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)', array($FIELDS['_marker']));
    if (!ldap_count_entries($LDAP_CON, $sr)) {
        return false;
    }
    $result = ldap_get_binentries($LDAP_CON, $sr);
    $entry = $result[0];
    if ($type == 'plain') {
        echo join(', ', (array) $entry[$FIELDS['_marker']]);
    } else {
        foreach ((array) $entry[$FIELDS['_marker']] as $tag) {
            echo '<a href="index.php?marker=';
            echo rawurlencode($tag);
            echo '" class="tag">';
            echo htmlspecialchars($tag);
            echo '</a> ';
        }
    }
}
开发者ID:pneff,项目名称:contagged,代码行数:30,代码来源:ajax.php


示例7: count

 public function count()
 {
     if (false !== ($count = ldap_count_entries($this->connection->getResource(), $this->search->getResource()))) {
         return $count;
     }
     throw new LdapException(sprintf('Error while retrieving entry count: %s', ldap_error($this->connection->getResource())));
 }
开发者ID:ayoah,项目名称:symfony,代码行数:7,代码来源:Collection.php


示例8: getUserDn

 function getUserDn($username)
 {
     if ($this->send_utf8_credentials) {
         $username = studip_utf8encode($username);
         $reader_password = studip_utf8encode($this->reader_password);
     }
     $user_dn = "";
     if (!($r = @ldap_bind($this->conn, $this->reader_dn, $this->reader_password))) {
         $this->error_msg = sprintf(_("Anmeldung von %s fehlgeschlagen."), $this->reader_dn) . $this->getLdapError();
         return false;
     }
     if (!($result = @ldap_search($this->conn, $this->base_dn, $this->getLdapFilter($username), array('dn')))) {
         $this->error_msg = _("Durchsuchen des LDAP Baumes fehlgeschlagen.") . $this->getLdapError();
         return false;
     }
     if (!ldap_count_entries($this->conn, $result)) {
         $this->error_msg = sprintf(_("%s wurde nicht unterhalb von %s gefunden."), $username, $this->base_dn);
         return false;
     }
     if (!($entry = @ldap_first_entry($this->conn, $result))) {
         $this->error_msg = $this->getLdapError();
         return false;
     }
     if (!($user_dn = @ldap_get_dn($this->conn, $entry))) {
         $this->error_msg = $this->getLdapError();
         return false;
     }
     return $user_dn;
 }
开发者ID:ratbird,项目名称:hope,代码行数:29,代码来源:StudipAuthLdapReadAndBind.class.php


示例9: entryCount

 /**
  * @return int
  * @throws EntryCountRetrievalFailureException
  */
 public function entryCount()
 {
     if (!($result = ldap_count_entries($this->link, $this->result))) {
         throw new EntryCountRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
     }
     return $result;
 }
开发者ID:daverandom,项目名称:ldapi,代码行数:11,代码来源:ResultSet.php


示例10: checkldapuser

function checkldapuser($username, $password)
{
    require 'config.php';
    $username = strtolower($username);
    $connect = ldap_connect($ldapServer);
    if ($connect != false) {
        ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
        ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
        // enlace a la conexión
        $bind = ldap_bind($connect, $usrLDAP, $pwdLDAP);
        if ($bind == false) {
            $mensajeError = "Falla la conexi&oacute;n con el servidor LDAP con el usuario \n{$usrLDAP}";
            return $mensajeError;
        }
        // active directory - pch
        $bind = @ldap_bind($connect, "{$campoBusqLDAP}=" . $username . ",{$cadenaBusqLDAP}", $password);
        if ($bind == false) {
            $mensajeError = "Usuario o contraseña incorrecta";
            return $mensajeError;
        }
        // busca el usuario - pch
        if (($res_id = ldap_search($connect, $cadenaBusqLDAP, "{$campoBusqLDAP}=" . $username)) == false) {
            $mensajeError = "No encontrado el usuario en el LDAP";
            return $mensajeError;
        }
        $cant = ldap_count_entries($connect, $res_id);
        if ($cant == 0) {
            $mensajeError = "El usuario {$username} NO se encuentra en el A.D. {$bind} HLPHLP";
            return $mensajeError;
        }
        if ($cant > 1) {
            $mensajeError = "El usuario {$username} se encuentra {$cant} veces en el A.D.";
            return $mensajeError;
        }
        $entry_id = ldap_first_entry($connect, $res_id);
        if ($entry_id == false) {
            $mensajeError = "No se obtuvieron resultados";
            return $mensajeError;
        }
        if (($user_dn = ldap_get_dn($connect, $entry_id)) == false) {
            $mensajeError = "No se puede obtener el dn del usuario";
            return $mensajeError;
        }
        error_reporting(0);
        /* Autentica el usuario */
        if (($link_id = ldap_bind($connect, "{$user_dn}", $password)) == false) {
            error_reporting(0);
            $mensajeError = "USUARIO O CONTRASE&Ntilde;A INCORRECTOS";
            return $mensajeError;
        }
        return '';
        @ldap_close($connect);
    } else {
        $mensajeError = "no hay conexi&oacute;n a '{$ldap_server}'";
        return $mensajeError;
    }
    @ldap_close($connect);
    return false;
}
开发者ID:kractos26,项目名称:orfeo,代码行数:59,代码来源:autenticaLDAP.php


示例11: count_entries

 public function count_entries()
 {
     if (isset($this->search)) {
         return ldap_count_entries($this->ds, $this->search);
     } else {
         return 0;
     }
 }
开发者ID:google-code-backups,项目名称:add-mvc-framework,代码行数:8,代码来源:add_ldap.class.php


示例12: readUser

 public static function readUser($ldapconn, $dn)
 {
     $search = ldap_read($ldapconn, $dn, USER::FILTER_USERS, array("cn", "mail", "displayName", "sn", "givenName", "memberOf"));
     if (ldap_count_entries($ldapconn, $search) > 0) {
         $entry = ldap_first_entry($ldapconn, $search);
         return User::readFromLdapEntry($ldapconn, $entry);
     }
 }
开发者ID:tmaex,项目名称:useradmin,代码行数:8,代码来源:user.inc.php


示例13: count_entries

 public function count_entries()
 {
     if (!empty($this->search)) {
         return ldap_count_entries($this->ds, $this->search);
     } else {
         throw new e_developer("Invalid count entries");
     }
 }
开发者ID:google-code-backups,项目名称:add-mvc-framework,代码行数:8,代码来源:add_ldap.class.php


示例14: getRecordCount

 /**
  * @see ResultSet::getRecordCount()
  */
 function getRecordCount()
 {
     $rows = @ldap_count_entries($this->result);
     if ($rows === null) {
         throw new SQLException("Error fetching num entries", ldap_error($this->conn->getResource()));
     }
     return (int) $rows;
 }
开发者ID:nmicht,项目名称:tlalokes-in-acst,代码行数:11,代码来源:LdapResultSet.php


示例15: _ldap

 /**
  *	LDAP storage handler
  *	@return bool
  *	@param $id string
  *	@param $pw string
  **/
 protected function _ldap($id, $pw)
 {
     $dc = @ldap_connect($this->args['dc']);
     if ($dc && ldap_set_option($dc, LDAP_OPT_PROTOCOL_VERSION, 3) && ldap_set_option($dc, LDAP_OPT_REFERRALS, 0) && ldap_bind($dc, $this->args['rdn'], $this->args['pw']) && ($result = ldap_search($dc, $this->args['base_dn'], 'uid=' . $id)) && ldap_count_entries($dc, $result) && ($info = ldap_get_entries($dc, $result)) && @ldap_bind($dc, $info[0]['dn'], $pw) && @ldap_close($dc)) {
         return $info[0]['uid'][0] == $id;
     }
     user_error(self::E_LDAP, E_USER_ERROR);
 }
开发者ID:max-weller,项目名称:fatfree-core,代码行数:14,代码来源:auth.php


示例16: ldap_mailhost_on_login

function ldap_mailhost_on_login($tools)
{
    // load the settings for this module
    require $tools->include_path . 'settings.php';
    // we're looking to find the user's imap server setting
    $imap_server = false;
    // user posted to login form
    if (isset($_POST['user'])) {
        $user = $_POST['user'];
        // check to see if the user specified their domain (user@domain)
        $domain = false;
        if (strstr($_POST['user'], '@') && strpos($_POST['user'], '@') < strlen($_POST['user'])) {
            $user = substr($_POST['user'], 0, strpos($_POST['user'], '@'));
            $domain = substr($_POST['user'], strpos($_POST['user'], '@') + 1);
        }
        // make sure we have safe input
        if (!preg_match($uid_pattern, $user)) {
            return;
        }
        if ($domain && !preg_match($domain_pattern, $domain)) {
            return;
        }
        // connect and bind to ldap
        if (!($connect = @ldap_connect($ldap_server))) {
            return;
        }
        if (!($bind = @ldap_bind($connect, $ldap_user, $ldap_pass))) {
            return;
        }
        // search for the user in the appropriate ldap base dn
        if (!($search = @ldap_search($connect, $domain ? sprintf($domain_base_format, $domain) : $default_base, sprintf($uid_filter_format, $user)))) {
            return;
        }
        // make sure we found one and only one user
        if (ldap_count_entries($connect, $search) != 1) {
            return;
        }
        // get the mailhost attribute from the user entry
        $info = ldap_get_entries($connect, $search);
        if ($info[0] && $info[0][$mailhost_attr] && $info[0][$mailhost_attr][0]) {
            $mailhost = $info[0][$mailhost_attr][0];
            // look up the mailhost value in the settings map to find
            // the corresponding imap_alt server
            foreach ($server_map as $alt_imap => $vals) {
                if ($mailhost == $vals) {
                    // if all went well
                    // we found the correct imap server to connect to
                    $_POST['imap_server'] = $alt_imap;
                    return;
                }
            }
        }
        // if something went wrong, the imap_server will remain whatever
        // the default imap_server setting is in hastymail.conf
        // depending on what that is set to, it will probably result in
        // and error to the user indicating that that imap server is down
    }
}
开发者ID:Hassanj343,项目名称:candidats,代码行数:58,代码来源:work.php


示例17: __construct

 /**
  * Constructor.
  *
  * @param  \Zend\Ldap\Ldap $ldap
  * @param  resource  $resultId
  * @return void
  */
 public function __construct(Ldap\Ldap $ldap, $resultId)
 {
     $this->_ldap = $ldap;
     $this->_resultId = $resultId;
     $this->_itemCount = @ldap_count_entries($ldap->getResource(), $resultId);
     if ($this->_itemCount === false) {
         throw new Ldap\Exception($this->_ldap, 'counting entries');
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:16,代码来源:DefaultIterator.php


示例18: search

 public function search($statement)
 {
     //returns false if there is a problem
     $results = array();
     $_search = ldap_search($this->_ldapCnx, $this->_baseDn, $statement, $this->_resultFields);
     $results['data'] = ldap_get_entries($this->_ldapCnx, $_search);
     $results['count'] = ldap_count_entries($this->_ldapCnx, $_search);
     return $results;
 }
开发者ID:spiro-stathakis,项目名称:projects,代码行数:9,代码来源:LdapComponent.php


示例19: login

 function login($uid, $pwd, $ip = 0)
 {
     // connect to ldap-server
     // echo ("Host: ".$this->host." Port: ".$this->port." BaseDN: ".$this->basedn." UID: $uid, PWD: $pwd \n<br>\n");
     if ($connect = @ldap_connect($this->host)) {
         // if connected to ldap server, check for protocol version
         if (!@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3)) {
             // echo "version 2<br>\n";
             $this->ldapver = 2;
         }
         // echo "verification on '$this->host': ";
         // bind to ldap connection
         if (($bind = @ldap_bind($connect)) == false) {
             // print "bind:__FAILED__<br>\n";
             return false;
         }
         // check whether we have an email address or an actual user id
         if (strpos($uid, '@') > 0) {
             $filter = "mail=" . $uid;
         } else {
             $filter = "uid=" . $uid;
         }
         // search for user
         if (($res_id = @ldap_search($connect, $this->basedn, $filter)) == false) {
             // print "failure: search in LDAP-tree failed<br>";
             return false;
         }
         if (@ldap_count_entries($connect, $res_id) != 1) {
             // print "failure: error looking up user $username<br>\n";
             return false;
         }
         if (($entry_id = @ldap_first_entry($connect, $res_id)) == false) {
             // print "failure: entry of searchresult couln't be fetched<br>\n";
             return false;
         }
         if (($user_dn = @ldap_get_dn($connect, $entry_id)) == false) {
             // print "failure: user-dn coulnd't be fetched<br>\n";
             return false;
         }
         // authenticate user
         if (($link_id = @ldap_bind($connect, $user_dn, $pwd)) == false) {
             // print "failure: username, password didn't match: $user_dn<br>\n";
             return false;
         }
         // login went fine, user login is ok
         @ldap_close($connect);
         $this->uid = $uid;
         return true;
     } else {
         // no conection to ldap server
         echo "no connection to '{$ldap_server}'<br>\n";
     }
     // echo "failed: ".ldap_error($connect)."<BR>\n";
     // something went wrong, cleanup and return false
     @ldap_close($connect);
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:57,代码来源:authLDAPUser.class.php


示例20: doSearch

 public function doSearch($filter)
 {
     $numEntries = 0;
     if (!$this->bindResult) {
         $this->connect();
     }
     @($this->searchResult = ldap_search($this->ldapConnection, $this->baseDN, $filter, $this->ldapAttributes));
     @($this->numEntries = ldap_count_entries($this->ldapConnection, $this->searchResult));
     return $this->numEntries;
 }
开发者ID:nyaray,项目名称:tekweb,代码行数:10,代码来源:lib_ldap.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ldap_delete函数代码示例发布时间:2022-05-15
下一篇:
PHP ldap_control_paged_result_response函数代码示例发布时间: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