[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * phpGroupWare - preferences * |
---|
| 4 | * http://www.phpgroupware.org * |
---|
| 5 | * Written by Joseph Engo <jengo@phpgroupware.org> * |
---|
| 6 | * -------------------------------------------- * |
---|
| 7 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 8 | * under the terms of the GNU General Public License as published by the * |
---|
| 9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 10 | * option) any later version. * |
---|
| 11 | \**************************************************************************/ |
---|
| 12 | |
---|
[3296] | 13 | function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha) |
---|
| 14 | { |
---|
| 15 | require_once(PHPGW_SERVER_ROOT . '/security/classes/CertificadoB.php'); |
---|
[2] | 16 | |
---|
[3296] | 17 | if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && |
---|
| 18 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && |
---|
| 19 | (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) |
---|
[1681] | 20 | { |
---|
[3296] | 21 | $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 22 | $ldap_servidor = $GLOBALS['phpgw_info']['server']['ldap_master_host']; |
---|
| 23 | $ldap_dn = $GLOBALS['phpgw_info']['server']['ldap_master_root_dn']; |
---|
| 24 | $ldap_passwd = $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']; |
---|
[1681] | 25 | } |
---|
[3296] | 26 | else |
---|
| 27 | { |
---|
| 28 | $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 29 | $ldap_servidor = $GLOBALS['phpgw_info']['server']['ldap_host']; |
---|
| 30 | $ldap_dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
| 31 | $ldap_passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
| 32 | } |
---|
[1681] | 33 | |
---|
| 34 | $cc=ldap_connect($ldap_servidor); |
---|
[1042] | 35 | |
---|
[3279] | 36 | if($GLOBALS['phpgw_info']['server']['ldap_version3']) |
---|
[3296] | 37 | { |
---|
[3279] | 38 | ldap_set_option($cc, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[3296] | 39 | } |
---|
[3279] | 40 | |
---|
[1681] | 41 | $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); |
---|
[1042] | 42 | $filtro = 'uidNumber='.$aux_uid; |
---|
[1681] | 43 | $sr=ldap_search($cc, $ldap_context,$filtro); |
---|
[1042] | 44 | $info = ldap_get_entries($cc, $sr); |
---|
[1681] | 45 | |
---|
[1042] | 46 | if($info["count"]!=1) |
---|
[3296] | 47 | { |
---|
[1042] | 48 | ldap_close($cc); |
---|
| 49 | return false; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | if(!$info[0]["usercertificate"][0]) |
---|
| 53 | { |
---|
| 54 | ldap_close($cc); |
---|
| 55 | return false; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | $a = new certificadoB(); |
---|
| 59 | $R = $a->encriptar_senha($aux_senha,$info[0]["usercertificate"][0]); |
---|
[3296] | 60 | |
---|
[1681] | 61 | if(!$R) |
---|
[1042] | 62 | { |
---|
| 63 | return false; |
---|
| 64 | } |
---|
[3296] | 65 | |
---|
[1042] | 66 | $user_info = array(); |
---|
| 67 | $aux1 = $info[0]["dn"]; |
---|
| 68 | $user_info['cryptpassword'] = $R; |
---|
| 69 | ldap_modify($cc,$aux1,$user_info); |
---|
| 70 | |
---|
| 71 | ldap_close($cc); |
---|
| 72 | |
---|
| 73 | return true; |
---|
| 74 | } |
---|
[3296] | 75 | |
---|
| 76 | |
---|
| 77 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 78 | 'noheader' => True, |
---|
| 79 | 'nonavbar' => True, |
---|
| 80 | 'currentapp' => 'preferences' |
---|
| 81 | ); |
---|
| 82 | |
---|
| 83 | include('../header.inc.php'); |
---|
| 84 | |
---|
[32] | 85 | $a_passwd = $_POST['a_passwd']; |
---|
[2] | 86 | $n_passwd = $_POST['n_passwd']; |
---|
| 87 | $n_passwd_2 = $_POST['n_passwd_2']; |
---|
| 88 | |
---|
| 89 | if(!$GLOBALS['phpgw']->acl->check('changepassword', 1) || $_POST['cancel']) |
---|
| 90 | { |
---|
[72] | 91 | if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) |
---|
| 92 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); |
---|
[1681] | 93 | |
---|
[35] | 94 | if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) |
---|
| 95 | Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); |
---|
| 96 | else |
---|
| 97 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
[1681] | 98 | |
---|
[2] | 99 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | $GLOBALS['phpgw']->template->set_file(array( |
---|
| 103 | 'form' => 'changepassword.tpl' |
---|
| 104 | )); |
---|
[32] | 105 | $GLOBALS['phpgw']->template->set_var('lang_enter_actual_password',lang('Enter your actual password')); |
---|
[2] | 106 | $GLOBALS['phpgw']->template->set_var('lang_enter_password',lang('Enter your new password')); |
---|
| 107 | $GLOBALS['phpgw']->template->set_var('lang_reenter_password',lang('Re-enter your password')); |
---|
| 108 | $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); |
---|
| 109 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 110 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepassword.php')); |
---|
| 111 | |
---|
[72] | 112 | if ($_GET['cd'] == 1) |
---|
| 113 | { |
---|
| 114 | $lang1 = lang('Your password has expired'); |
---|
| 115 | $lang2 = lang('You must register a new password'); |
---|
| 116 | $GLOBALS['phpgw']->template->set_var('messages',"<font color=red><h1>$lang1.<br>$lang2.</h1></font>"); |
---|
| 117 | } |
---|
| 118 | |
---|
[2] | 119 | if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap') |
---|
| 120 | { |
---|
| 121 | $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature does *not* change your email password. This will ' |
---|
| 122 | . 'need to be done manually.')); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | if ($_POST['change']) |
---|
[1681] | 126 | { |
---|
| 127 | include(personalize_include_path('preferences','changepassword')); |
---|
| 128 | } |
---|
[2] | 129 | else |
---|
| 130 | { |
---|
| 131 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your password'); |
---|
| 132 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 133 | echo parse_navbar(); |
---|
| 134 | |
---|
| 135 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 136 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 137 | } |
---|
| 138 | ?> |
---|