Changing Password Error

Get help from the community here.

Moderator: Developers

Re: Changing Password Error

Postby WilmarVB » Thu Nov 17, 2011 10:03 am

Hello Methleraner,

Hard to say without seeing what your script is doing ;-)
Kind regards,
WilmarVB
Intermesh
User avatar
WilmarVB
Group-Office Developer
 
Posts: 86
Joined: Mon May 10, 2010 3:47 pm
Location: Den Bosch, Netherlands

Re: Changing Password Error

Postby Methleraner » Thu Nov 17, 2011 11:31 am

Here is my code.

Code: Select all
if(!empty($_POST["password2"]))
         {
            $user['password']=($_POST["password2"]);
            $hmail_mysqlhost="localhost"; // MySQL-Host angeben
            $hmail_mysqluser="Benutzer"; // MySQL-User angeben
            $hmail_mysqlpwd="Passwort"; // Passwort angeben
            $hmail_mysqldb="hmail"; // Gewuenschte Datenbank angeben
            
            $groupware_mysqlhost="localhost"; // MySQL-Host angeben
            $groupware_mysqluser="Benutzer"; // MySQL-User angeben
            $groupware_mysqlpwd="Passwort"; // Passwort angeben
            $groupware_mysqldb="groupoffice"; // Gewuenschte Datenbank angeben
            

            $hmail_connection=mysql_connect($hmail_mysqlhost, $hmail_mysqluser, $hmail_mysqlpwd) or die ("Verbindungsversuch zu hMail-SQL fehlgeschlagen");
            mysql_select_db($hmail_mysqldb, $hmail_connection) or die("Konnte die Datenbank hMail nicht waehlen.");
            mysql_query("UPDATE hm_accounts SET accountpassword = '".md5($_POST["password2"])."' WHERE accountaddress = '".$user['email']."' ");
            mysql_close($hmail_connection);
            
            $groupware_connection=mysql_connect($groupware_mysqlhost, $groupware_mysqluser, $groupware_mysqlpwd) or die ("Verbindungsversuch zu groupware-SQL fehlgeschlagen");
            mysql_select_db($groupware_mysqldb, $groupware_connection) or die("Konnte die Datenbank groupware nicht waehlen.");
            mysql_query("UPDATE em_accounts SET password_encrypted = '0', password = '" .($_POST["password2"])."' WHERE username = '".$user['email']."' ");
            mysql_close($groupware_connection);
            
            }
Methleraner
 
Posts: 41
Joined: Tue Jun 28, 2011 10:25 am

Re: Changing Password Error

Postby WilmarVB » Tue Nov 22, 2011 1:00 pm

Hello Methleraner,

1) Did you encrypt your password?
2) Look for 'save_account_properties' in modules/email/action.php.
3) Look for function update_account in modules/email/classes/email.class.inc.php and function encrypt in classes/cryptastic.class.inc.php.
Kind regards,
WilmarVB
Intermesh
User avatar
WilmarVB
Group-Office Developer
 
Posts: 86
Joined: Mon May 10, 2010 3:47 pm
Location: Den Bosch, Netherlands

Re: Changing Password Error

Postby Methleraner » Wed Nov 30, 2011 8:44 am

WilmarVB wrote:Hello Methleraner,

1) Did you encrypt your password?


At first, I decrypt my password and then it will automaticly encrypt.

WilmarVB wrote:2) Look for 'save_account_properties' in modules/email/action.php.


Code: Select all
$account['mbroot'] = isset($_POST['mbroot']) ? $_POST['mbroot'] : '';

         if ($_POST['name'] == "" ||   $_POST['email'] == "" ||
                     ($GO_MODULES->modules['email']['write_permission'] && ($_POST['port'] == "" ||
                                             $_POST['username'] == "" ||
                                             $_POST['password'] == "" ||
                                             $_POST['host'] == "" ||
                                             $_POST['smtp_host'] == "" ||
                                             $_POST['smtp_port'] == ""))) {
            $response['feedback'] = $lang['common']['missingField'];
         }else {
            $account['id']=isset($_POST['account_id']) ? ($_POST['account_id']) : 0;

            if(isset($_POST['username'])) {
               $account['mbroot'] = isset($_POST['mbroot']) ? $_POST['mbroot'] : '';
               $account['use_ssl'] = isset($_REQUEST['use_ssl'])  ? '1' : '0';
               //$account['novalidate_cert'] = isset($_REQUEST['novalidate_cert']) ? '1' : '0';
               $account['examine_headers'] = isset($_POST['examine_headers']) ? '1' : '0';
               $account['type']=$_POST['type'];
               $account['host']=$_POST['host'];
               $account['port']=$_POST['port'];
               $account['username']=$_POST['username'];
               $account['password']=$_POST['password'];

               $account['smtp_host']=$_POST['smtp_host'];
               $account['smtp_port']=$_POST['smtp_port'];
               $account['smtp_encryption']=$_POST['smtp_encryption'];
               $account['smtp_username']=$_POST['smtp_username'];
               $account['smtp_password']=$_POST['smtp_password'];
            }
            $account['name']=$_POST['name'];
            $account['email']=$_POST['email'];
            $account['signature']=$_POST['signature'];

            if ($account['id'] > 0) {
               if(isset($_REQUEST['user_id'])) {
                  $account['user_id']=$_REQUEST['user_id'];

                  $old_account = $email->get_account($account['id']);
                  if($old_account['user_id']!=$account['user_id']){
                     $GO_SECURITY->chown_acl($old_account['acl_id'], $account['user_id']);
                  }

               }

               $account['sent']=$_POST['sent'];
               $account['drafts']=$_POST['drafts'];
               $account['trash']=$_POST['trash'];

               if($GO_MODULES->modules['email']['write_permission']) {
                  if(!$email->update_account($account)) {
                     throw new Exception(sprintf($lang['email']['feedbackCannotConnect'],$_POST['host'], $imap->last_error(), $_POST['port']));
                  }
               }else {
                  if(!$email->_update_account($account)) {
                     throw new DatabaseUpdateException();
                  }
               }

               $response['success']=true;

               $use_systemusers = true;
               if(isset($GO_MODULES->modules['serverclient'])) {
                  require_once($GO_MODULES->modules['serverclient']['class_path'].'serverclient.class.inc.php');
                  $sc = new serverclient();

                  if(count($sc->domains)) {
                     $use_systemusers = false;

                     foreach($sc->domains as $domain) {
                        if(!$GO_MODULES->modules['email']['write_permission']) {
                           $account = $email->get_account($account['id']);
                           $account = $email->decrypt_account($account);
                        }

                        if(strpos($account['email'], '@'.$domain)) {
                           $sc->login();

                           require_once($GO_CONFIG->class_path.'mail/RFC822.class.inc');
                           $RFC822 = new RFC822();

                           $forward_to=$RFC822->reformat_address_list($_POST['forward_to'],true);
                           if($forward_to===false) {
                              throw new Exception($lang['common']['invalidEmailError']);
                           }

                           //For LDAP auth with usernames without the domain in it.
                           if(!strpos($account['username'],'@')){
                              $arr= explode('@',$account['email']);
                              $account['username'] .= '@'.$arr[1];
                           }


                           $params=array(
                                       //'sid'=>$sc->sid,
                                       'task'=>'serverclient_set_vacation',
                                       'username'=>$account['username'],
                                       'password'=>$account['password'],
                                       'vacation_active'=>isset($_POST['vacation_active']) ? '1' : '0',
                                       'vacation_subject'=>$_POST['vacation_subject'],
                                       'vacation_body'=>$_POST['vacation_body'],
                                       'forward_to'=>$_POST['forward_to']
                           );

                           $server_response = $sc->send_request($GO_CONFIG->serverclient_server_url.'modules/postfixadmin/action.php', $params);

                           $decoded = json_decode($server_response, true);
                           
                           if(!isset($decoded['success']))
                              throw new Exception('Serverclient Could not connect to '.$GO_CONFIG->serverclient_server_url.': '.$server_response);

                           if(!$decoded['success']) {
                              throw new Exception($decoded['feedback']);
                           }
                           break;
                        }

                     }
                  }
               }

               if(isset($GO_MODULES->modules['systemusers']) && $use_systemusers) {
                  exec('whereis vacation', $return);
                  if(isset($return[0])) {
                     $params = explode(' ', $return[0]);
                  }

                  $vacation_exec = (isset($params[1])) ? $params[1] : false;
                  if(!is_executable($vacation_exec)) {
                     require_once ($GO_LANGUAGE->get_language_file('systemusers'));
                     //throw new Exception($lang['systemusers']['vacation_not_executable_error']);
                  }


                  require_once($GO_MODULES->modules['systemusers']['class_path'].'systemusers.class.inc.php');
                  $su = new systemusers();

                  $vacation['vacation_active'] = isset($_POST['vacation_active']) ? '1' : '0';
                  $vacation['vacation_subject'] = isset($_POST['vacation_subject']) ? ($_POST['vacation_subject']) : '';
                  $vacation['vacation_body'] = isset($_POST['vacation_body']) ? ($_POST['vacation_body']) : '';
                  $vacation['forward_to'] = isset($_POST['forward_to']) ? ($_POST['forward_to']) : '';
                  $vacation['account_id'] = $account['id'];

                  if($su->get_vacation($vacation['account_id'])) {
                     $su->update_vacation($vacation);
                  }else {
                     $su->add_vacation($vacation);
                  }

                  $cmd = $GO_CONFIG->cmd_sudo.' '.$GO_MODULES->modules['systemusers']['path'].'sudo.php '.$GO_CONFIG->get_config_file().' set_vacation '.$vacation['account_id'];
                  //go_debug($cmd);
                  exec($cmd);


I dont find antything to turn off the message.

WilmarVB wrote:3) Look for function update_account in modules/email/classes/email.class.inc.php and function encrypt in classes/cryptastic.class.inc.php.




Code: Select all
function update_account_order($account) {
      $this->replace_row('em_accounts_sort', $account);
   }


   function _update_account($account) {
      if(isset($account['name'])) {
         $alias['default']='1';
         $alias['account_id']=$account['id'];
         $alias['name']=$account['name'];

         if(isset($account['email']))
            $alias['email']=$account['email'];

         if(isset($account['signature']))
            $alias['signature']=$account['signature'];

         $this->update_row('em_aliases',array('account_id', 'default'), $alias);

         unset($account['name'],$account['email'],$account['signature']);
      }

      return $this->update_row('em_accounts', 'id', $account,'', false);
   }



An now? :D Sorry ... I dont understand what i must to do now.
Methleraner
 
Posts: 41
Joined: Tue Jun 28, 2011 10:25 am

Re: Changing Password Error

Postby WilmarVB » Thu Dec 01, 2011 4:53 pm

I think it's safe to say that your login will go smoothly if you use the same encryption method as Group-Office does for the IMAP passwords:
Code: Select all
            require_once($GO_CONFIG->class_path.'cryptastic.class.inc.php');
            $c = new cryptastic();

            $encrypted = $c->encrypt($account['password']);
            if($encrypted){
               $account['password']=$encrypted;
               $account['password_encrypted']=2;
            }else
            {
               $account['password_encrypted']=0;
            }

This comes from somewhere around line 600 in /path/to/go/modules/email/classes/email.class.inc.php . Good luck ;-)
Kind regards,
WilmarVB
Intermesh
User avatar
WilmarVB
Group-Office Developer
 
Posts: 86
Joined: Mon May 10, 2010 3:47 pm
Location: Den Bosch, Netherlands

Previous

Return to General help

Who is online

Users browsing this forum: No registered users and 1 guest