[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 | |
---|
| 13 | |
---|
| 14 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 15 | 'noheader' => True, |
---|
| 16 | 'nonavbar' => True, |
---|
| 17 | 'currentapp' => 'preferences' |
---|
| 18 | ); |
---|
| 19 | |
---|
| 20 | include('../header.inc.php'); |
---|
| 21 | |
---|
[1681] | 22 | /* |
---|
| 23 | function path_template_include($app,$prefix) |
---|
| 24 | { |
---|
| 25 | $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/' . $GLOBALS['phpgw_info']['login_template_set'] . '/' . $prefix . '_' . $GLOBALS['phpgw_info']['login_template_set'] . '.php'; |
---|
| 26 | |
---|
| 27 | if(!$file_include || !file_exists($file_include)) |
---|
| 28 | { |
---|
| 29 | $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/default/' . $prefix .'_default.php'; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | return $file_include; |
---|
| 33 | } |
---|
| 34 | */ |
---|
| 35 | |
---|
[1042] | 36 | function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha) |
---|
[1681] | 37 | { |
---|
[1174] | 38 | require_once('/var/www/expresso/security/classes/CertificadoB.php'); |
---|
[1042] | 39 | $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context']; |
---|
| 40 | $ldap_servidor = $GLOBALS['phpgw_info']['server']['ldap_host']; |
---|
| 41 | $ldap_dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; |
---|
| 42 | $ldap_passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; |
---|
| 43 | |
---|
[1681] | 44 | $cc=ldap_connect($ldap_servidor); |
---|
[1042] | 45 | |
---|
| 46 | // bind .. |
---|
[1681] | 47 | $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); |
---|
[1042] | 48 | |
---|
| 49 | $filtro = 'uidNumber='.$aux_uid; |
---|
| 50 | |
---|
| 51 | // Pesquisa uidNumber no LDAP |
---|
[1681] | 52 | $sr=ldap_search($cc, $ldap_context,$filtro); |
---|
[1042] | 53 | |
---|
| 54 | // Pega resultado .... |
---|
| 55 | $info = ldap_get_entries($cc, $sr); |
---|
[1681] | 56 | |
---|
[1042] | 57 | // Tem de achar só uma entrada.....ao menos uma.... |
---|
| 58 | if($info["count"]!=1) |
---|
| 59 | { |
---|
| 60 | ldap_close($cc); |
---|
| 61 | return false; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | if(!$info[0]["usercertificate"][0]) |
---|
| 65 | { |
---|
| 66 | //Usuario sem certificado cadastrado |
---|
| 67 | ldap_close($cc); |
---|
| 68 | return false; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | $a = new certificadoB(); |
---|
| 72 | $R = $a->encriptar_senha($aux_senha,$info[0]["usercertificate"][0]); |
---|
[1681] | 73 | if(!$R) |
---|
[1042] | 74 | { |
---|
| 75 | return false; |
---|
| 76 | } |
---|
| 77 | $user_info = array(); |
---|
| 78 | $aux1 = $info[0]["dn"]; |
---|
| 79 | $user_info['cryptpassword'] = $R; |
---|
| 80 | ldap_modify($cc,$aux1,$user_info); |
---|
| 81 | |
---|
| 82 | ldap_close($cc); |
---|
| 83 | |
---|
| 84 | return true; |
---|
| 85 | } |
---|
[32] | 86 | $a_passwd = $_POST['a_passwd']; |
---|
[2] | 87 | $n_passwd = $_POST['n_passwd']; |
---|
| 88 | $n_passwd_2 = $_POST['n_passwd_2']; |
---|
| 89 | |
---|
| 90 | if(!$GLOBALS['phpgw']->acl->check('changepassword', 1) || $_POST['cancel']) |
---|
| 91 | { |
---|
[72] | 92 | if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) |
---|
| 93 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); |
---|
[1681] | 94 | |
---|
[35] | 95 | if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) |
---|
| 96 | Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); |
---|
| 97 | else |
---|
| 98 | $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); |
---|
[1681] | 99 | |
---|
[2] | 100 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | $GLOBALS['phpgw']->template->set_file(array( |
---|
| 104 | 'form' => 'changepassword.tpl' |
---|
| 105 | )); |
---|
[32] | 106 | $GLOBALS['phpgw']->template->set_var('lang_enter_actual_password',lang('Enter your actual password')); |
---|
[2] | 107 | $GLOBALS['phpgw']->template->set_var('lang_enter_password',lang('Enter your new password')); |
---|
| 108 | $GLOBALS['phpgw']->template->set_var('lang_reenter_password',lang('Re-enter your password')); |
---|
| 109 | $GLOBALS['phpgw']->template->set_var('lang_change',lang('Change')); |
---|
| 110 | $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel')); |
---|
| 111 | $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/preferences/changepassword.php')); |
---|
| 112 | |
---|
[72] | 113 | if ($_GET['cd'] == 1) |
---|
| 114 | { |
---|
| 115 | $lang1 = lang('Your password has expired'); |
---|
| 116 | $lang2 = lang('You must register a new password'); |
---|
| 117 | $GLOBALS['phpgw']->template->set_var('messages',"<font color=red><h1>$lang1.<br>$lang2.</h1></font>"); |
---|
| 118 | } |
---|
| 119 | |
---|
[2] | 120 | if ($GLOBALS['phpgw_info']['server']['auth_type'] != 'ldap') |
---|
| 121 | { |
---|
| 122 | $GLOBALS['phpgw']->template->set_var('sql_message',lang('note: This feature does *not* change your email password. This will ' |
---|
| 123 | . 'need to be done manually.')); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | if ($_POST['change']) |
---|
[1681] | 127 | { |
---|
| 128 | include(personalize_include_path('preferences','changepassword')); |
---|
| 129 | } |
---|
[2] | 130 | else |
---|
| 131 | { |
---|
| 132 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Change your password'); |
---|
| 133 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 134 | echo parse_navbar(); |
---|
| 135 | |
---|
| 136 | $GLOBALS['phpgw']->template->pfp('out','form'); |
---|
| 137 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 138 | } |
---|
| 139 | ?> |
---|