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


PHP ldap_read函数代码示例

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


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

示例1: _RootDSE

 function _RootDSE($filtr)
 {
     $sr = ldap_read($this->conn, '', 'objectClass=*', array($filtr), 0);
     //$sr = ldap_read($this->conn, '', 'objectClass=*');
     $entry = ldap_first_entry($this->conn, $sr);
     $attributes = ldap_get_attributes($this->conn, $entry);
     $values = false;
     if ($attributes['count'] > 0) {
         $values = @ldap_get_values_len($this->conn, $entry, $filtr);
     }
     return $values;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:12,代码来源:ldap.php

示例2: xldap_user_group_check

function xldap_user_group_check($ldap, $userdn, $groupdn, $recurs_count = 16)
{
    if ($recurs_count <= 0) {
        return FALSE;
    }
    $attributes = array('memberof');
    $result = ldap_read($ldap, $userdn, '(objectclass=*)', $attributes);
    if ($result === FALSE) {
        return FALSE;
    }
    $entries = ldap_get_entries($ldap, $result);
    if ($entries['count'] <= 0) {
        return FALSE;
    }
    if (empty($entries[0]['memberof'])) {
        return FALSE;
    } else {
        for ($i = 0; $i < $entries[0]['memberof']['count']; $i++) {
            if ($entries[0]['memberof'][$i] == $groupdn) {
                return TRUE;
            } else {
                if ($recurs_count > 1) {
                    if (xldap_user_group_check($ldap, $entries[0]['memberof'][$i], $groupdn, $recurs_count - 1)) {
                        return TRUE;
                    }
                }
            }
        }
    }
    return FALSE;
}
开发者ID:BestianRU,项目名称:AD-LDAP-Auth,代码行数:31,代码来源:auth.php

示例3: get_ldap_cn

function get_ldap_cn($user, $debug = 0)
{
    try {
        if (!($ds = get_ldap_connection())) {
            throw new Exception('Unable to connect to LDAP Server');
        }
        $dn = "mail={$user}, o=com, dc=mozilla";
        //the object itself instead of the top search level as in ldap_search
        $filter = "(objectclass=inetOrgPerson)";
        // this command requires some filter
        $justthese = array("cn");
        //the attributes to pull, which is much more efficient than pulling all attributes if you don't do this
        if (!($sr = ldap_read($ds, $dn, $filter, $justthese))) {
            throw new Exception('Incorrect Username or filter');
        }
        if (!($entry = ldap_get_entries($ds, $sr))) {
            throw new Exception('Unable to find LDAP entry for ' . $user);
        }
        if ($debug != 0) {
            echo $entry[0]["cn"][0] . " is the name in LDAP for " . $user;
        }
        ldap_close($ds);
        return $entry[0]["cn"][0];
    } catch (Exception $e) {
        echo 'Oops! I countered the following error: ', $e->getMessage(), "\n";
    }
}
开发者ID:rkulan007,项目名称:tableau-portal,代码行数:27,代码来源:get_cn.php

示例4: readAttribute

 /**
  * @brief reads a given attribute for an LDAP record identified by a DN
  * @param $dn the record in question
  * @param $attr the attribute that shall be retrieved
  * @returns the values in an array on success, false otherwise
  *
  * Reads an attribute from an LDAP entry
  */
 public function readAttribute($dn, $attr)
 {
     if (!$this->checkConnection()) {
         \OCP\Util::writeLog('user_ldap', 'No LDAP Connector assigned, access impossible for readAttribute.', \OCP\Util::WARN);
         return false;
     }
     $cr = $this->connection->getConnectionResource();
     if (!is_resource($cr)) {
         //LDAP not available
         \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
         return false;
     }
     $rr = @ldap_read($cr, $dn, 'objectClass=*', array($attr));
     if (!is_resource($rr)) {
         \OCP\Util::writeLog('user_ldap', 'readAttribute ' . $attr . ' failed for DN ' . $dn, \OCP\Util::DEBUG);
         //in case an error occurs , e.g. object does not exist
         return false;
     }
     $er = ldap_first_entry($cr, $rr);
     //LDAP attributes are not case sensitive
     $result = \OCP\Util::mb_array_change_key_case(ldap_get_attributes($cr, $er), MB_CASE_LOWER, 'UTF-8');
     $attr = mb_strtolower($attr, 'UTF-8');
     if (isset($result[$attr]) && $result[$attr]['count'] > 0) {
         $values = array();
         for ($i = 0; $i < $result[$attr]['count']; $i++) {
             $values[] = $this->resemblesDN($attr) ? $this->sanitizeDN($result[$attr][$i]) : $result[$attr][$i];
         }
         return $values;
     }
     \OCP\Util::writeLog('user_ldap', 'Requested attribute ' . $attr . ' not found for ' . $dn, \OCP\Util::DEBUG);
     return false;
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:40,代码来源:access.php

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

示例6: readEntry

 /**
  * @param string $dn         the dn to read
  * @param string $filter     the filter
  * @param array  $attributes the attributes to be returned
  *
  * @return array
  * @throws \Exception
  */
 public function readEntry($dn, $filter, array $attributes)
 {
     $result = @ldap_read($this->connection, $dn, $filter, $attributes);
     if ($result === false) {
         throw new \Exception("invalid bla");
     }
     $entries = ldap_get_entries($this->connection, $result);
     return $entries;
 }
开发者ID:dittertp,项目名称:libldap,代码行数:17,代码来源:LibLdap.php

示例7: getRootDse

 /**
  * Get Root DSE
  *
  * @param	array	Attributes to return.  By default all attributes will be returned
  * @return	array	Requested attributes
  */
 protected function getRootDse($attributes = null)
 {
     if ($attributes === null) {
         $result = ldap_read($this->connection, NULL, 'objectClass=*');
     } else {
         $result = ldap_read($this->connection, NULL, 'objectClass=*', $attributes);
     }
     $entries = ldap_get_entries($this->connection, $result);
     return $entries;
 }
开发者ID:rokett,项目名称:ldapHelper,代码行数:16,代码来源:ldap.class.php

示例8: ldap_search_withScope

function ldap_search_withScope($ds, $basedn, $filter, $attrlist, $scope)
{
    if ($scope == "base") {
        $search = ldap_read($ds, $basedn, $filter, $attrlist);
    } elseif ($scope == "one") {
        $search = ldap_list($ds, $basedn, $filter, $attrlist);
    } elseif ($scope == "sub") {
        $search = ldap_search($ds, $basedn, $filter, $attrlist);
    }
    return $search;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:11,代码来源:ldap-functions.php

示例9: getUserInfo

 /**
  * Reads all objects.
  *
  * @return array
  */
 public function getUserInfo()
 {
     if ($this->authenticated) {
         if (empty($this->userData)) {
             $rs = ldap_read($this->connection, $this->dn, "(objectclass=*)");
             $this->userData = ldap_get_entries($this->connection, $rs);
         }
         return $this->userData;
     }
     return [];
 }
开发者ID:rajeshpillai,项目名称:df-adldap,代码行数:16,代码来源:OpenLdap.php

示例10: readAttribute

 /**
  * @brief reads a given attribute for an LDAP record identified by a DN
  * @param $dn the record in question
  * @param $attr the attribute that shall be retrieved
  *        if empty, just check the record's existence
  * @returns an array of values on success or an empty
  *          array if $attr is empty, false otherwise
  *
  * Reads an attribute from an LDAP entry or check if entry exists
  */
 public function readAttribute($dn, $attr, $filter = 'objectClass=*')
 {
     if (!$this->checkConnection()) {
         \OCP\Util::writeLog('user_ldap', 'No LDAP Connector assigned, access impossible for readAttribute.', \OCP\Util::WARN);
         return false;
     }
     $cr = $this->connection->getConnectionResource();
     if (!is_resource($cr)) {
         //LDAP not available
         \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
         return false;
     }
     $dn = $this->DNasBaseParameter($dn);
     $rr = @ldap_read($cr, $dn, $filter, array($attr));
     if (!is_resource($rr)) {
         if (!empty($attr)) {
             //do not throw this message on userExists check, irritates
             \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, \OCP\Util::DEBUG);
         }
         //in case an error occurs , e.g. object does not exist
         return false;
     }
     if (empty($attr)) {
         \OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', \OCP\Util::DEBUG);
         return array();
     }
     $er = ldap_first_entry($cr, $rr);
     if (!is_resource($er)) {
         //did not match the filter, return false
         return false;
     }
     //LDAP attributes are not case sensitive
     $result = \OCP\Util::mb_array_change_key_case(ldap_get_attributes($cr, $er), MB_CASE_LOWER, 'UTF-8');
     $attr = mb_strtolower($attr, 'UTF-8');
     if (isset($result[$attr]) && $result[$attr]['count'] > 0) {
         $values = array();
         for ($i = 0; $i < $result[$attr]['count']; $i++) {
             if ($this->resemblesDN($attr)) {
                 $values[] = $this->sanitizeDN($result[$attr][$i]);
             } elseif (strtolower($attr) == 'objectguid' || strtolower($attr) == 'guid') {
                 $values[] = $this->convertObjectGUID2Str($result[$attr][$i]);
             } else {
                 $values[] = $result[$attr][$i];
             }
         }
         return $values;
     }
     \OCP\Util::writeLog('user_ldap', 'Requested attribute ' . $attr . ' not found for ' . $dn, \OCP\Util::DEBUG);
     return false;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:60,代码来源:access.php

示例11: install_etape_ldap3_dist

function install_etape_ldap3_dist()
{
    $adresse_ldap = _request('adresse_ldap');
    $login_ldap = _request('login_ldap');
    $pass_ldap = _request('pass_ldap');
    $port_ldap = _request('port_ldap');
    $base_ldap_text = defined('_INSTALL_BASE_LDAP') ? _INSTALL_BASE_LDAP : "ou=users, dc=mon-domaine, dc=com";
    echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
    echo info_etape(_T('info_chemin_acces_1'), info_progression_etape(3, 'etape_ldap', 'install/')), _T('info_chemin_acces_2');
    $ldap_link = @ldap_connect("{$adresse_ldap}", "{$port_ldap}");
    if ($ldap_link) {
        @ldap_bind($ldap_link, "{$login_ldap}", "{$pass_ldap}");
        $result = @ldap_read($ldap_link, "", "objectclass=*", array("namingContexts"));
        $info = @ldap_get_entries($ldap_link, $result);
        @ldap_close($ldap_link);
    }
    $checked = false;
    $res = '';
    if (is_array($info) and $info["count"] > 0) {
        $res .= "<p>" . _T('info_selection_chemin_acces') . "</p>";
        $res .= "<ul>";
        $n = 0;
        for ($i = 0; $i < $info["count"]; $i++) {
            $names = $info[$i]["namingcontexts"];
            if (is_array($names)) {
                for ($j = 0; $j < $names["count"]; $j++) {
                    $n++;
                    $res .= "<li><input name=\"base_ldap\" value=\"" . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab{$n}'";
                    if (!$checked) {
                        $res .= " checked=\"checked\"";
                        $checked = true;
                    }
                    $res .= " />";
                    $res .= "<label for='tab{$n}'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n";
                }
            }
        }
        $res .= "</ul>";
        $res .= _T('info_ou') . " ";
    }
    $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'";
    if (!$checked) {
        $res .= " checked=\"checked\"";
        $checked = true;
    }
    $res .= " />" . "\n<label for='manuel'>" . _T('entree_chemin_acces') . "</label> " . "\n<fieldset>" . "<input type='text' name='base_ldap_text' class='text' value=\"{$base_ldap_text}\" size='40' />" . "\n</fieldset>" . "\n<input type='hidden' name='etape' value='ldap4' />" . install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) . bouton_suivant();
    echo generer_form_ecrire('install', $res);
    echo install_fin_html();
}
开发者ID:JLuc,项目名称:SPIP,代码行数:49,代码来源:etape_ldap3.php

示例12: ReadEntry

 public function ReadEntry($dn, $attribs)
 {
     //foreach($attribs as &$attrib)
     //	$attrib = strtolower($attrib);
     $filter = '(objectclass=*)';
     $sr = ldap_read($this->con, $dn, $filter, $attribs);
     if ($sr === false) {
         return false;
     }
     $entry = ldap_get_entries($this->con, $sr);
     if ($entry === false) {
         return false;
     }
     return $entry;
 }
开发者ID:hoangsoft90,项目名称:cpanel-manager,代码行数:15,代码来源:LdapDb.inc.php

示例13: getUserAttributes

 public function getUserAttributes()
 {
     $fname_tag = qa_opt('ldap_login_fname');
     $sname_tag = qa_opt('ldap_login_sname');
     $mail_tag = qa_opt('ldap_login_mail');
     $filter = qa_opt('ldap_login_filter');
     $attributes = array('dn', $fname_tag, $sname_tag, $mail_tag);
     // The DN is known so just use it to read attributes
     $read = ldap_read($this->con, $this->dn, $filter, $attributes);
     $data = ldap_get_entries($this->con, $read);
     $fname = $data[0][strtolower($fname_tag)][0];
     $sname = $data[0][strtolower($sname_tag)][0];
     $mail = $data[0][strtolower($mail_tag)][0];
     return array($fname, $sname, $mail, $this->authenticatedUser);
 }
开发者ID:neobubbaloo82,项目名称:qa-ldap-login,代码行数:15,代码来源:ActiveDirectoryLDAPServer.php

示例14: read

 public function read($dn = NULL)
 {
     $dn = $dn ? $dn : $this->dn;
     # default to self
     $attrs = array('givenname', 'surname', 'displayname', 'title', 'mail', 'mobile', 'telephonenumber', 'uid');
     $result = ldap_read($this->conn, $dn, $this->filter, $attrs);
     if (!$result) {
         throw new LDAPAuthError();
     }
     $entries = ldap_get_entries($this->conn, $result);
     if ($entries === false) {
         throw new LDAPAuthError();
     }
     return $this->flatten($entries[0]);
 }
开发者ID:btalayminaei,项目名称:DGSecurity,代码行数:15,代码来源:ldap.php

示例15: getUserAttributesByDn

 private function getUserAttributesByDn($userDn)
 {
     $query = @ldap_read($this->ldapConnection, $userDn, "(objectClass=*)", array_values($this->config->s('LdapVootStorage')->s('attributeMapping')->toArray()));
     if (false === $query) {
         throw new VootStorageException("ldap_error", "directory query for user failed");
     }
     $entry = @ldap_first_entry($this->ldapConnection, $query);
     if (false === $entry) {
         throw new VootStorageException("not_found", "user not found");
     }
     $attributes = @ldap_get_attributes($this->ldapConnection, $entry);
     if (false === $attributes) {
         throw new VootStorageException("ldap_error", "unable to get user attributes");
     }
     $filteredAttributes = $this->filterAttributes($attributes);
     return $filteredAttributes;
 }
开发者ID:preemeijer,项目名称:php-voot-provider,代码行数:17,代码来源:LdapVootStorage.php


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