Urgent: Postgres User Account Lost

Discussion in '3CX Phone System - General' started by darrellchapman, Mar 9, 2008.

Thread Status:
Not open for further replies.
  1. darrellchapman

    Joined:
    Nov 26, 2007
    Messages:
    268
    Likes Received:
    0
    I sincerely apologize for cross posting this however, I am in quite a bind.

    Friday evening, Postgres crashed. I'm not exactly sure what happened but the end result was that 3CX could not log in to the database. I did my best to troubleshoot the issue, however not being very familiar with Postgres, I didn't make very progress. What I did find out though, is that the user account that it created at install time to log in to 3CX is the same user that is created in the database. However, this user had been deleted from the database (preventing 3CX from logging in)

    I tried to restore from a 3CX backup that I had made a few days earlier however this did not restore the missing user. Further troubleshooting lef me to find that there is a "phonesystem" user in the Postgres database however this password is unknown. I found reference to this password in the pg_auth file however the password is an MD5 hash. Does anyone know this password?

    Now, I'm not sure how to proceed here. I've tried uninstalling and re-installing with a blank database, performing a restore, but I continue to get the following error:

    Code:
    Can't connect to the database server - invalid password or login name
    
    
    SQLSTATE[08006] [7] FATAL:  password authentication failed for user "[DELETED]"<br>#0 C:\Program Files\3CX PhoneSystem\Data\Http\functions\CallContext.php(37): PDO->__construct('pgsql:dbname=ph...', '[DELETED], '[DELETED]')<br />
    #1 C:\Program Files\3CX PhoneSystem\Data\Http\functions\CallContext.php(86): CallContext->getConnection()<br />
    #2 C:\Program Files\3CX PhoneSystem\Data\Http\functions\fDN.php(83): CallContext->safeExec('select dn.iddn ...', Array, 'Cannot get DN o...')<br />
    #3 C:\Program Files\3CX PhoneSystem\Data\Http\functions\fObject.php(90): fDN->getData()<br />
    #4 C:\Program Files\3CX PhoneSystem\Data\Http\status.php(113): fObject->getManager()<br />
    #5 {main}							
    I've tried changing the auth mode in Postgres to "trust," logging in as "phonesystem," and successfully got in to the database (using the psql tool). From there I created the "3CX Admin" user with the current password, switch the auth mode back to "password" but still cannot log in.

    Any advice is greatly appreciated.

    Sincerely,
    Darrell Chapman
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. darrellchapman

    Joined:
    Nov 26, 2007
    Messages:
    268
    Likes Received:
    0
    I was able to change the auth mode of Postgres to "trust" so that I could login as the "phonesystem" user. Just an FYI: Turns out that when Postgres is in trust mode you can login with any known user in the database with having to provide a password. This allowed me to add the user account back via the psql Postgress utility (CREATE USER Admin WITH PASSWORD '*****';). I was a little confused about whether I needed to provide the password in encrypted format or not. Turns out that the Encryption is turned on by default so when I add the user, the password it automatically converted to the MD5 hash that is stored as the password.

    So at this point, 3CX can't connect to the DB but a few pages give me errors (specifically when dealing with lines). The weird thing is that my VoIP lines are now appearing as PSTN lines and, of course, don't work.

    Anyone have any suggestions now?

    Darrell Chapman
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. landfiets

    landfiets New Member

    Joined:
    Jul 17, 2007
    Messages:
    243
    Likes Received:
    0
    to help you maybe we need some more info. What windows are you using. did you install more versions on this one? Like 3.1? and how did you upgrade to 5.x. What kind of other software do you have running? Websites with DB? or Exchange?
    Have you tried to really erase everything from an old installation? In the most worse case, try to run it in virtual machine and see if it runs.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. darrellchapman

    Joined:
    Nov 26, 2007
    Messages:
    268
    Likes Received:
    0
    landfiets,

    Thanks for your reply.

    This is a dedicated 3CX v5.1 server installed on Windows 2003 Server Standard. Nothing else has been or was installed on it. The phone system was working fine and then we noticed that 3CX was unable to log in to the database. There is no explanation as to why this happened. None.

    The good news is that I was able to merge the old working database with the new database from a fresh install. From the differences in the two databases I can see that both my "3CX Admin" user was deleted as well as all of my providers in the "providers" table. This explains both of the errors I was receiving (unable to login and unable to enumerate the VoIP lines).

    Regardless, everything is back up and running now. I had to recreate the providers I had listed in the "providers" table and re-associate each provider with ID of the gateway in the "gateways" table.

    The good news to all of this is that I'm now quite familiar with the schema (structure) of the phonesystem database. Should anyone else have this issue, I should (hopefully) be able o help.

    Darrell Chapman
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.