/[drupal]/contributions/modules/ldap_integration/ldapdata.admin.inc
ViewVC logotype

Diff of /contributions/modules/ldap_integration/ldapdata.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8, Mon Mar 30 08:33:26 2009 UTC revision 1.9, Tue Jul 28 14:03:05 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: ldapdata.admin.inc,v 1.6 2009/03/24 10:07:26 miglius Exp $  // $Id: ldapdata.admin.inc,v 1.8 2009/03/30 08:33:26 miglius Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 106  function ldapdata_admin_list() { Line 106  function ldapdata_admin_list() {
106   *   The form structure.   *   The form structure.
107   */   */
108  function ldapdata_admin_edit(&$form_state, $op, $sid) {  function ldapdata_admin_edit(&$form_state, $op, $sid) {
109      drupal_add_js(drupal_get_path('module', 'ldapdata') .'/ldapdata.admin.js');
110    
111    if ($op == "reset" && $sid) {    if ($op == "reset" && $sid) {
112      $form['sid'] = array(      $form['sid'] = array(
113        '#type' => 'value',        '#type' => 'value',
# Line 239  function ldapdata_admin_edit(&$form_stat Line 241  function ldapdata_admin_edit(&$form_stat
241      $form['advanced'] = array(      $form['advanced'] = array(
242        '#type' => 'fieldset',        '#type' => 'fieldset',
243        '#title' => t('Advanced configuration'),        '#title' => t('Advanced configuration'),
244        '#description' => t('<p>When reading/editing attributes, this module logs on to the LDAP directory using the user\'s DN/pass pair. However, many LDAP setups do not allow their users to edit attributes.</p><p>If this is your case, but still you want users to edit their LDAP attributes via Drupal, you should set up an special user on your directory, with special access to edit your users\' attributes. Then this module will use it to log on and edit data.</p><p>"Test" tries authentication with the saved DN and password and prints the result.</p>'),        '#description' => t('<p>When reading/editing attributes, this module logs on to the LDAP directory using the user\'s DN/pass pair. However, many LDAP setups do not allow their users to edit attributes.</p><p>If this is your case, but still you want users to edit their LDAP attributes via Drupal, you should set up an special user on your directory, with special access to edit your users\' attributes. Then this module will use it to log on and edit data.</p>'),
245        '#collapsible' => TRUE,        '#collapsible' => TRUE,
246        '#collapsed' => TRUE        '#collapsed' => FALSE,
     );  
     $form['advanced']['ldapdata_binddn'] = array(  
       '#type' => 'textfield',  
       '#title' => t('DN for reading/editing attributes'),  
       '#default_value' => $edit['ldapdata_binddn'],  
       '#size' => 50,  
       '#maxlength' => 255,  
247      );      );
248      if (!$edit['ldapdata_bindpw']) {      if (!$edit['ldapdata_bindpw']) {
249          $form['advanced']['ldapdata_binddn'] = array(
250            '#type' => 'textfield',
251            '#title' => t('DN for reading/editing attributes'),
252            '#default_value' => $edit['ldapdata_binddn'],
253            '#size' => 50,
254            '#maxlength' => 255,
255          );
256        $form['advanced']['ldapdata_bindpw'] = array(        $form['advanced']['ldapdata_bindpw'] = array(
257          '#type' => 'password',          '#type' => 'password',
258          '#title' => t('Password for reading/editing attributes'),          '#title' => t('Password for reading/editing attributes'),
# Line 259  function ldapdata_admin_edit(&$form_stat Line 261  function ldapdata_admin_edit(&$form_stat
261        );        );
262      }      }
263      else {      else {
264          $form['advanced']['ldapdata_binddn'] =  array(
265            '#type' => 'item',
266            '#title' => t('DN for non-anonymous search'),
267            '#value' => $edit['ldapdata_binddn'],
268          );
269        // Given an option to clear the password.        // Given an option to clear the password.
270        $form['advanced']['ldapdata_bindpw_clear'] = array(        $form['advanced']['ldapdata_bindpw_clear'] = array(
271          '#type' => 'checkbox',          '#type' => 'checkbox',
272          '#default_value' => FALSE,          '#default_value' => FALSE,
273          '#title' => t('Clear current password'),          '#title' => t('Clear current password and change DN'),
274        );        );
275      }      }
276      $form['advanced']['test'] = array(      $form['advanced']['test'] = array(
277        '#type'  => 'submit',        '#type'  => 'submit',
278        '#value' => t('Test'),        '#value' => t('Test'),
279          '#suffix' => '<div id="test-spinner" style="display: none;">'. theme_image(drupal_get_path('module', 'ldapdata') .'/images/spinner.gif') .'</div><div id="test-message" class="messages" style="display: none;"></div>',
280      );      );
281    
282      $form['sid'] = array(      $form['sid'] = array(
# Line 341  function ldapdata_admin_edit_submit($for Line 349  function ldapdata_admin_edit_submit($for
349    switch ($op) {    switch ($op) {
350      case t('Update'):      case t('Update'):
351        if (isset($values['ldapdata_bindpw_clear'])) {        if (isset($values['ldapdata_bindpw_clear'])) {
352          db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_binddn = '%s', ldapdata_attrs = '%s', ldapdata_filter_php = '%s' WHERE sid = %d", $form_state['ldapdata_mappings'], $form_state['ldapdata_roattrs'], $form_state['ldapdata_rwattrs'], $values['ldapdata_binddn'], $form_state['ldapdata_attrs'], $form_state['ldapdata_filter_php'], $values['sid']);          db_query("UPDATE {ldapauth} SET ldapdata_mappings = '%s', ldapdata_roattrs = '%s', ldapdata_rwattrs = '%s', ldapdata_attrs = '%s', ldapdata_filter_php = '%s' WHERE sid = %d", $form_state['ldapdata_mappings'], $form_state['ldapdata_roattrs'], $form_state['ldapdata_rwattrs'], $form_state['ldapdata_attrs'], $form_state['ldapdata_filter_php'], $values['sid']);
353          if ($values['ldapdata_bindpw_clear']) {          if ($values['ldapdata_bindpw_clear']) {
354            db_query("UPDATE {ldapauth} SET ldapdata_bindpw = '' WHERE sid = %d", $values['sid']);            db_query("UPDATE {ldapauth} SET ldapdata_bindpw = '' WHERE sid = %d", $values['sid']);
355          }          }
# Line 380  function ldapdata_admin_edit_submit($for Line 388  function ldapdata_admin_edit_submit($for
388    }    }
389  }  }
390    
391    /**
392     * Implements the AJAX server test.
393     *
394     * @param $sid
395     *   LDAP server ID.
396     *
397     * @return
398     *   The JSON data.
399     */
400    function _ldapdata_ajax_test($sid) {
401      global $_ldapdata_ldap;
402    
403      if (!is_numeric($sid)) {
404        return;
405      }
406    
407      _ldapdata_init($sid);
408    
409      if ($_POST['bindpw_clear'] == 'undefined') {
410        $binddn = $_POST['binddn'];
411        $bindpw = $_POST['bindpw'];
412      }
413      else {
414        $binddn = $_ldapdata_ldap->getOption('binddn');
415        $bindpw = $_ldapdata_ldap->getOption('bindpw');
416      }
417    
418      drupal_json($_ldapdata_ldap->connect($binddn, $bindpw) ? array('status' => 1, 'message' => t('Authentication with the LDAP server succeeded.')) : array('status' => 0, 'message' => t('Authentication with the LDAP server failed.')));
419      exit;
420    }
421    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.2