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


PHP ldap_count_entries函数代码示例

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


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


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