Changeset 1681
- Timestamp:
- 11/19/09 13:59:58 (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/login.php
r1152 r1681 126 126 } 127 127 128 $login_include = $GLOBALS['phpgw_info']['server']['template_dir'] . '/login_' . $GLOBALS['phpgw_info']['login_template_set'] . '.php'; 129 130 if(!$login_include || !file_exists($login_include)) 131 { 132 $aux = explode('phpgwapi',$GLOBALS['phpgw_info']['server']['template_dir']); 133 $login_include = $aux[0] . 'phpgwapi/templates/default/login_default.php'; 134 } 135 136 include($login_include); 137 128 include(personalize_include_path('phpgwapi','login')); 138 129 ?> 139 130 -
trunk/phpgwapi/inc/class.auth_ldap.inc.php
r393 r1681 200 200 } 201 201 202 function change_password_user ($old_passwd, $new_passwd, $dn, $referrals=false) 203 { 204 //Use with RHDS 205 //system('echo "CP old_passwd: '.$old_passwd.'" >>/tmp/controle'); 206 //system('echo "CP new_passwd: '.$new_passwd.'" >>/tmp/controle'); 207 //system('echo "CP dn: '.$dn.'" >>/tmp/controle'); 208 //system('echo "CP referrals: '.$referrals.'" >>/tmp/controle'); 209 $ds=ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 210 if (!$ds) 211 { 212 //system('echo "CP Nao conectou no ldap" >>/tmp/controle'); 213 $this->auth_reason = ldap_errno($ldap); 214 return False; 215 } 216 else 217 { 218 if ($referrals) 219 { 220 //system('echo "CP Entrou referrals" >>/tmp/controle'); 221 $this->passwd=$old_passwd; 222 $this->dn=$dn; 223 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); 224 ldap_set_option($ds, LDAP_OPT_REFERRALS, 1); 225 if($GLOBALS['phpgw_info']['server']['diretorioescravo']) 226 { 227 ldap_set_rebind_proc($ds, array($this, '_rebindProc')); 228 } 229 } 230 $modify["userpassword"]=$new_passwd; 231 if (!@ldap_bind($ds,$dn,$old_passwd)) 232 { 233 //system('echo "CP nao conseguiu dar bind" >>/tmp/controle'); 234 //Se a politica estiver no diretorio eh necessario tentar alterar a senha mesmo que nao haja um bind, pois a negacao de bind pode ser proveniente de uma expiracao 235 if($GLOBALS['phpgw_info']['server']['politicasenhas']=='diretorio') 236 { 237 //system('echo "CP politica eh no diretorio" >>/tmp/controle'); 238 if (!@ldap_mod_replace($ds,$dn,$modify)) 239 { 240 //system('echo "CP nao conseguiu fazer replace!" >>/tmp/controle'); 241 $this->auth_reason = ldap_errno($ds); 242 return false; 243 } 244 else 245 { 246 //system('echo "CP replace funcionou!" >>/tmp/controle'); 247 return $new_passwd; 248 } 249 } 250 $this->auth_reason = ldap_errno($ds); 251 return False; 252 } 253 else 254 { 255 //system('echo "CP Conseguiu dar bind" >>/tmp/controle'); 256 if (!ldap_mod_replace($ds,$dn,$modify)) 257 { 258 $this->auth_reason = ldap_errno($ds); 259 return False; 260 } 261 else 262 { 263 return $new_passwd; 264 } 265 } 266 } 267 } 268 269 202 270 function update_lastlogin($_account_id, $ip) 203 271 { -
trunk/phpgwapi/inc/common_functions.inc.php
r1321 r1681 685 685 686 686 /*! 687 @function personalize_include_path 688 @abstract return path to include a "ile.php" 689 @author Serpro 690 @author Antonio Carlos da SIlva 691 @discussion This function is used to generate a path with $app and $prefix paramameters. 692 @example include(personalize_include_path('phpgwapi','login'); 693 @example Will generate : /var/www/expresso/phpgwapi/templates/default/login_default.php 694 @example if "default" is the 'login_template_set' . 695 @param $app : name of application 696 @param $prefix : value to affix in login_template_set 697 */ 698 function personalize_include_path($app,$prefix) 699 { 700 $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/' . $GLOBALS['phpgw_info']['login_template_set'] . '/' . $prefix . '_' . $GLOBALS['phpgw_info']['login_template_set'] . '.php'; 701 if(!$file_include || !file_exists($file_include)) 702 { 703 $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/default/' . $prefix .'_default.php'; 704 } 705 return $file_include; 706 } 707 708 /*! 687 709 @function CreateObject 688 710 @abstract Load a class and include the class file if not done so already. -
trunk/preferences/changepassword.php
r1174 r1681 20 20 include('../header.inc.php'); 21 21 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 22 36 function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha) 23 { 37 { 24 38 require_once('/var/www/expresso/security/classes/CertificadoB.php'); 25 39 $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context']; … … 28 42 $ldap_passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 29 43 30 $cc=ldap_connect($ldap_servidor); 44 $cc=ldap_connect($ldap_servidor); 31 45 32 46 // bind .. 33 $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); 47 $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); 34 48 35 49 $filtro = 'uidNumber='.$aux_uid; 36 50 37 51 // Pesquisa uidNumber no LDAP 38 $sr=ldap_search($cc, $ldap_context,$filtro); 52 $sr=ldap_search($cc, $ldap_context,$filtro); 39 53 40 54 // Pega resultado .... 41 55 $info = ldap_get_entries($cc, $sr); 42 56 43 57 // Tem de achar só uma entrada.....ao menos uma.... 44 58 if($info["count"]!=1) … … 57 71 $a = new certificadoB(); 58 72 $R = $a->encriptar_senha($aux_senha,$info[0]["usercertificate"][0]); 59 if(!$R) 73 if(!$R) 60 74 { 61 75 return false; … … 70 84 return true; 71 85 } 72 73 86 $a_passwd = $_POST['a_passwd']; 74 87 $n_passwd = $_POST['n_passwd']; … … 79 92 if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) 80 93 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); 81 94 82 95 if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 83 96 Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 84 97 else 85 98 $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); 86 99 87 100 $GLOBALS['phpgw']->common->phpgw_exit(); 88 101 } … … 112 125 113 126 if ($_POST['change']) 114 { 115 // Default number of letters = 3 116 if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass']) 117 $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3; 118 // Default number of special letters = 0 119 if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) 120 $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0; 121 if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) 122 { 123 $errors[] = lang('Your actual password is wrong'); 124 } 125 else if ($n_passwd != $n_passwd_2) 126 { 127 $errors[] = lang('The two passwords are not the same'); 128 } 129 else if ($a_passwd == $n_passwd) 130 { 131 $errors[] = lang('Your old password and your new password are the same. Choose a different new password'); 132 } 133 else if (! $n_passwd) 134 { 135 $errors[] = lang('You must enter a password'); 136 } 137 else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) 138 { 139 $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']); 140 } 141 142 // Special Letters 143 $speccial_letter = 0; 144 for ($i=0; $i<strlen($n_passwd); $i++) 145 { 146 $letter = $n_passwd[$i]; 147 if (! ereg ("[a-zA-Z]", $letter ) ) 148 $speccial_letter++; 149 } 150 if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) 151 { 152 $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']); 153 } 154 155 if(is_array($errors)) 156 { 157 $GLOBALS['phpgw']->common->phpgw_header(); 158 echo parse_navbar(); 159 $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); 160 $GLOBALS['phpgw']->template->pfp('out','form'); 161 $GLOBALS['phpgw']->common->phpgw_exit(True); 162 } 163 164 $o_passwd = $GLOBALS['phpgw_info']['user']['passwd']; 165 $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); 166 if(!$passwd_changed) 167 { 168 $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.'; 169 $GLOBALS['phpgw']->common->phpgw_header(); 170 echo parse_navbar(); 171 $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); 172 $GLOBALS['phpgw']->template->pfp('out','form'); 173 $GLOBALS['phpgw']->common->phpgw_exit(True); 174 } 175 else 176 { 177 $GLOBALS['phpgw_info']['user']['passwd'] = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); 178 $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 179 $GLOBALS['hook_values']['old_passwd'] = $o_passwd; 180 $GLOBALS['hook_values']['new_passwd'] = $n_passwd; 181 $GLOBALS['phpgw']->hooks->process('changepassword'); 182 183 if($GLOBALS['phpgw_info']['server']['certificado']) 184 { 185 if(!$GLOBALS['phpgw_info']['server']['atributousuarios'] or $GLOBALS['phpgw_info']['server']['atributousuarios'] == "person") 186 { 187 $RR = grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd); 188 } 189 } 190 191 if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 192 Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 193 else 194 $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); 195 } 196 } 127 { 128 include(personalize_include_path('preferences','changepassword')); 129 } 197 130 else 198 131 {
Note: See TracChangeset
for help on using the changeset viewer.