Old Manual Accounts with same username as LDAP Accounts

Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді
Number of replies: 14

Hi there,

On our Moodle site we had a collection of manual local accounts. We have since moved onto LDAP. I have deleted the old local accounts. The usernames of the LDAP accounts are the same as the old ones.

When you try and login Moodle using LDAP it gives an incorrect username message. I only get this message when i try an login to Moodle with the same username as the old accounts. If i login with a new LDAP account that didnt have the same username as the old manual account it works flawlessly.

It seems to remember the old usernames in some way.

Does anyone know of any ideas to fix this please?

Thanks

Zak

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді

Since the last post i went into the database and removed all the old accounts in there. I am still having the problem.

Im not sure if its a problem with the username format. Our test accounts work fine but students dont

Test account username format: 07test

Real Student Account Format: t041JohnS

Help is appreciated

Thanks

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

HJWUCGA INC. - келді
did you make sure that your auth method for all users is "ldap" in their profile? If a new login is detected, Moodle will automatically create it for you. Also make sure that the default login method is ldap. It's in either mdl_config or mdl_config_plugins table (can't remember the exact place).


In reply to HJWUCGA INC.

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді

How do i make those config changes in the Database?

Thanks

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

HJWUCGA INC. - келді
To change the default to set it as ldap, use this query

ALTER TABLE `mdl_user` CHANGE `auth` `auth` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'ldap';

To check to see how many are not using LDAP

select id, auth, username from mdl_user where auth != 'ldap';

make a note of the number of records returned.

To replace all the users currently in your db (be careful with the admin account if it's manually created if you need it) to ldap

update mdl_user set auth = 'ldap' where auth != 'ldap';

the number of records you've just updated should be the same as the one you queried for those that are not using ldap.


That should do it. Again be careful with the admin account if you want to keep it as manual account so exclude that id/username from the update.

Don't forget to make a backup just in case.

I assume you know how to get to your database?


In reply to HJWUCGA INC.

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді

yes i will be getting to the Database using phpMyAdmin.

In the DB there are only 4 users. The admin account and 3 accounts that already work with LDAP.

I have run the first query, would i need to do the others?

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

HJWUCGA INC. - келді
Yes... The first query just sets the default as ldap is for any new accounts from that point onwards.

The 2nd one ensures you know how many will be updated and

the 3rd query is the one that actually updates the auth field with the value of 'ldap' for any existing accounts you have in the system.
In reply to HJWUCGA INC.

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді

Running the query to change LDAP to default didn't work sad

do i need to to the other 2 querys? The only other users in the Database already use LDAP and it works well

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді
In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

HJWUCGA INC. - келді
What errors are you encountering now?
In reply to HJWUCGA INC.

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді
Same saying invalid username and password
In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

Iñaki Arenaza - келді
Core developers қатысушының суреті Documentation writers қатысушының суреті Particularly helpful Moodlers қатысушының суреті Peer reviewers қатысушының суреті Plugin developers қатысушының суреті

I'd say the most probable cause is a mis-configuration of your LDAP settings. Are you sure you are using the right contexts for your users?

Iñaki.

In reply to Iñaki Arenaza

Re: Old Manual Accounts with same username as LDAP Accounts

Zak Fleming - келді

"Are you sure you are using the right contexts for your users?"

Sorry how do you mean?

I dont think it is a configuration error as my active directory test accounts work fine. These username where not used in the old install

In reply to Zak Fleming

Re: Old Manual Accounts with same username as LDAP Accounts

Iñaki Arenaza - келді
Core developers қатысушының суреті Documentation writers қатысушының суреті Particularly helpful Moodlers қатысушының суреті Peer reviewers қатысушының суреті Plugin developers қатысушының суреті

Are the test accounts and the student accounts in the same Organizational Unit (OU) in your Active Directory? If they aren't, you might have specified the OU for the test accounts in your LDAP settings (in the 'Contexts' setting, under the 'User Lookup settings' section), but not the OU for the student accounts.

That's what I was referring to.

Saludos. Iñaki.