You are here

public static function Server::ldapEscape in Lightweight Directory Access Protocol (LDAP) 8.3

Wrapper for ldap_escape().

Helpful for unit testing without the PHP LDAP module.

Parameters

string $string: String to escape.

Return value

mixed|string Escaped string.

2 calls to Server::ldapEscape()
Server::groupMembershipsFromEntryRecursive in ldap_servers/src/Entity/Server.php
Recurse through all groups, adding parent groups to $all_group_dns array.
Server::groupUserMembershipsFromUserAttr in ldap_servers/src/Entity/Server.php
Get list of groups that a user is a member of using the memberOf attribute.

File

ldap_servers/src/Entity/Server.php, line 499

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public static function ldapEscape($string) {
  if (function_exists('ldap_escape')) {
    return ldap_escape($string);
  }
  else {
    return str_replace([
      '*',
      '\\',
      '(',
      ')',
    ], [
      '\\*',
      '\\\\',
      '\\(',
      '\\)',
    ], $string);
  }
}