Authentication against NT domain

Authentication against NT domain

by Richard Watkins -
Number of replies: 3

I've just been fiddling with my test installation and managed to get Moodle to authenticate against an NT password using UserServer found here http://clauer.free.fr/php/userserver.zip. I thought someone else might be able to use what I've found.

A few modifications to the login index.php were needed. But nothing too drastic. As far as Moodle is concerned, everyone's password is the same, currently 'password' but could be anything, and this is hard coded.

 if (CheckPassword($username, $password)) {
        $user = authenticate_user_login($frm->username, 'password');

.... other moodle code

}
else {
            $errormsg = get_string("invalidlogin");
       }

CheckPassword is a php function supplied with userserver which returns 1 if the username/password is valid.
Obviously accounts need to be created with user names matching the NT ones, but I will be creating the accounts anyway, so this isn't a problem for us.

Average of ratings: -
In reply to Richard Watkins

Re: Authentication against NT domain

by Richard Watkins -

I've just been thinking about this some more, and I guess it should be made an authentication module?

Can someone guide me on how I might do this please.

In reply to Richard Watkins

Re: Authentication against NT domain

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes, indeed - it should definitely be an authentication module.

Well, start out by copying another directory in "auth", eg "imap".

Edit lib.php ... at a minimum it just needs to contain one function:

function auth_user_login ($username, $password) {
/// Returns true if the username and password work
/// and false if they don't
}

See auth/ldap/lib.php for more advanced functions.

You also need to edit config.php to define your settings ... using names like auth_ntxxxxx for consistency with the other modules. These will all be available to your function later in the $CFG global variable. eg $CFG->auth_nthostname

You also need to define some new language strings in lang/en/auth.php

Send me some stuff when it's working, I can polish it up for CVS.
In reply to Richard Watkins

Re: Authentication against NT domain

by Richard Watkins -

I'm struggling to get this to work. It works fine as I have it currently (not as a module) but when I try to get it working as a module, Apache takes 99% of the processor and doesn't give it back until I kill it!!

I'll keep playing next year (school ends in 3 days, yay!) and see if I can figure the problem. The hack I have done solves our problem for now ;)