Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:31:21+00:00 2026-05-24T09:31:21+00:00

I have a non-Drupal site which authenticates with a simple MySQL user database. I

  • 0

I have a non-Drupal site which authenticates with a simple MySQL user database. I want to share that user information with my Drupal site. So I guess either:

  • have some system whereby the external user database is automatically / regularly copied into the Drupal user database, which has the advantage of not messing with Drupal’s login system; or
  • change Drupal’s login system so it checks the username and password against this external database and then presumably (knowing that Drupal likes to keep things local) creating a local account if it hasn’t already.

The problem here though is that there are two user databases and if information such as passwords gets changed on one, this is not reflected on the other. Drupal would need to check the username and the password against the external db, and not keep its own password record. But I also want to take some profile information from the external db, and this would run into the problem of duplicate records.

So I guess the first solution is preferred, but then if the script is only set to run, say, once per hour, then the user cannot login to the Drupal site within an hour of signing up with the external site. Also it seems to be a very “non-Drupal” way of doing things.

A further problem is that the user will have to log in twice, but the Drupal site is meant to be a seamless extension of the external site so logging in twice isn’t preferred. However, this is the least priority as there could be a message telling users to log in again “for security reasons”.

Any suggestions??

EDIT: I do have some scope to edit the external site. Perhaps a simpler way would be to have the external site authenticate through Drupal’s user db? The best way seems to be if the Drupal db replaces the external db so the external site’s user db IS Drupal’s. Or the user simply logs in via Drupal and the external site knows somehow that he has done so. Either of those sound simpler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:31:22+00:00Added an answer on May 24, 2026 at 9:31 am

    The way I’m currently doing it is to have Drupal authenticate against the external DB and just ignore the password stored in the Drupal DB. If the username doesn’t exist in the external DB, then it just reverts to authenticating normally against the Drupal DB.

    In hook_form_user_login_alter, you can search through the $form[‘#validate’] array and replace user_login_authenticate_validate with your own function that checks the external DB.

    Something like:

    function MYMODULE_form_user_login_alter(&$form, $form_state) {
        $array_key = array_search('user_login_authenticate_validate', $form['#validate']);
        if ($array_key === FALSE) {
            $final_validator = array_pop($form['#validate']);
                $form['#validate'][] = 'mymodule_validate';
                $form['#validate'][] = $final_validator;
        }
        else {
            $form['#validate'][$array_key] = 'mymodule_validate';
        }
    }
    
    function mymodule_validate($form, &$form_state) {
        if (mymodule_user_exists($form_state['values']['name'])) {
            if (mymodule_check_password($form_state['values']['name'], $form_state['values']['pass'])) {
                user_external_login_register($form_state['values']['name'], 'mymodule');
                user_authenticate_finalize($form_state['values']);
                // maybe sync some data here
            }
        }
        else {
            user_login_authenticate_validate($form, $form_state);
        }
    }
    

    You can also make use of hook_user to sync some data (or prevent editing) when the user registers or tries to update their account.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a non-Drupal website create a user account in my Drupal
I've been trying to deal with some delimited text files that have non standard
I have a non-.Net executable file that is included in my .net assembly as
I have a non-visual component which manages other visual controls. I need to have
We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests
Suppose I have a non-recurring event that needs to be raised X seconds from
I have created a non-visual component in C# which is designed as a placeholder
I'm getting a redirect loop on a Drupal 7 install. Whenever a non-admin user
I have two database tables, one in MYSQL and one in MSSQL. Both have
If I have a non-template (i.e. normal) class and wish to have a template

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.