External database authentication using a view

External database authentication using a view

by Steen Pedersen -
Number of replies: 2

Hi

We have a new Moodle server and several external users is going to use this server. The users are created in an external SQL server and I have been given the following information about this server:

SQl server IP-Address

Username

Password

Name of the view they have created with the relevant users (there are a lot of other users in the same database). 

I have read the following regarding external database connection:

https://docs.moodle.org/39/en/External_database_authentication

And I have checked the fields in question on our Moodle server. 

Is it possible to connect to a view on a SQL server from Moodle´s external database configuration (Site administration > Plugins > Authentication > External database)?

Or do you have to connect to the specific database and specify the tables in question?

Our Moodle server has the following specs.:

Moodle version: Moodle 3.9.1

Operating system: Debian 10.5

Database: MariaDB

WebServer: Nginx


Best Regards

Steen Pedersen


Average of ratings: -
In reply to Steen Pedersen

Re: External database authentication using a view

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Yes, you need to be able to read all the user columns needed (username, email, first name, last name, password, etc.) from a single database object so if these aren't available from one table you must create a view which joins the necessary tables. Then specify the name of this view in the Table (auth_db | table) field. Moodle doesn't do anything special for this, it just issues a SELECT statement to the external database via the selected PHP database driver on the specified object, table or view.

Here's another reply which may be relevant.

Average of ratings: Useful (1)
In reply to Leon Stringer

Ang: Re: External database authentication using a view

by Steen Pedersen -
Hi Leon

Thank you very much for your answer. I think this is exactly the information we need to get our external database authentication to work smile.

Best Regards

Steen Pedersen