summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2012-08-27 12:47:35 (GMT)
committerTorsten Grote <grote@kolabsys.com>2012-08-27 12:47:35 (GMT)
commit7b5e4a2b04e4fb38485bc12965e07794388d0224 (patch)
tree42031777dcb7476a63e9d6080ab9b8eef8ebb6f0 /kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers
parentee39408867ae52c2321036a67c472e684c1e1108 (diff)
downloadkolab.org-www-7b5e4a2b04e4fb38485bc12965e07794388d0224.tar.gz
updated ctools, ldap and views modules
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/LdapServer.class.php1
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php16
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc61
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.info6
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc15
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/tests/LdapServerTest.class.php14
6 files changed, 82 insertions, 31 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/LdapServer.class.php b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
index c4ecd10..f3ef1ff 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
@@ -367,6 +367,7 @@ class LdapServer {
$result = $this->ldapQuery($scope, $ldap_query_params);
if ($result && (ldap_count_entries($this->connection, $result) !== FALSE) ) {
$entries = ldap_get_entries($this->connection, $result);
+ drupal_alter('ldap_server_search_results', $entries, $ldap_query_params);
return (is_array($entries)) ? $entries : FALSE;
}
elseif ($this->ldapErrorNumber()) {
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
new file mode 100644
index 0000000..0da6cd4
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Documentations of the module hooks
+ */
+
+
+/**
+ * Allow the results from the ldap search answer to be modified
+ * The query parameters are provided as context infomation
+ * (readonly)
+ *
+ */
+function hook_ldap_server_search_results_alter(&$entries, $ldap_query_params) {
+ // look for a specific part of the $results array
+ // and maybe change it
+}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
index 7fc57c9..8066847 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
@@ -20,13 +20,15 @@ function ldap_server_module_load_include($type, $module, $name = NULL) {
* as LDAP_CREATE_ACCOUNT_ALREADY_EXISTS, LDAP_CREATE_ERROR
*
*/
-function ldap_create_drupal_account($authname, $accountname, $mail, $dn, $sid, $edit = array()) {
+// $account = ldap_create_drupal_account($authname, $accountname, $ldap_user['mail'], $ldap_user['dn'], $sid, array(), $status);
+
+function ldap_create_drupal_account($authname, $accountname, $mail, $dn, $sid, $status, $edit) {
$edit['name'] = $accountname;
$edit['pass'] = user_password(20);
$edit['mail'] = $mail;
$edit['init'] = $mail;
- $edit['status'] = 1;
+ $edit['status'] = $status;
if (!isset($edit['signature'])) {
$edit['signature'] = '';
}
@@ -207,16 +209,10 @@ function ldap_server_tokenize_entry($ldap_entry, $token_keys = 'all', $pre = LDA
foreach ($dn_parts as $pair) {
list($attr_name, $attr_value) = explode('=', $pair);
$attr_value = ldap_pear_unescape_dn_value($attr_value);
- try {
- $attr_value = check_plain($attr_value);
- }
- catch (Exception $e) {
- if ($detailed_watchdog_log) {
- $watchdog_tokens = array('%attr_name' => $attr_name);
- watchdog('ldap_servers', 'skipped tokenization of attribute %attr_name because the value would not pass check_plain function.', $watchdog_tokens, WATCHDOG_DEBUG);
- }
- continue; // don't tokenize data that can't pass check_plain
+ if (!($attr_value = ldap_server_check_plain($attr_value, $attr_name))) {
+ continue;
}
+
if (!isset($parts_count[$attr_name])) {
$tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = $attr_value;
$parts_count[$attr_name] = 0;
@@ -237,18 +233,26 @@ function ldap_server_tokenize_entry($ldap_entry, $token_keys = 'all', $pre = LDA
foreach ($token_keys as $attr_name) {
$attr_value = $ldap_entry[$attr_name];
if (is_array($attr_value) && is_scalar($attr_value[0]) && $attr_value['count'] == 1) {
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = check_plain($attr_value[0]);
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . '0' . $post] = check_plain($attr_value[0]);
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = check_plain($attr_value[0]);
+ if ($value = ldap_server_check_plain($attr_value[0], $attr_name)) {
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = $value;
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . '0' . $post] = $value;
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = $value;
+ }
}
elseif (is_array($attr_value) && $attr_value['count'] > 1) {
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = check_plain($attr_value[$attr_value['count']-1]);
+ if ($value = ldap_server_check_plain($attr_value[$attr_value['count']-1], $attr_name)) {
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = $value;
+ }
for ($i=0; $i<$attr_value['count']; $i++) {
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . $i . $post] = check_plain($attr_value[$i]);
+ if ($value = ldap_server_check_plain($attr_value[$i], $attr_name)) {
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . $i . $post] = $value;
+ }
}
}
elseif (is_scalar($attr_value)) {
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = check_plain($attr_value);
+ if ($value = ldap_server_check_plain($attr_value, $attr_name)) {
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = $value;
+ }
}
}
}
@@ -272,16 +276,35 @@ function ldap_server_tokenize_entry($ldap_entry, $token_keys = 'all', $pre = LDA
else {
$value = $ldap_entry[$token_key][0];
}
- $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = check_plain($value);
+ $value = ldap_server_check_plain($value, $token_key);
+ if ($value === FALSE) {
+ continue; // don't tokenize data that can't pass check_plain
+ }
+ $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . $post] = $value;
}
}
// include the dn. it will not be handled correctly by previous loops
- $tokens[$pre . 'dn' . $post] = check_plain($ldap_entry['dn']);
+ $tokens[$pre . 'dn' . $post] = ldap_server_check_plain($ldap_entry['dn']);
return $tokens;
}
+
+function ldap_server_check_plain($text, $attr_name = 'attribute', $detailed_watchdog_log = FALSE) {
+
+ try {
+ $text = @check_plain($text);
+ }
+ catch (Exception $e) {
+ if ($detailed_watchdog_log) {
+ $watchdog_tokens = array('%attr_name' => $attr_name);
+ watchdog('ldap_servers', 'skipped tokenization of attribute %attr_name because the value would not pass check_plain function.', $watchdog_tokens, WATCHDOG_DEBUG);
+ }
+ $text = FALSE;
+ }
+ return $text;
+}
/**
* @param string $template in form [cn]@myuniversity.edu
* @return array of all tokens in the template such as array('cn')
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.info b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.info
index 1746a05..56818f5 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.info
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.info
@@ -23,9 +23,9 @@ files[] = tests/ldap_servers.test
configure = admin/config/people/ldap/servers
-; Information added by drupal.org packaging script on 2012-06-14
-version = "7.x-1.0-beta11"
+; Information added by drupal.org packaging script on 2012-08-20
+version = "7.x-1.0-beta12"
core = "7.x"
project = "ldap"
-datestamp = "1339643179"
+datestamp = "1345503423"
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
index f731349..439601a 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
@@ -78,12 +78,14 @@ function ldap_servers_test_form($form, &$form_state, $op = NULL, $sid = NULL) {
'#weight' => 100,
);
+
if (isset($_SESSION['ldap_server_test_data']) && count($_SESSION['ldap_server_test_data']) > 0) {
$form['#suffix'] = theme('ldap_server_ldap_entry_table',
array(
'entry' => $_SESSION['ldap_server_test_data']['LDAP Entry']['attr'],
'username' => $_SESSION['ldap_server_test_data']['username'],
));
+
if (function_exists('dpm')) {
$user_name = $_SESSION['ldap_server_test_data']['username'];
dpm("ldap full result array for: " . $user_name);
@@ -92,14 +94,17 @@ function ldap_servers_test_form($form, &$form_state, $op = NULL, $sid = NULL) {
$user = user_load_by_name($user_name);
dpm("drupal user object for: $user_name");
dpm($user);
- $user_entity = entity_load_single('user', $user->uid);
- dpm("drupal user entity for: $user_name");
- dpm($user_entity);
+ $user_entity = entity_load('user', array($user->uid));
+ if (count($user_entity) > 0) {
+ dpm("drupal user entity for: $user_name");
+ dpm($user_entity);
+ }
}
unset($_SESSION['ldap_server_test_data']);
}
+
return $form;
}
@@ -120,6 +125,7 @@ function ldap_servers_test_form_validate($form, &$form_state) {
* Submit hook for the LDAP server form.
*/
function ldap_servers_test_form_submit($form, &$form_state) {
+
$errors = FALSE;
$values = $form_state['values'];
$sid = $values['sid'];
@@ -186,9 +192,10 @@ function ldap_servers_test_form_submit($form, &$form_state) {
'LDAP Entry' => $ldap_user,
);
}
- $message = theme_item_list(array('items' => $results, 'title' => t('Result Messages'), 'type' => 'ul', 'attributes' => array()));
+ $message = ''; // theme_item_list(array('items' => $results, 'title' => t('Result Messages'), 'type' => 'ul', 'attributes' => array()));
drupal_set_message(t($message), ($has_errors) ? 'error' : 'status');
+
$form_state['redirect'] = LDAP_SERVERS_MENU_BASE_PATH . "/servers/test/$sid";
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/tests/LdapServerTest.class.php b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/tests/LdapServerTest.class.php
index b7cb8b9..d3943df 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/tests/LdapServerTest.class.php
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_servers/tests/LdapServerTest.class.php
@@ -134,7 +134,7 @@ class LdapServerTest extends LdapServer {
* An array of matching entries->attributes, or FALSE if the search is empty.
*/
function search($base_dn = NULL, $filter, $attributes = array(), $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = LDAP_DEREF_NEVER, $scope = LDAP_SCOPE_SUBTREE) {
-
+ //debug("feaux_server_filter=$filter");
$filter = trim(str_replace(array("\n", " "),array('',''), $filter)); // for test matching simplicity remove line breaks and tab spacing
// debug("filter=$filter");
// debug('search'); debug("base_dn: $base_dn"); debug("filter:<pre>$filter</pre>");
@@ -159,6 +159,9 @@ class LdapServerTest extends LdapServer {
$filter = strtolower(trim($filter,"()"));
list($filter_attribute, $filter_value) = explode('=', $filter);
+ if (strtolower($filter_attribute) == 'dn') { // don't allow filtering on dn. filters should use distinguishedName
+ continue;
+ }
// $filter_value = ldap_pear_unescape_filter_value($filter_value);
// need to perform feaux ldap search here with data in
$results = array();
@@ -171,11 +174,12 @@ class LdapServerTest extends LdapServer {
$user_data_lcase['attr'][drupal_strtolower($attr)] = $values;
}
- $dn = strtolower($dn);
+
// if not in basedn, skip
// eg. basedn ou=campus accounts,dc=ad,dc=myuniversity,dc=edu
// should be leftmost string in:
// cn=jdoe,ou=campus accounts,dc=ad,dc=myuniversity,dc=edu
+ $dn = strtolower($dn);
$pos = stripos($dn, $base_dn);
if ($pos === FALSE || strcasecmp($base_dn, substr($dn, 0, $pos + 1)) == FALSE) {
if ($my_debug2) {debug("dn=$dn not in base_dn=$base_dn");}
@@ -206,7 +210,7 @@ class LdapServerTest extends LdapServer {
// loop through all attributes, if any don't match continue
- $user_data_lcase['attr']['dn'] = $dn;
+ $user_data_lcase['attr']['distinguishedname'] = $dn;
if ($attributes) {
$selected_user_data = array();
foreach ($attributes as $i => $attr_name) {
@@ -246,8 +250,8 @@ class LdapServerTest extends LdapServer {
}
// loop through all attributes, if any don't match continue
- $group_data['attr']['dn'] = $dn;
- $group_data['distinguishedname'] = $dn;
+ // $group_data['attr']['distinguishedname'] = $dn;
+ // $group_data['distinguishedname'] = $dn;
if ($attributes) {
$selected_group_data = array();