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

PHP ldap_control_paged_result函数代码示例

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

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



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

示例1: loadPage

 protected function loadPage()
 {
     if (!ldap_control_paged_result($this->connection, $this->pageSize, true, $this->pageToken)) {
         throw new SearchException("Unable to set paged control pageSize: " . $this->pageSize);
     }
     $search = ldap_search($this->connection, $this->baseDn, $this->filter, is_array($this->attributes) ? $this->attributes : []);
     if (!$search) {
         // Something went wrong in search
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     $this->entries = ldap_get_entries($this->connection, $search);
     $this->entriesPosition = 0;
     if (!$this->entries) {
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     // check if on first page
     if (empty($this->pageToken)) {
         $this->currentPage = 0;
     } else {
         $this->currentPage++;
     }
     // Ok go to next page
     ldap_control_paged_result_response($this->connection, $search, $this->pageToken);
     if (empty($this->pageToken)) {
         $this->isLastPage = true;
     }
 }
开发者ID:81square,项目名称:ldap,代码行数:27,代码来源:SearchIterator.php


示例2: getAvailableValues

 public function getAvailableValues()
 {
     if (!empty($this->fields['values'])) {
         $ldap_values = json_decode($this->fields['values']);
         $ldap_dropdown = new RuleRightParameter();
         if (!$ldap_dropdown->getFromDB($ldap_values->ldap_attribute)) {
             return array();
         }
         $attribute = array($ldap_dropdown->fields['value']);
         $config_ldap = new AuthLDAP();
         if (!$config_ldap->getFromDB($ldap_values->ldap_auth)) {
             return array();
         }
         if (!function_exists('warning_handler')) {
             function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext)
             {
                 if (0 === error_reporting()) {
                     return false;
                 }
                 throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
             }
         }
         set_error_handler("warning_handler", E_WARNING);
         try {
             $tab_values = array();
             $ds = $config_ldap->connect();
             ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
             $cookie = '';
             do {
                 if (AuthLDAP::isLdapPageSizeAvailable($config_ldap)) {
                     ldap_control_paged_result($ds, $config_ldap->fields['pagesize'], true, $cookie);
                 }
                 $result = ldap_search($ds, $config_ldap->fields['basedn'], $ldap_values->ldap_filter, $attribute);
                 $entries = ldap_get_entries($ds, $result);
                 array_shift($entries);
                 foreach ($entries as $id => $attr) {
                     if (isset($attr[$attribute[0]]) && !in_array($attr[$attribute[0]][0], $tab_values)) {
                         $tab_values[$id] = $attr[$attribute[0]][0];
                     }
                 }
                 if (AuthLDAP::isLdapPageSizeAvailable($config_ldap)) {
                     ldap_control_paged_result_response($ds, $result, $cookie);
                 }
             } while ($cookie !== null && $cookie != '');
             if ($this->fields['show_empty']) {
                 $tab_values = array('' => '-----') + $tab_values;
             }
             asort($tab_values);
             return $tab_values;
         } catch (Exception $e) {
             return array();
         }
         restore_error_handler();
     } else {
         return array();
     }
 }
开发者ID:CHCI74,项目名称:formcreator,代码行数:57,代码来源:ldapselect-field.class.php


示例3: searchAll

 /**
  * Search LDAP registry for entries matching filter and optional attributes
  * and return ALL values, including those beyond the usual 1000 entries, as an array.
  *
  * @param  string	$filter
  * @param  array	$attributes -OPTIONAL
  * @return array
  * @throws Exception\LdapException
  */
 public function searchAll($filter, array $attributes = [])
 {
     $ldap = $this->getResource();
     // $ds is a valid link identifier (see ldap_connect)
     ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
     $cookie = '';
     $result = [];
     do {
         ldap_control_paged_result($ldap, self::PAGE_SIZE, true, $cookie);
         Stdlib\ErrorHandler::start(E_WARNING);
         $search = ldap_search($ldap, $this->getBaseDn(), $filter, $attributes);
         Stdlib\ErrorHandler::stop();
         if ($search === false) {
             throw new Lp\Exception\LdapException($this, 'searching: ' . $filter);
         }
         $entries = $this->createCollection(new Lp\Collection\DefaultIterator($this, $search), null);
         foreach ($entries as $es) {
             $result[] = $es;
         }
         ldap_control_paged_result_response($ldap, $search, $cookie);
     } while ($cookie !== null && $cookie != '');
     return $result;
 }
开发者ID:diskerror,项目名称:utilities,代码行数:32,代码来源:Ldap.php


示例4: controlPagedResult

 /**
  * Send LDAP pagination control.
  *
  * @param int    $pageSize
  * @param bool   $isCritical
  * @param string $cookie
  *
  * @return bool
  *
  * @throws AdldapException
  */
 public function controlPagedResult($pageSize = 1000, $isCritical = false, $cookie = '')
 {
     if ($this->isPagingSupported()) {
         if ($this->suppressErrors) {
             return @ldap_control_paged_result($this->getConnection(), $pageSize, $isCritical, $cookie);
         }
         return ldap_control_paged_result($this->getConnection(), $pageSize, $isCritical, $cookie);
     }
     $message = 'LDAP Pagination is not supported on your current PHP installation.';
     throw new AdldapException($message);
 }
开发者ID:HarkiratGhotra,项目名称:application,代码行数:22,代码来源:Ldap.php


示例5: getGroupsFromLDAP

 /**
  * @since version 0.84 new parameter $limitexceeded
  *
  * @param $ldap_connection
  * @param $config_ldap
  * @param $filter
  * @param $search_in_groups         (true by default)
  * @param $groups             array
  * @param $limitexceeded
  **/
 static function getGroupsFromLDAP($ldap_connection, $config_ldap, $filter, $search_in_groups = true, $groups = array(), &$limitexceeded)
 {
     global $DB;
     //First look for groups in group objects
     $extra_attribute = $search_in_groups ? "cn" : $config_ldap->fields["group_field"];
     $attrs = array("dn", $extra_attribute);
     if ($filter == '') {
         if ($search_in_groups) {
             $filter = !empty($config_ldap->fields['group_condition']) ? $config_ldap->fields['group_condition'] : "(objectclass=*)";
         } else {
             $filter = !empty($config_ldap->fields['condition']) ? $config_ldap->fields['condition'] : "(objectclass=*)";
         }
     }
     $cookie = '';
     $count = 0;
     do {
         if (self::isLdapPageSizeAvailable($config_ldap)) {
             ldap_control_paged_result($ldap_connection, $config_ldap->fields['pagesize'], true, $cookie);
         }
         $filter = Toolbox::unclean_cross_side_scripting_deep($filter);
         $sr = @ldap_search($ldap_connection, $config_ldap->fields['basedn'], $filter, $attrs);
         if ($sr) {
             if (in_array(ldap_errno($ldap_connection), array(4, 11))) {
                 // openldap return 4 for Size limit exceeded
                 $limitexceeded = true;
             }
             $infos = self::get_entries_clean($ldap_connection, $sr);
             if (in_array(ldap_errno($ldap_connection), array(4, 11))) {
                 // openldap return 4 for Size limit exceeded
                 $limitexceeded = true;
             }
             $count += $infos['count'];
             //If page results are enabled and the number of results is greater than the maximum allowed
             //warn user that limit is exceeded and stop search
             if (self::isLdapPageSizeAvailable($config_ldap) && $config_ldap->fields['ldap_maxlimit'] && $count > $config_ldap->fields['ldap_maxlimit']) {
                 $limitexceeded = true;
                 break;
             }
             for ($ligne = 0; $ligne < $infos["count"]; $ligne++) {
                 if ($search_in_groups) {
                     // No cn : not a real object
                     if (isset($infos[$ligne]["cn"][0])) {
                         $cn = $infos[$ligne]["cn"][0];
                         $groups[$infos[$ligne]["dn"]] = array("cn" => $infos[$ligne]["cn"][0], "search_type" => "groups");
                     }
                 } else {
                     if (isset($infos[$ligne][$extra_attribute])) {
                         if ($config_ldap->fields["group_field"] == 'dn' || in_array('ou', $groups)) {
                             $dn = $infos[$ligne][$extra_attribute];
                             $ou = array();
                             for ($tmp = $dn; count($tmptab = explode(',', $tmp, 2)) == 2; $tmp = $tmptab[1]) {
                                 $ou[] = $tmptab[1];
                             }
                             /// Search in DB for group with ldap_group_dn
                             if ($config_ldap->fields["group_field"] == 'dn' && count($ou) > 0) {
                                 $query = "SELECT `ldap_value`\n                                     FROM `glpi_groups`\n                                     WHERE `ldap_group_dn`\n                                             IN ('" . implode("', '", Toolbox::addslashes_deep($ou)) . "')";
                                 foreach ($DB->request($query) as $group) {
                                     $groups[$group['ldap_value']] = array("cn" => $group['ldap_value'], "search_type" => "users");
                                 }
                             }
                         } else {
                             for ($ligne_extra = 0; $ligne_extra < $infos[$ligne][$extra_attribute]["count"]; $ligne_extra++) {
                                 $groups[$infos[$ligne][$extra_attribute][$ligne_extra]] = array("cn" => self::getGroupCNByDn($ldap_connection, $infos[$ligne][$extra_attribute][$ligne_extra]), "search_type" => "users");
                             }
                         }
                     }
                 }
             }
         }
         if (self::isLdapPageSizeAvailable($config_ldap)) {
             ldap_control_paged_result_response($ldap_connection, $sr, $cookie);
         }
     } while ($cookie !== null && $cookie != '');
     return $groups;
 }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:85,代码来源:authldap.class.php


示例6: ldap_mod_del

$dn = "cn=groupname,cn=groups,dc=example,dc=com";
echo "\nModDel " . $dn;
$entry['memberuid'] = "username";
ldap_mod_del($ds, $dn, $entry);
/* #### MOD REPLACE ### */
$dn = "cn=groupname,cn=groups,dc=example,dc=com";
echo "\nModReplace " . $dn;
$entry['memberuid'] = "username";
ldap_mod_replace($ds, $dn, $entry);
/* ### SEARCH ### */
$dn = "o=My Company, c=USs";
echo "\nSearch " . $dn;
$filter = "(|(sn=jeantet)(givenname=jeantet*))";
$justthese = array("ou", "sn", "givenname", "mail");
$cookie = 'cookie';
ldap_control_paged_result($ds, 23, true, $cookie);
$sr = ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo "\n\t" . $info["count"] . " entries returned";
// ldap_control_paged_result_response($ds, $sr, $cookie);
/* ### COMPARE ### */
$dn = "cn=Matti Meikku, ou=My Unit, o=My Company, c=FI";
echo "\nCompare " . $dn;
// Préparation des données
$value = "secretpassword";
$attr = "password";
// Comparaison des valeurs
$r = ldap_compare($ds, $dn, $attr, $value);
if ($r === -1) {
    echo "Error: " . ldap_error($ds);
} elseif ($r === true) {
开发者ID:postfix,项目名称:ldapserver,代码行数:31,代码来源:full.php


示例7: checkBeforeSave

 /**
  * Validate form fields before add or update a question
  *
  * @param  Array $input Datas used to add the item
  *
  * @return Array        The modified $input array
  *
  * @param  [type] $input [description]
  * @return [type]        [description]
  */
 private function checkBeforeSave($input)
 {
     // Control fields values :
     // - name is required
     if (empty($input['name'])) {
         Session::addMessageAfterRedirect(__('The title is required', 'formcreator'), false, ERROR);
         return array();
     }
     // - field type is required
     if (empty($input['fieldtype'])) {
         Session::addMessageAfterRedirect(__('The field type is required', 'formcreator'), false, ERROR);
         return array();
     }
     // - section is required
     if (empty($input['plugin_formcreator_sections_id'])) {
         Session::addMessageAfterRedirect(__('The section is required', 'formcreator'), false, ERROR);
         return array();
     }
     // Values are required for GLPI dropdowns, dropdowns, multiple dropdowns, checkboxes, radios, LDAP
     $itemtypes = array('select', 'multiselect', 'checkboxes', 'radios', 'ldap');
     if (empty($input['values']) && in_array($input['fieldtype'], $itemtypes)) {
         Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
         return array();
     }
     // Fields are differents for dropdown lists, so we need to replace these values into the good ones
     if ($input['fieldtype'] == 'dropdown') {
         if (empty($input['dropdown_values'])) {
             Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
             return array();
         }
         $input['values'] = $input['dropdown_values'];
         $input['default_values'] = isset($input['dropdown_default_value']) ? $input['dropdown_default_value'] : '';
     }
     // Fields are differents for GLPI object lists, so we need to replace these values into the good ones
     if ($input['fieldtype'] == 'glpiselect') {
         if (empty($input['glpi_objects'])) {
             Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
             return array();
         }
         $input['values'] = $input['glpi_objects'];
         $input['default_values'] = isset($input['dropdown_default_value']) ? $input['dropdown_default_value'] : '';
     }
     // A description field should have a description
     if ($input['fieldtype'] == 'description' && empty($input['description'])) {
         Session::addMessageAfterRedirect(__('A description field should have a description:', 'formcreator') . ' ' . $input['name'], false, ERROR);
         return array();
     }
     // format values for numbers
     if ($input['fieldtype'] == 'integer' || $input['fieldtype'] == 'float') {
         $input['default_values'] = !empty($input['default_values']) ? (double) str_replace(',', '.', $input['default_values']) : null;
         $input['range_min'] = !empty($input['range_min']) ? (double) str_replace(',', '.', $input['range_min']) : null;
         $input['range_max'] = !empty($input['range_max']) ? (double) str_replace(',', '.', $input['range_max']) : null;
     }
     // LDAP fields validation
     if ($input['fieldtype'] == 'ldapselect') {
         // Fields are differents for dropdown lists, so we need to replace these values into the good ones
         if (!empty($input['ldap_auth'])) {
             $config_ldap = new AuthLDAP();
             $config_ldap->getFromDB($input['ldap_auth']);
             $ldap_dropdown = new RuleRightParameter();
             $ldap_dropdown->getFromDB($input['ldap_attribute']);
             $attribute = array($ldap_dropdown->fields['value']);
             // Set specific error handler too catch LDAP errors
             if (!function_exists('warning_handler')) {
                 function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext)
                 {
                     if (0 === error_reporting()) {
                         return false;
                     }
                     throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
                 }
             }
             set_error_handler("warning_handler", E_WARNING);
             try {
                 $ds = $config_ldap->connect();
                 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
                 ldap_control_paged_result($ds, 1);
                 $sn = ldap_search($ds, $config_ldap->fields['basedn'], $input['ldap_filter'], $attribute);
                 $entries = ldap_get_entries($ds, $sn);
             } catch (Exception $e) {
                 Session::addMessageAfterRedirect(__('Cannot recover LDAP informations!', 'formcreator'), false, ERROR);
             }
             restore_error_handler();
             $input['values'] = json_encode(array('ldap_auth' => $input['ldap_auth'], 'ldap_filter' => $input['ldap_filter'], 'ldap_attribute' => strtolower($input['ldap_attribute'])));
         }
     }
     // Add leading and trailing regex marker automaticaly
     if (!empty($input['regex'])) {
         if (substr($input['regex'], 0, 1) != '/') {
             if (substr($input['regex'], 0, 1) != '^') {
//.........这里部分代码省略.........
开发者ID:CHCI74,项目名称:formcreator,代码行数:101,代码来源:question.class.php


示例8: searchRaw

 public function searchRaw($search = "*")
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     // Perform the search and grab all their details
     $filter = "(&(objectClass=user)(samaccounttype=" . adLDAP::ADLDAP_NORMAL_ACCOUNT . ")(objectCategory=person)(cn=" . $search . "))";
     $fields = array("samaccountname", "displayname");
     $pageSize = 25;
     $cookie = '';
     ldap_control_paged_result($this->adldap->getLdapConnection(), $pageSize, true, $cookie);
     $sr = ldap_search($this->adldap->getLdapConnection(), $this->adldap->getBaseDn(), $filter, $fields);
     $entries = ldap_get_entries($this->adldap->getLdapConnection(), $sr);
     ldap_control_paged_result_response($this->adldap->getLdapConnection(), $sr, $cookie);
     $return = [];
     foreach ($entries as $k => $r) {
         $comp = explode(",", $r['dn']);
         $cn = '';
         $ou = '';
         $dc = '';
         foreach ($comp as $c) {
             $x = explode("=", "{$c}");
             switch ($x[0]) {
                 case 'CN':
                     $cn = $x[1];
                     break;
                 case 'OU':
                     $ou = $x[1];
                     break;
                 case 'DC':
                     $dc .= $x[1] . ".";
                     break;
             }
         }
         if (count($r['samaccountname']) == 0) {
             continue;
         }
         $return[] = ['fullname' => isset($r['displayname']) ? @$r['displayname'][0] : @$r['samaccountname'][0], 'username' => @$r['samaccountname'][0], 'cn' => $cn, 'dc' => $dc, 'ou' => $ou];
     }
     return $return;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:41,代码来源:adLDAPUsers.php


示例9: resetPagingControl

 /**
  * Resets the paging control so that read operations work after a paging operation is used.
  *
  * @throws LdapConnectionException
  */
 public function resetPagingControl()
 {
     // Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.
     // However, testing this it doesn't seem to completely work. Perhaps a PHP bug?
     if (!@ldap_control_paged_result($this->connection->getConnection(), 0, false, $this->cookie)) {
         throw new LdapConnectionException(sprintf('Unable to reset paged results control for read operation: %s', $this->connection->getLastError()));
     }
 }
开发者ID:ldaptools,项目名称:ldaptools,代码行数:13,代码来源:PageControl.php


示例10: controlPagedResult

 /**
  * @link http://php.net/manual/en/function.ldap-control-paged-result.php
  * @param $link
  * @param $pagesize
  * @param bool $iscritical
  * @param string $cookie
  * @return bool
  */
 public function controlPagedResult($link, $pagesize, $iscritical = false, $cookie = "")
 {
     return ldap_control_paged_result($link, $pagesize, $iscritical, $cookie);
 }
开发者ID:CarnegieLearningWeb,项目名称:ldap-orm-bundle,代码行数:12,代码来源:Core.php


示例11: setControlPagedResult

 /**
  * Send LDAP pagination control.
  * @param int    $pageSize
  * @param bool   $isCritical
  * @param string $cookie
  * @return bool
  */
 public function setControlPagedResult($cookie)
 {
     return ldap_control_paged_result($this->resource, $this->pageSize, false, $cookie);
 }
开发者ID:chrmorandi,项目名称:yii2-ldap,代码行数:11,代码来源:Connection.php


示例12: ldap

 public function ldap()
 {
     set_time_limit(0);
     //$this->db->query("truncate px_tmp");
     $host = "192.168.5.3";
     $user = "zldcgroup\\zldc";
     $pswd = "zldc@8888";
     $cookie = '';
     $result = [];
     $result['count'] = 0;
     do {
         $ad = ldap_connect($host) or die("Could not connect!");
         //var_dump($ad);
         if ($ad) {
             //璁剧疆鍙傛暟
             ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
             ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
             // bool ldap_bind ( resource $link_identifier [, string $bind_rdn = NULL [, string $bind_password = NULL ]] )
             $bd = ldap_bind($ad, $user, $pswd) or die("Could not bind");
             ldap_control_paged_result($ad, 500, true, $cookie);
             $attrs = array("displayname", "name", "sAMAccountName", "userPrincipalName", "objectclass");
             //鎸囧畾闇�鏌ヨ鐨勭敤鎴疯寖鍥�
             $filter = "(objectclass=*)";
             //ldap_search ( resource $link_identifier , string $base_dn , string $filter [, array $attributes [, int $attrsonly [, int $sizelimit [, int $timelimit [, int $deref ]]]]] )
             $search = ldap_search($ad, 'ou=中梁集团,DC=zldcgroup,DC=com', $filter, $attrs, 0, 0, 0) or die("ldap search failed");
             $entries = ldap_get_entries($ad, $search);
             ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
             $result = array_merge($result, $entries);
             ldap_control_paged_result_response($ad, $search, $cookie);
             //echo json_encode($entries);
             //		var_dump($entries);
             $data = array();
             if ($entries["count"] > 0) {
                 //echo '返回记录数:'.$entries["count"];
                 for ($i = 0; $i < $entries["count"]; $i++) {
                     //所要获取的字段,都必须小写
                     //if(isset($entries[$i]["displayname"])){
                     //						echo "<p>name: ".$entries[$i]["name"][0]."<br />";//用户名
                     //						echo "<p>sAMAccountName: ".@$entries[$i]["samaccountname"][0]."<br />";//用户名
                     if (isset($entries[$i]["dn"][0])) {
                         //							echo "dn: ".$entries[$i]["dn"]."<br />";//用户名字
                         $is_user = in_array('user', $entries[$i]["objectclass"]) ? 1 : 0;
                         if ($is_user == 0) {
                             continue;
                         }
                         $dn = $entries[$i]["dn"];
                         $dn = explode(",", $dn);
                         $area = array();
                         foreach ($dn as $v) {
                             if (strpos($v, 'OU=') !== false) {
                                 array_push($area, str_replace("OU=", "", $v));
                                 //有的抬头不是OU
                             } else {
                                 if (strpos($v, 'CN=') !== false) {
                                     array_push($area, str_replace("CN=", "", $v));
                                     //有的抬头不是CN
                                 } else {
                                     if (strpos($v, 'DC=') !== false) {
                                         array_push($area, str_replace("DC=", "", $v));
                                         //有的抬头不是DC
                                     }
                                 }
                             }
                         }
                         $area = array_reverse($area);
                         $insertArr = array();
                         $flag = 1;
                         if (is_array($area)) {
                             $flag = count($area, COUNT_NORMAL);
                         }
                         //							var_dump($area);
                         //	list($f6,$f5,$f4,$f3,$f2,$f1) = $area;
                         foreach ($area as $val) {
                             $keyStr = 'F' . $flag;
                             $flag--;
                             $insertArr[$keyStr] = $val;
                         }
                         $insertArr['FISUSER'] = 1;
                         $insertArr['FNUMBER'] = $entries[$i]["samaccountname"][0];
                         $insertArr['FNAME'] = $entries[$i]["name"][0];
                         $insertArr['FORG'] = 'test';
                         if (is_array($area)) {
                             if (count($area, COUNT_NORMAL) >= 7) {
                                 //echo "test 5  ";
                             }
                         }
                         $where = 'FNUMBER = ' . $entries[$i]["samaccountname"][0];
                         $tableName = 'T_USER';
                         $this->db->select('*');
                         $this->db->where('FNUMBER', $entries[$i]["samaccountname"][0]);
                         $row = $this->db->get('T_USER')->row_array();
                         if (isset($row)) {
                             $result = $this->Tools->updateDataWithFID($insertArr, $tableName, $row['FID']);
                         } else {
                             $result = $this->Tools->addData($insertArr, $tableName);
                         }
                     }
                 }
                 //}
             } else {
//.........这里部分代码省略.........
开发者ID:hardcao,项目名称:CiProject,代码行数:101,代码来源:Ldap.php


示例13: group_info

 /**
  * Group Information.  Returns an array of information about a group.
  * The group name is case sensitive
  * 
  * @param string $group_name The group name to retrieve info about
  * @param array $fields Fields to retrieve
  * @return array
  */
 public function group_info($group_name, $fields = NULL)
 {
     if ($group_name === NULL) {
         return false;
     }
     if (!$this->_bind) {
         return false;
     }
     if (stristr($group_name, '+')) {
         $group_name = stripslashes($group_name);
     }
     $filter = "(&(objectCategory=group)(name=" . $this->ldap_slashes($group_name) . "))";
     //echo ($filter."!!!<br>");
     if ($fields === NULL) {
         $fields = array("member", "memberof", "cn", "description", "distinguishedname", "objectcategory", "samaccountname");
     }
     // Let's use paging if available
     if (function_exists('ldap_control_paged_result')) {
         $pageSize = 500;
         $cookie = '';
         $entries = array();
         $entries_page = array();
         do {
             ldap_control_paged_result($this->_conn, $pageSize, true, $cookie);
             $sr = ldap_search($this->_conn, $this->_base_dn, $filter, $fields);
             $entries_page = ldap_get_entries($this->_conn, $sr);
             if (!is_array($entries_page)) {
                 return false;
             }
             $entries = array_merge($entries, $entries_page);
             ldap_control_paged_result_response($this->_conn, $sr, $cookie);
         } while ($cookie !== null && $cookie != '');
         $entries['count'] = count($entries) - 1;
         // Set a new count value !important!
         ldap_control_paged_result($this->_conn, $pageSize, true, $cookie);
         // RESET is important
     } else {
         // Non-Paged version
         $sr = ldap_search($this->_conn, $this->_base_dn, $filter, $fields);
         $entries = ldap_get_entries($this->_conn, $sr);
     }
     //print_r($entries);
     return $entries;
 }
开发者ID:kc596,项目名称:cse.nits.ac.in,代码行数:52,代码来源:adLDAP.php


示例14: initPagedSearch

 /**
  * @brief prepares a paged search, if possible
  * @param $filter the LDAP filter for the search
  * @param $base the LDAP subtree that shall be searched
  * @param $attr optional, when a certain attribute shall be filtered outside
  * @param $limit
  * @param $offset
  *
  */
 private function initPagedSearch($filter, $base, $attr, $limit, $offset)
 {
     $pagedSearchOK = false;
     if ($this->connection->hasPagedResultSupport && !is_null($limit)) {
         $offset = intval($offset);
         //can be null
         \OCP\Util::writeLog('user_ldap', 'initializing paged search for  Filter' . $filter . ' base ' . $base . ' attr ' . print_r($attr, true) . ' limit ' . $limit . ' offset ' . $offset, \OCP\Util::DEBUG);
         //get the cookie from the search for the previous search, required by LDAP
         $cookie = $this->getPagedResultCookie($filter, $limit, $offset);
         if (empty($cookie) && $offset > 0) {
             //no cookie known, although the offset is not 0. Maybe cache run out. We need to start all over *sigh* (btw, Dear Reader, did you need LDAP paged searching was designed by MSFT?)
             $reOffset = $offset - $limit < 0 ? 0 : $offset - $limit;
             //a bit recursive, $offset of 0 is the exit
             \OCP\Util::writeLog('user_ldap', 'Looking for cookie L/O ' . $limit . '/' . $reOffset, \OCP\Util::INFO);
             $this->search($filter, $base, $attr, $limit, $reOffset, true);
             $cookie = $this->getPagedResultCookie($filter, $limit, $offset);
             //still no cookie? obviously, the server does not like us. Let's skip paging efforts.
             //TODO: remember this, probably does not change in the next request...
             if (empty($cookie)) {
                 $cookie = null;
             }
         }
         if (!is_null($cookie)) {
             if ($offset > 0) {
                 \OCP\Util::writeLog('user_ldap', 'Cookie ' . $cookie, \OCP\Util::INFO);
             }
             $pagedSearchOK = ldap_control_paged_result($this->connection->getConnectionResource(), $limit, false, $cookie);
             \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::INFO);
         } else {
             \OCP\Util::writeLog('user_ldap', 'No paged search for us, Cpt., Limit ' . $limit . ' Offset ' . $offset, \OCP\Util::INFO);
         }
     }
     return $pagedSearchOK;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:43,代码来源:access.php


示例15: retrieve

 /**
  * The core of ORM behavior for this bundle: retrieve data
  * from LDAP and convert results into objects.
  *
  * Options maybe:
  *
  *      attributes (array): array of attribute types (strings)
  *
  *      filter (LdapFilter): a filter array or a correctly formatted filter string
  *
  *      max (integer): the maximum limit of entries to return
  *
  *      searchDn (string): the search DN
  *
  *      subentryNodes (array): parameters for the left hand side of a searchDN, useful for mining subentries.
  *
  *      pageSize (integer): employ pagination and return pages of the given size
  *
  *      pageCookie (opaque): The opaque stucture sent by the LDAP server to maintain pagination state. Default is empty string.
  *
  *      pageCritical (boolean): if pagination employed, force paging and return no results on service which do not provide it. Default is true.
  *
  *      checkOnly (boolean): Only check result existence; don't convert search results to Symfony entities. Default is false.
  *
  * @param string $entityName
  * @param array $options
  * @return array
  * @throws MissingSearchDnException
  */
 public function retrieve($entityName, $options = array())
 {
     $paging = !empty($options['pageSize']);
     $instanceMetadataCollection = $this->getClassMetadata($entityName);
     // Discern max result size
     $max = empty($options['max']) ? self::DEFAULT_MAX_RESULT_COUNT : $options['max'];
     // Employ results paging if requested with pageSize option
     if ($paging) {
         if (!isset($options['pageCritical'])) {
             $options['pageCritical'] = FALSE;
         }
         if (isset($options['pageCookie'])) {
             $this->pageCookie = $options['pageCookie'];
         }
         ldap_control_paged_result($this->client->getLdapResource(), $options['pageSize'], $options['pageCritical'], $this->pageCookie);
     }
     // Discern subentryNodes for substituing into searchDN
     $subentryNodes = empty($options['subentryNodes']) ? array() : $options['subentryNodes'];
     // Discern search DN
     if (isset($options['searchDn'])) {
         $searchDn = $options['searchDn'];
     } else {
         $searchDn = $instanceMetadataCollection->getSearchDn();
     }
     if (empty($searchDn)) {
         throw new MissingSearchDnException('Could not discern search DN while searching for ' . $entityName);
     }
     // Discern LDAP filter
     $objectClass = $instanceMetadataCollection->getObjectClass();
     if (empty($options['filter'])) {
         $filter = '(objectClass=' . $objectClass . ')';
     } else {
         if (is_array($options['filter'])) {
             $options['filter'] = array('&' => array('objectClass' => $objectClass, $options['filter']));
             $ldapFilter = new LdapFilter($options['filter']);
             $filter = $ldapFilter->format();
         } else {
             if (is_a($options['filter'], LdapFilter::class)) {
                 $options['filter']->setFilterArray(array('&' => array('objectClass' => $objectClass, $options['filter']->getFilterArray())));
                 $filter = $options['filter']->format();
             } else {
                 // assume pre-formatted scale/string filter value
                 $filter = '(&(objectClass=' . $objectClass . ')' . $options['filter'] . ')';
             }
         }
     }
     // Discern attributes to retrieve
     if (empty($options['attributes'])) {
         $attributes = array_values($instanceMetadataCollection->getMetadatas());
     } else {
         $attributes = $options['attributes'];
     }
     // Search LDAP
     $searchResult = $this->doRawLdapSearch($filter, $attributes, $max, $searchDn);
     $entries = @ldap_get_entries($this->client->getLdapResource(), $searchResult);
     if (!empty($options['checkOnly']) && $options['checkOnly'] == true) {
         return $entries['count'] > 0;
     }
     $entities = array();
     foreach ($entries as $entry) {
         if (is_array($entry)) {
             $entities[] = $this->entryToEntity($entityName, $entry);
         }
     }
     if ($paging) {
         ldap_control_paged_result_response($this->client->getLdapResource(), $searchResult, $this->pageCookie);
         $this->pageMore = !empty($this->pageCookie);
     }
     if ($entries['count'] == 1) {
         return $entities[0];
     }
//.........这里部分代码省略.........
开发者ID:t73biz,项目名称:ldap-orm-bundle,代码行数:101,代码来源:LdapEntityManager.php


示例16: findLdapUsers

 /**
  * Searches LDAP
  *
  * @author [A. Gianotto] [<[email protected]>]
  * @since [v3.0]
  * @param $ldapatttibutes
  * @return array|bool
  */
 static function findLdapUsers()
 {
     $ldapconn = Ldap::connectToLdap();
     $ldap_bind = Ldap::bindAdminToLdap($ldapconn);
     $base_dn = Setting::getSettings()->ldap_basedn;
     $filter = Setting::getSettings()->ldap_filter;
     // Set up LDAP pagination for very large databases
     // @author Richard Hofman
     $page_size = 500;
     $cookie = '';
     $result_set = array();
     $global_count = 0;
     // Perform the search
     do {
         // Paginate (non-critical, if not supported by server)
         ldap_control_paged_result($ldapconn, $page_size, false, $cookie);
         $search_results = ldap_search($ldapconn, $base_dn, '(' . $filter . ')');
         if (!$search_results) {
             return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_search') . ldap_error($ldapconn));
         }
         // Get results from page
         $results = ldap_get_entries($ldapconn, $search_results);
         if (!$results) {
             return redirect()->route('users')->with('error', trans('admin/users/message.error.ldap_could_not_get_entries') . ldap_error($ldapconn));
         }
         // Add results to result set
         $global_count += $results['count'];
         $result_set = array_merge($result_set, $results);
         ldap_control_paged_result_response($ldapconn, $search_results, $cookie);
     } while ($cookie !== null && $cookie != '');
     // Clean up after search
     $result_set['count'] = $global_count;
     $results = $result_set;
     ldap_control_paged_result($ldapconn, 0);
     return $results;
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:44,代码来源:Ldap.php


示例17: QueryArray

 function QueryArray($str = '(ObjectClass=*)', $fields = false)
 {
     global $APPLICATION;
     if (strlen($this->arFields['BASE_DN']) <= 0) {
         return false;
     }
     $arBaseDNs = explode(";", $this->arFields['BASE_DN']);
     $info = false;
     $i = 0;
     if ($this->arFields["CONVERT_UTF8"] == "Y") {
         $str = $APPLICATION->ConvertCharset($str, SITE_CHARSET, "utf-8");
     }
     foreach ($arBaseDNs as $BaseDN) {
         global $APPLICATION;
         $BaseDN = trim($BaseDN);
         if ($BaseDN == "") {
             continue;
         }
         if ($this->arFields["CONVERT_UTF8"] == "Y") {
             $BaseDN = $APPLICATION->ConvertCharset($BaseDN, SITE_CHARSET, "utf-8");
         }
         $defaultMaxPageSizeAD = 1000;
         $pageSize = isset($this->arFields['MAX_PAGE_SIZE']) && intval($this->arFields['MAX_PAGE_SIZE'] > 0) ? intval($this->arFields['MAX_PAGE_SIZE']) : $defaultMaxPageSizeAD;
         $cookie = '';
         do {
             if (CLdapUtil::isLdapPaginationAviable()) {
                 ldap_control_paged_result($this->conn, $pageSize, false, $cookie);
             }
             if ($fields === false) {
                 $sr = @ldap_search($this->conn, $BaseDN, $str);
             } else {
                 $sr = @ldap_search($this->conn, $BaseDN, $str, $fields);
             }
             if ($sr) {
                 $entry = ldap_first_entry($this->conn, $sr);
                 if ($entry) {
                     if (!is_array($info)) {
                         $info = array();
                         $i = 0;
                     }
                     do {
                         $attributes = ldap_get_attributes($this->conn, $entry);
                         for ($j = 0; $j < $attributes['count']; $j++) {
                             $values = @ldap_get_values_len($this->conn, $entry, $attributes[$j]);
                             if ($values === false) {
                                 continue;
                             }
                             $bPhotoAttr = in_array($attributes[$j], self::$PHOTO_ATTRIBS);
                             $info[$i][strtolower($attributes[$j])] = $bPhotoAttr ? $values : $this->WorkAttr($values);
                         }
                         if (!is_set($info[$i], 'dn')) {
                             if ($this->arFields["CONVERT_UTF8"] == "Y") {
                                 $info[$i]['dn'] = $APPLICATION->ConvertCharset(ldap_get_dn($this->conn, $entry), "utf-8", SITE_CHARSET);
                             } else {
                                 $info[$i]['dn'] = ldap_get_dn($this->conn, $entry);
                             }
                         }
                         $i++;
                     } while ($entry = ldap_next_entry($this->conn, $entry));
                 }
             } elseif ($sr === false) {
                 $APPLICATION->ThrowException("LDAP_SEARCH_ERROR");
             }
             if (CLdapUtil::isLdapPaginationAviable()) {
                 ldap_control_paged_result_response($this->conn, $sr, $cookie);
             }
         } while ($cookie !== null && $cookie != '');
     }
     return $info;
 }
                      

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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