Changeset 3296 for branches/2.2
- Timestamp:
- 09/28/10 09:20:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/preferences/changepassword.php
r3279 r3296 11 11 \**************************************************************************/ 12 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 13 76 14 77 $GLOBALS['phpgw_info']['flags'] = array( … … 20 83 include('../header.inc.php'); 21 84 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 36 function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha)37 {38 require_once('/var/www/expresso/security/classes/CertificadoB.php');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 44 $cc=ldap_connect($ldap_servidor);45 46 if($GLOBALS['phpgw_info']['server']['ldap_version3'])47 {48 ldap_set_option($cc, LDAP_OPT_PROTOCOL_VERSION, 3);49 }50 51 // bind ..52 $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd);53 54 $filtro = 'uidNumber='.$aux_uid;55 56 // Pesquisa uidNumber no LDAP57 $sr=ldap_search($cc, $ldap_context,$filtro);58 59 // Pega resultado ....60 $info = ldap_get_entries($cc, $sr);61 62 // Tem de achar só uma entrada.....ao menos uma....63 if($info["count"]!=1)64 { if($GLOBALS['phpgw_info']['server']['ldap_version3'])65 {66 ldap_set_option($cc, LDAP_OPT_PROTOCOL_VERSION, 3);67 }68 ldap_close($cc);69 return false;70 }71 72 if(!$info[0]["usercertificate"][0])73 {74 //Usuario sem certificado cadastrado75 ldap_close($cc);76 return false;77 }78 79 $a = new certificadoB();80 $R = $a->encriptar_senha($aux_senha,$info[0]["usercertificate"][0]);81 if(!$R)82 {83 return false;84 }85 $user_info = array();86 $aux1 = $info[0]["dn"];87 $user_info['cryptpassword'] = $R;88 ldap_modify($cc,$aux1,$user_info);89 90 ldap_close($cc);91 92 return true;93 }94 85 $a_passwd = $_POST['a_passwd']; 95 86 $n_passwd = $_POST['n_passwd'];
Note: See TracChangeset
for help on using the changeset viewer.