before installing the LDAP module I was parsing credentials from a html webform from another site using code like this:
<?php
chdir('../../');
define('DRUPAL_ROOT', getcwd());
require './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
$userName = $_REQUEST['txtUsernameEmployees'];
$password = $_REQUEST['txtPasswordEmployees'];
$account = user_authenticate($userName, $password);
$user = user_load($account, TRUE);
drupal_session_regenerate();
if($user->uid > 0)
header("Location: /myDrupalSite/");
else
header("Location: ../login/");
?>
this still works for 'drupal' users but NOT for LDAP users. is there a way to alter this so that it works with the LDAP module? if so, any direction on how to do that would be greatly appreciated.
Comments
Comment #1
johnbarclay commentedyes. configure and ldap server instance. use one of the test credentials functions in the ldap module to test the credentials, passing that server id (sid) as one of the arguments.
Comment #2
trapper-1 commentedexcuse my ignorance, but that went over my head.
I have an LDAP server configured with Authorization module and have it working.
I also have a stand-alone website with a login page (html form) that hits login.php when the form is submitted. the code I pasted about is everything that is in login.php.
The code above initiates a drupal user connection and, upon success, redirects the user to the drupal site.
are you suggesting I need another LDAP server configuration using the LDAP module? where are the 'test credentials functions' and how would I parse an (sid) to one of them? I am just confused here...If you have the time to 'dumb this down' I would greatly appreciate it.
thanks
Comment #3
johnbarclay commentedso if you configure ldap authentication to take mixed mode, the code you already have may work.
Comment #4
trapper-1 commentedI changed to mixed mode and tested with the same results. I can login from the external website using a drupal-only account (user 1), but this code does not work for LDAP accounts.
I am just taking a stab in the dark, but it would seem that I could replace the "user_authenticate" part of my code with a function of similar results from the LDAP module? I have no idea where to being looking for this function though...
Comment #5
trapper-1 commentedupdate - bug??
I created an account in drupal with the exact username as a known AD account (with a different password).
results:
logging in from Drupal login bock:
1)When I login using this account and the AD password then Drupal LDAP recognizes my AD account, logs me in. When I visit my account 'edit' page, the password field is greyed out and empty.
2) I can still login using the same account name but using the Drupal password that was assigned when I originally created the account (within Drupal)
logging in from external website using code pasted above:
1)When I login using this account and the AD password I go nowhere:
header("Location: ../login/");2)When I login using this account and the Drupal password I get redirected to my Drupal site, logged-in.
Looks like Drupal is storing the old password somewhere? does the LDAP password actually get stored in the Drupal database?
Comment #6
johnbarclay commentedno. the ldap password is not stored.
Comment #7
johnbarclay commented