Moodle
  1. Moodle
  2. MDL-41497

Can't connect to ODBC database for database enrolments

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      Enable the External DB auth plugin
      Go to the settings page for the plugin
      Verify that the Host field has help text next to the field including "Use a system DSN entry if using ODBC."
      Verify that the DB Name field has help text next to the field including "Leave empty if using an ODBC DSN."

      Enable the external db enrolment method for the site
      Go to the settings page for the external db enrolment method

      Verify that the dbhost field has help text next to the field including "Use a system DSN entry if using ODBC."
      Verify that the dbname field has help text next to the field including "Leave empty if using an ODBC DSN."

      Use a sanity check on the help text for these fields and complain if you think they don't make sense.

      Show
      Enable the External DB auth plugin Go to the settings page for the plugin Verify that the Host field has help text next to the field including "Use a system DSN entry if using ODBC." Verify that the DB Name field has help text next to the field including "Leave empty if using an ODBC DSN." Enable the external db enrolment method for the site Go to the settings page for the external db enrolment method Verify that the dbhost field has help text next to the field including "Use a system DSN entry if using ODBC." Verify that the dbname field has help text next to the field including "Leave empty if using an ODBC DSN." Use a sanity check on the help text for these fields and complain if you think they don't make sense.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull 2.4 Branch:
    • Pull 2.5 Branch:
    • Pull Master Branch:
      MDL-41497-master
    • Rank:
      52557

      Description

      Attempts to setup external database enrolment to an odbc database from a RedHat server fails to connect.

      $ sudo -u apache php sync.php -v
      Starting course synchronisation...
      PHP Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/moodlemaster/moodle/lib/adodb/drivers/adodb-odbc.inc.php on line 64

      Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/moodlemaster/moodle/lib/adodb/drivers/adodb-odbc.inc.php on line 64
      Error while communicating with external enrolment database
      Starting user enrolment synchronisation...
      PHP Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/moodlemaster/moodle/lib/adodb/drivers/adodb-odbc.inc.php on line 64

      Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/moodlemaster/moodle/lib/adodb/drivers/adodb-odbc.inc.php on line 64
      Error while communicating with external enrolment database

      In trying to setup an ODBC connection in Linux, lib/adodb/drivers/adodb-odbc.inc.php attempts to create a dsn less connection but fails to include a driver statement or the "server=".

        Issue Links

          Activity

          Hide
          Willy Lee added a comment -

          It's worth noting that to get this to work in 2.3, we had a dsn name in the database field of the configuration screen instead of the server name. That dsn was setup in /etc/odbc.ini . This no longer works since adodb-odbc.inc.php is trying to use a dsn less syntax.

          Show
          Willy Lee added a comment - It's worth noting that to get this to work in 2.3, we had a dsn name in the database field of the configuration screen instead of the server name. That dsn was setup in /etc/odbc.ini . This no longer works since adodb-odbc.inc.php is trying to use a dsn less syntax.
          Hide
          Willy Lee added a comment -

          Also, if you just reset $argDSN to the name of your DSN in line 60 of adodb-odbc.inc.php, everything works again.

          Show
          Willy Lee added a comment - Also, if you just reset $argDSN to the name of your DSN in line 60 of adodb-odbc.inc.php, everything works again.
          Hide
          Charles Fulton added a comment -

          It appears that ADODB changed how it validates the DSN in 5.17 (MDL-35184). See https://github.com/moodle/moodle/commit/ffdd502dbd4932e45cf3558ac305821997c2c4e6#diff-42.

          Show
          Charles Fulton added a comment - It appears that ADODB changed how it validates the DSN in 5.17 ( MDL-35184 ). See https://github.com/moodle/moodle/commit/ffdd502dbd4932e45cf3558ac305821997c2c4e6#diff-42 .
          Hide
          Willy Lee added a comment -

          Charles and I stepped through this and it appears that you can get it to work in my environment if you leave out the database name and put the name of a DSN in the database server name. It may be easier to document this in the form rather than change the vendor library.

          Show
          Willy Lee added a comment - Charles and I stepped through this and it appears that you can get it to work in my environment if you leave out the database name and put the name of a DSN in the database server name. It may be easier to document this in the form rather than change the vendor library.
          Hide
          Willy Lee added a comment -

          I put in some help text in this branch.

          https://github.com/willylee/moodle/tree/MDL-41497-master

          Show
          Willy Lee added a comment - I put in some help text in this branch. https://github.com/willylee/moodle/tree/MDL-41497-master
          Hide
          Dan Poltawski added a comment -

          Hi Guys,

          This seems like a sensible solution to me, thanks! I think we need to do the following:

          1. Need to do the same in the auth plugin, which will also be affected by this (I assume)
            # We should add a note in the release notes: http://docs.moodle.org/24/en/Upgrading#Possible_issues_that_may_affect_you_in_Moodle_2.4
            http://docs.moodle.org/25/en/Upgrading#Possible_issues_that_may_affect_you_in_Moodle_2.5
          2. Add branches for 2.5 and 2.4 too.
          Show
          Dan Poltawski added a comment - Hi Guys, This seems like a sensible solution to me, thanks! I think we need to do the following: Need to do the same in the auth plugin, which will also be affected by this (I assume) # We should add a note in the release notes: http://docs.moodle.org/24/en/Upgrading#Possible_issues_that_may_affect_you_in_Moodle_2.4 http://docs.moodle.org/25/en/Upgrading#Possible_issues_that_may_affect_you_in_Moodle_2.5 Add branches for 2.5 and 2.4 too.
          Hide
          Willy Lee added a comment -

          I added branches for 2.4 and 2.5 with the initial changes. I'll test database auth today.

          Show
          Willy Lee added a comment - I added branches for 2.4 and 2.5 with the initial changes. I'll test database auth today.
          Hide
          Willy Lee added a comment -

          Dan's inclination was correct and auth_db fails in exactly the same way. I added a new set of commits to all three branches that add some help text in the external database authentication form.

          Show
          Willy Lee added a comment - Dan's inclination was correct and auth_db fails in exactly the same way. I added a new set of commits to all three branches that add some help text in the external database authentication form.
          Hide
          Dan Poltawski added a comment -

          Think this looks good for integration then, thanks!

          Show
          Dan Poltawski added a comment - Think this looks good for integration then, thanks!
          Hide
          Damyon Wiese added a comment -

          Thanks Willy,

          Integrated to 24, 25 and master.

          I added a commit to fix a typo in the lang files (sysem not system).

          Show
          Damyon Wiese added a comment - Thanks Willy, Integrated to 24, 25 and master. I added a commit to fix a typo in the lang files (sysem not system).
          Hide
          Michael de Raadt added a comment -

          Test result: Success!

          Tested in 2.4, 2.5 and master.

          The new help strings appear.

          Show
          Michael de Raadt added a comment - Test result: Success! Tested in 2.4, 2.5 and master. The new help strings appear.
          Hide
          Damyon Wiese added a comment -

          This issue along with 77 of it's friends has been sent upstream and released to the world.

          Thankyou for your contribution.

          Show
          Damyon Wiese added a comment - This issue along with 77 of it's friends has been sent upstream and released to the world. Thankyou for your contribution.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: