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 | function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha) |
---|
14 | { |
---|
15 | require_once(PHPGW_SERVER_ROOT . '/security/classes/CertificadoB.php'); |
---|
16 | |
---|
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'])) ) |
---|
20 | { |
---|
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']; |
---|
25 | } |
---|
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 | } |
---|
33 | |
---|
34 | $cc=ldap_connect($ldap_servidor); |
---|
35 | |
---|
36 | if($GLOBALS['phpgw_info']['server']['ldap_version3']) |
---|
37 | { |
---|
38 | ldap_set_option($cc, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
39 | } |
---|
40 | |
---|
41 | $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); |
---|
42 | $filtro = 'uidNumber='.$aux_uid; |
---|
43 | $sr=ldap_search($cc, $ldap_context,$filtro); |
---|
44 | $info = ldap_get_entries($cc, $sr); |
---|
45 | |
---|
46 | if($info["count"]!=1) |
---|
47 | { |
---|
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]); |
---|
60 | |
---|
61 | if(!$R) |
---|
62 | { |
---|
63 | return false; |
---|
64 | } |
---|
65 | |
---|
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 | } |
---|
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 | |
---|
85 | $a_passwd = $_POST['a_passwd']; |
---|
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 | { |
---|
91 | if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) |
---|
92 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); |
---|
93 | |
---|
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'); |
---|
98 | |
---|
99 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
100 | } |
---|
101 | |
---|
102 | $GLOBALS['phpgw']->template->set_file(array( |
---|
103 | 'form' => 'changepassword.tpl' |
---|
104 | )); |
---|
105 | $GLOBALS['phpgw']->template->set_var('lang_enter_actual_password',lang('Enter your actual password')); |
---|
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 | |
---|
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 | |
---|
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']) |
---|
126 | { |
---|
127 | include(personalize_include_path('preferences','changepassword')); |
---|
128 | } |
---|
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 | ?> |
---|