Skip to content
Snippets Groups Projects
Commit eec6fbbe authored by John Barclay's avatar John Barclay
Browse files

Issue #1477540. Added more debug code to ldap authorization og and addl error checking.

parent aa082961
No related branches found
No related tags found
No related merge requests found
*.patch
*.komodoproject
Issue #1477540. Added more debug code to ldap authorization og and addl error checking.
Issue #1535538 by snickl. fix testing username property
Issue #1532084 by lucuhb. Remove ldap_profile's dependeny on ldap_authentication
Issue #1468990 by superhenne. Duplicate entry in db after updating configuration
......
......@@ -63,8 +63,22 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
$rid = NULL;
$targets = explode(',', $mapping[1]);
list($group_target, $group_target_value) = explode('=', $targets[0]);
list($role_target, $role_target_value) = explode('=', $targets[1]);
if (count($targets) != 2) {
return FALSE;
}
$group_target_and_value = explode('=', $targets[0]);
if (count($group_target_and_value) != 2) {
return FALSE;
}
list($group_target, $group_target_value) = $group_target_and_value;
$role_target_and_value = explode('=', $targets[1]);
if (count($role_target_and_value) != 2) {
return FALSE;
}
list($role_target, $role_target_value) = $role_target_and_value;
if ($group_target == 'gid') {
$gid = $group_target_value;
}
......@@ -75,7 +89,11 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
}
}
else {
list($entity_type, $field) = explode('.', $group_target);
$entity_type_and_field = explode('.', $group_target);
if (count($entity_type_and_field) != 2) {
return FALSE;
}
list($entity_type, $field) = $entity_type_and_field;
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', $entity_type)
......@@ -232,6 +250,7 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
list($gid, $rid) = @explode('-', $authorization_id);
$watchdog_tokens['%gid'] = $gid;
$watchdog_tokens['%rid'] = $rid;
$watchdog_tokens['%uid'] = $user->uid;
$available_consumer_ids = $this->availableConsumerIDs(TRUE);
// CASE 1: Bad Parameters
......@@ -275,7 +294,13 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
}
// CASE 5: grant role
if ($this->detailedWatchdogLog) {
watchdog('ldap_authorization_og',
'LdapAuthorizationConsumerOG.grantSingleAuthorization()
calling og_role_grant(%gid, $uid, %rid)',
$watchdog_tokens,
WATCHDOG_DEBUG);
}
og_role_grant($gid, $user->uid, $rid);
// modify group_audience field for user
......@@ -360,13 +385,18 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
if (!$pass) {
$message_text = '<code>"' . t('!map_to', $tokens) . '"</code> ' . t('does not map to any existing organic groups and roles. ');
if ($has_form_values) {
$create_consumers = (isset($form_values['synchronization_actions']['create_consumers']) && $form_values['synchronization_actions']['create_consumers']);
}
else {
$create_consumers = $this->consumerConf->create_consumers;
}
if ($create_consumers && $this->allowConsumerObjectCreation) {
if ($normalized === FALSE) {
$message_type = 'error';
$message_text .= t('Can not normalize mappings. Please check the syntax in Mapping of LDAP to OG Group', $tokens);
}
elseif ($create_consumers && $this->allowConsumerObjectCreation) {
$message_type = 'warning';
$message_text .= t('It will be created when needed. If "!map_to" is not intentional, please fix it', $tokens);
}
......
......@@ -28,9 +28,9 @@ function ldap_authorization_og_ldap_authorization_consumer() {
<code>[raw authorization id]|[og group match field]=[og group match id],[og role match field]=[og role match id]</code>
<br/>such as:<br/>
<code>
Campus Accounts|group-name=knitters,role-name=administrator member
ou=Underlings,dc=myorg,dc=mytld,dc=edu|gid=7,rid=28
ou=IT,dc=myorg,dc=mytld,dc=edu|node.field_state_id=IL,role-name=administrator member
Campus Accounts|group-name=knitters,role-name=administrator member<br/>
ou=Underlings,dc=myorg,dc=mytld,dc=edu|gid=7,rid=28<br/>
ou=IT,dc=myorg,dc=mytld,dc=edu|node.field_state_id=IL,role-name=administrator member<br/>
</code>',
);
......@@ -148,6 +148,3 @@ function ldap_authorization_og_form_ldap_authorization_admin_form_alter(&$form,
$form['filter_and_mappings']['use_filter']['#type'] = 'hidden';
}
}
......@@ -20,6 +20,9 @@ function ldap_create_drupal_account($name, $mail, $dn, $sid, $edit = array()) {
$edit['mail'] = $mail;
$edit['init'] = $mail;
$edit['status'] = 1;
if (!isset($edit['signature'])) {
$edit['signature'] = '';
}
// save 'init' data to know the origin of the ldap authentication provisioned account
$edit['data']['ldap_authentication']['init'] = array(
......
......@@ -250,28 +250,30 @@ class ldap_views_plugin_query_ldap extends views_plugin_query {
$sort_fields[drupal_strtolower($orderby['field'])]['direction'] = $orderby['direction'];
$sort_fields[drupal_strtolower($orderby['field'])]['data'] = array();
}
}
foreach ($entries as $key => &$entry) {
foreach ($view->field as $field) {
$alias = $field_alias[$field->field_alias];
if (is_array($entry) && array_key_exists($alias, $entry)) {
if (is_array($entry[$alias])) {
switch ($field->options['multivalue']) {
case 'v-all':
// remove 'count' index
array_shift($entry[$alias]);
$entry[$alias] = implode($field->options['value_separator'], $entry[$alias]);
break;
case 'v-count':
$entry[$alias] = $entry[$alias]['count'];
break;
case 'v-index':
$index = $field->options['index_value'] >= 0 ? intval($field->options['index_value']) : $entry[$alias]['count'] + $field->options['index_value'];
$entry[$alias] = array_key_exists($index, $entry[$alias]) ? $entry[$alias][$index] :
$entry[$alias][0];
break;
if (isset($entry['jpegphoto'])) {
$entry['jpegphoto'][0] = "<img src='data:image/jpeg;base64,".base64_encode($entry['jpegphoto'][0])."' alt='photo' />";
}
foreach ($view->field as $field) {
$alias = $field_alias[$field->field_alias];
if (is_array($entry) && array_key_exists($alias, $entry)) {
if (is_array($entry[$alias])) {
switch ($field->options['multivalue']) {
case 'v-all':
// remove 'count' index
array_shift($entry[$alias]);
$entry[$alias] = implode($field->options['value_separator'], $entry[$alias]);
break;
case 'v-count':
$entry[$alias] = $entry[$alias]['count'];
break;
case 'v-index':
$index = $field->options['index_value'] >= 0 ? intval($field->options['index_value']) : $entry[$alias]['count'] + $field->options['index_value'];
$entry[$alias] = array_key_exists($index, $entry[$alias]) ? $entry[$alias][$index] :
$entry[$alias][0];
break;
}
}
// order criteria
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment