PHP.mk документација

ldap_escape

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.ldap-escape.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.ldap-escape.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ldap_escape

Референца за `function.ldap-escape.php` со подобрена типографија и навигација.

function.ldap-escape.php

ldap_escape

(PHP 5 >= 5.6.0, PHP 7, PHP 8)

ldap_escape(PHP 5 >= 5.6.0, PHP 7, PHP 8)

= NULL

ldap_escape(string $value, string $ignore = "", int $flags = 0): string

Escape a string for use in an LDAP filter or DN value Escapes flags.

Параметри

value

for use in the context implied by

ignore

The value to escape.

flags

Characters to ignore when escaping. LDAP_ESCAPE_FILTER The context the escaped string will be used in: ldap_search(), или LDAP_ESCAPE_DN for filters to be used with

Вратени вредности

Враќа избегнатиот стринг.

Примери

for DNs. If neither flag is passed, all chars are escaped.

When building an LDAP filter, you should use ldap_escape with LDAP_ESCAPE_FILTER flag.

<?php
// $ds is a valid LDAP\Connection instance for a directory server

// $mail is an email address provided by the user in a form

$base = "o=My Company, c=US";
$filter = "(mail=".ldap_escape($mail, "", LDAP_ESCAPE_FILTER).")";

$sr = ldap_search($ds, $base, $filter, array("sn", "givenname", "mail"));

$info = ldap_get_entries($ds, $sr);

echo
$info["count"]." entries returned\n";
?>

Белешки од корисници 2 забелешки

Example #1 Searching for an email address
пред 6 години
Suppose you want to reverse the operation, here is a way to "ldap_unescape"

<?php

function ldap_unescape($string) {
    return
        preg_replace_callback(
            "/\\\\[\da-z]{2}/",
            function ($matches) {
                $match = array_shift($matches);
                return hex2bin(substr($match, 1));
            },
            $string
        );
}

$result = ldap_unescape("uid=\\61\\6c\\70\\68\\6f\\6e\\7a\\6f,ou=people,dc=foo,dc=com"); // uid=alphonzo,ou=people,dc=foo,dc=com

?>
support at extollit dot com
пред 10 години
You can use it like this for filtering

<?php
$badSearchInput = 'Domain\username';

$escapedSearchInput = ldap_escape($badSearchInput, null, LDAP_ESCAPE_FILTER);
?>
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.