t('LDAP Help'), 'description' => t('Debugging and Configuration Help with LDAP'), 'page callback' => 'ldaphelp_main', 'access arguments' => array('administer ldap modules'), ); $items['admin/settings/ldap/help/resources'] = array( 'title' => t('Resources'), 'description' => t('Some help resources for LDAP modules'), 'page callback' => 'ldaphelp_main', 'access arguments' => array('administer ldap modules'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 2, ); $items['admin/settings/ldap/help/status'] = array( 'title' => t('Status'), 'description' => t('LDAP status page'), 'page callback' => 'ldaphelp_status', 'access arguments' => array('administer ldap modules'), 'file' => 'ldaphelp_status.inc', 'type' => MENU_LOCAL_TASK, 'weight' => 4, ); $items['admin/settings/ldap/help/watchdog'] = array( 'title' => t('Watchdog'), 'description' => t('LDAP watchdog logs'), 'page callback' => 'ldaphelp_watchdog', 'access arguments' => array('administer ldap modules'), 'type' => MENU_LOCAL_TASK, 'weight' => 5, ); $items['admin/settings/ldap/help/addcommon'] = array( 'title' => t('Common LDAPs'), 'description' => 'Add a new LDAP starting with common defaults such as Active Directory defaults.', 'page callback' => 'ldaphelp_addcommon', 'access arguments' => array('administer ldap modules'), 'type' => MENU_LOCAL_TASK, 'weight' => 7, ); $items['admin/settings/ldap/help/wizard'] = array( 'title' => t('Wizard'), 'description' => t('A multi step form to help figure out LDAP server configuration.'), 'access arguments' => array('administer ldap modules'), 'file' => 'ldaphelp_wizard.inc', 'type' => MENU_LOCAL_TASK, 'weight' => 13, 'page callback' => 'drupal_get_form', 'page arguments' => array('ldaphelp_wizard_form'), ); return $items; } function _ldaphelp_bind_test($ldapserver) { global $_ldapauth_ldap; $test = array(); $_ldapauth_ldap = new LDAPInterface(); foreach ($ldapserver as $key => $value) { $_ldapauth_ldap->setOption($key, $value); } if ($_ldapauth_ldap->getOption('binddn') && $_ldapauth_ldap->getOption('bindpw')) { $test['bind_result'] = $_ldapauth_ldap->connectAndBind($_ldapauth_ldap->getOption('binddn'), $_ldapauth_ldap->getOption('bindpw')); $test['bind_type'] = "non-anon"; } else { $test['bind_result'] = $_ldapauth_ldap->connectAndBind(); $test['bind_type'] = "anon"; } if ($test['bind_result']) { $test['bind_result_text'] = "Success"; $test['bind_success'] = TRUE; } else { $test['bind_result_error'] = ldap_error($_ldapauth_ldap->connection); $test['bind_result_errno'] = ldap_errno($_ldapauth_ldap->connection); $test['bind_result_text'] = "Fail"; $test['bind_success'] = FALSE; } return $test; } function ldaphelp_bind_trial_message($trial) { $tls = ($trial['tls']) ? "1" : "0"; $text = "Failed to bind to server: ". $trial['server'] .", port=". $trial['port'] .", tls=$tls
"; $text .= "error: ". $trial['results']['bind_result_error']; return $text; } function ldaphelp_addcommon() { if (!module_exists('ldapauth')) { drupal_set_message('Links below will not work until ldapauth module is not enabled.', 'warning'); } global $_ldaphelp_ldaps; $content = '

'. t('LDAP Integration Default LDAPs') .'

'; $content .= '

'. t('These links simply start an Add LDAP Server form with some common defaults.') .'

'; $content .= '"; return $content; } function ldaphelp_form_ldapauth_admin_form_alter(&$form, $form_state) { global $_ldaphelp_ldaps; if (in_array(arg(4), array_keys($_ldaphelp_ldaps))) { $ldap_type = arg(4); foreach ($_ldaphelp_ldaps[$ldap_type]['fields'] as $fieldset => $pairs) { foreach ($pairs as $fieldname => $value ) { $form[$fieldset][$fieldname]['#default_value'] = $value; } } } // don't hide/collapse login fieldset if data in it. if ($form['login-procedure']['basedn']['#default_value'] || $form['login-procedure']['user_attr']['#default_value'] || $form['login-procedure']['mail_attr']['#default_value'] ) { $form['login-procedure']['#collapsed'] = FALSE; } } function _ldaphelp_get_configuration($admin_settings = TRUE, $sids = NULL) { if ($admin_settings) { $form = ldapauth_admin_settings(); $data['admin_settings'] = _ldaphelp_get_form_values($form); } $data['ldaps'] = array(); if ( ! (is_array($sids) && count($sids) == 0)) { if ($sids == NULL) { $result = db_query("SELECT sid FROM {ldapauth} ORDER BY name"); while ($row = db_fetch_object($result)) { $sids[] = $row->sid; } } if (count($sids) > 0) { foreach ($sids as $sid) { $form = ldapauth_admin_form($form_state, 'edit', $sid); $data['ldaps'][$sid] = _ldaphelp_get_form_values($form); unset($data['ldaps'][$sid]['bindpw_clear']); } } } return $data; } function _ldaphelp_get_form_values(&$form) { $values = array(); foreach ($form as $key => $item) { if ($form[$key]['#type'] == 'fieldset') { foreach ($form[$key] as $subskey => $subitem) { if ( drupal_substr($subskey, 0, 1) != '#') { $values[$subskey] = ($subitem['#value']) ? $subitem['#value'] : $subitem['#default_value']; } } } elseif (drupal_substr($key, 0, 1) != '#' && $key != 'submit' && $key != 'reset') { $values[$key] = ($item['#value']) ? $item['#value'] : $item['#default_value']; } } return $values; } function ldaphelp_display_settings_short($ldap) { foreach ( $ldap as $fieldset => $pairs) { foreach ($ldap[$fieldset] as $fieldname => $value ) { $ret .= "$fieldname = $value; "; } } return $ret; } function ldaphelp_arraytohtmllist($array) { foreach ($array as $key => $value) { $text .= "
  • $key: $value
  • \r\n"; } return ""; } function ldaphelp_arraytohtml($array) { foreach ($array as $key => $value) { $text .= "
    $key: $value"; } return $text; } function ldaphelp_arraytotxt($array) { foreach ($array as $key => $value) { $text .= "$key: $value\r\n"; } return $text; } function ldaphelp_get_export_comments($export_conf_data) { if ($export_conf_data['admin_settings']) { $text = "\r\nAdmin Settings: \r\n". ldaphelp_arraytotxt($export_conf_data['admin_settings']); } foreach ($export_conf_data['ldaps'] as $sid => $ldap) { $text .= "\r\n" . ldaphelp_arraytotxt($ldap); } return $text; } function ldaphelp_main() { $text = '

    '. t('LDAP Help Module') .'

    '. t('This module is meant to assist Drupal admins in configuring, debugging, sharing, and submitting support and bug request related to LDAP integration modules.') .''. t(' LDAP Help Module should be disabled unless you are debugging or configuring ldap problems.') .''. t(' It adds no functionality to the LDAP modules.') .'

    '; $path = drupal_get_path("module", "ldapauth"); $text .= <<LDAP Integration Module Resources

    General Drupal Support Help

    General LDAP Resources

    EOT; return $text; } function ldaphelp_watchdog() { /* watchdog table */ drupal_add_css(drupal_get_path('module', 'ldaphelp') .'/ldaphelp.css', 'module', 'all', FALSE); $path = drupal_get_path("module", "ldapauth"); $_content = ""; if (module_exists('dblog')) { include_once(drupal_get_path('module', 'dblog') .'/dblog.admin.inc'); $_SESSION['dblog_overview_filter']['type'] = Array('ldapauth' => 'ldapauth'); if (! ($_SESSION['dblog_overview_filter'] || $_SESSION['dblog_overview_filter']['severity'])) { $_SESSION['dblog_overview_filter']['severity'] = array(); } $_content .= "

    ". t('LDAP Watchdog Errors and Notifications') ."

    "; $_content .= dblog_overview(); $_content .= l('...more watchdog', 'admin/reports/dblog'); } else { $_content .= "

    ". t('LDAP Help Watchdog Errors and Notifications') ."

    "; $_content .= 'This feature requires Database logging module to be turned on. '; $_content .= l('Module enable page', 'admin/build/modules'); } return $_content; }