function ldap_server_massage_text in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.functions.inc \ldap_server_massage_text()
- 7.2 ldap_servers/ldap_servers.functions.inc \ldap_server_massage_text()
function to massage (change case, escape, unescape) ldap attribute names and values. The primary purpose of this is to articulate and ensure consistency across ldap modules.
Parameters
mixed $value to be massaged:
enum $value_type = 'attr_name' or 'attr_value;:
enum $context...see LDAP_SERVER_MASSAGE_* constants:
.e.g. ldap_server_massage_text($value, 'attr_value', LDAP_SERVER_MASSAGE_QUERY_LDAP) ldap_server_massage_text($value, 'attr_value', LDAP_SERVER_MASSAGE_QUERY_ARRAY)
5 calls to ldap_server_massage_text()
- LdapServer::deriveFromAttrGroupsResursive in ldap_servers/
LdapServer.class.php - not working yet will be ton of permission issues with service accounts need configurable obj type to avoid binding to a million user entries, printers, etc.
- LdapServer::deriveFromEntryGroups in ldap_servers/
LdapServer.class.php - return by reference groups/authorizations when groups are defined from entry
- LdapServer::groupsByEntryIsMember in ldap_servers/
LdapServer.class.php - looking at all members of a child group. only need to determine if member of one of the groups, doesn't matter which one.
- LdapServer::user_lookup in ldap_servers/
LdapServer.class.php - Queries LDAP server for the user.
- theme_ldap_query_results in ldap_query/
ldap_query.theme.inc
File
- ldap_servers/
ldap_servers.functions.inc, line 362 - collection of functions that don't belong in server object
Code
function ldap_server_massage_text($value, $value_type, $context) {
$scalar = is_scalar($value);
if ($value_type == 'attr_value') {
if ($context == LDAP_SERVER_MASSAGE_QUERY_LDAP) {
$value = ldap_pear_escape_filter_value($value);
}
elseif ($context == LDAP_SERVER_MASSAGE_STORE_LDAP) {
$value = ldap_pear_escape_dn_value($value);
}
switch ($context) {
case LDAP_SERVER_MASSAGE_DISPLAY:
case LDAP_SERVER_MASSAGE_TOKEN_REPLACE:
case LDAP_SERVER_MASSAGE_QUERY_LDAP:
case LDAP_SERVER_MASSAGE_QUERY_DB:
case LDAP_SERVER_MASSAGE_QUERY_ARRAY:
case LDAP_SERVER_MASSAGE_QUERY_PROPERTY:
case LDAP_SERVER_MASSAGE_STORE_LDAP:
case LDAP_SERVER_MASSAGE_STORE_DB:
case LDAP_SERVER_MASSAGE_STORE_ARRAY:
case LDAP_SERVER_MASSAGE_STORE_PROPERTY:
break;
}
}
elseif ($value_type == 'attr_name') {
// attr_name
switch ($context) {
case LDAP_SERVER_MASSAGE_DISPLAY:
break;
case LDAP_SERVER_MASSAGE_TOKEN_REPLACE:
case LDAP_SERVER_MASSAGE_QUERY_LDAP:
case LDAP_SERVER_MASSAGE_QUERY_DB:
case LDAP_SERVER_MASSAGE_QUERY_ARRAY:
case LDAP_SERVER_MASSAGE_QUERY_PROPERTY:
case LDAP_SERVER_MASSAGE_STORE_LDAP:
case LDAP_SERVER_MASSAGE_STORE_DB:
case LDAP_SERVER_MASSAGE_STORE_ARRAY:
case LDAP_SERVER_MASSAGE_STORE_PROPERTY:
if ($scalar) {
$value = drupal_strtolower($value);
}
else {
foreach ($value as $i => $val) {
$value[$i] = drupal_strtolower($val);
}
}
break;
}
}
return $value;
}