Coding Thread, php - AD authentication in Coding and Web Development; Can anyone help?
I'm trying (failing miserably!) to create a simple login page for our web-based school reports. It's a ...
4th December 2012, 07:54 PM #1
php - AD authentication
Can anyone help?
I'm trying (failing miserably!) to create a simple login page for our web-based school reports. It's a php/mysql setup.
Basically, i'm trying to get the user to authenticate with AD, and on success go to page X else stay on login page, but my retard brain can't see how the code is meant to go together.
I've tried a number of examples i found on the www but i always get problems with them. They either authenticate 'successfully' without even showing me the login box and redirect me straight to page 1 (suggesting the auth bit of code is running before i 'submit' ) or i get errors for undefined variables etc.
it occurs to me as i write this that maybe it doesn't have to be php, just that's what i'm using.
4th December 2012, 09:33 PM #2
Im, not really sure what your are asking for help with. However this is how I would do it:
I would download this: adLDAP - LDAP Authentication with PHP for Active Directory
I would have my login form POST the users data over to Login_process.php which would then authenticate the user and then redirect. I've knocked up a quick example.
Login form -
<form action="login_process.php" method="POST">
<input type="text" name="username" />
<label for="password ">Password:</label>
<input type="password" name="password" />
You'll obviously want to sanitise the POST variables or detect if there empty and provide feedback to the user. I havent tested this code and I know that LDAP / AD can be a right pain to get right.
$username = $_POST('username');
$password = $_POST('password');
$adldap = new adLDAP();
$authUser = $adldap->user()->authenticate($username, $password);
if($authUser == true)
2 Thanks to jamiess:
detjo (5th December 2012), zag (5th December 2012)
5th December 2012, 09:24 AM #3
Thanks, Jamie. I'll give that a go
6th December 2012, 10:00 AM #4
Well I got it going in the end
I tried your example but got an error about expecting a string, then i had a thought that i would also want to include a 'deny' on direct URLs if the user was not logged in - which i already had with the current (now old) log-in.
When i started this project (over a year ago - it's now becoming version 2) the log-in was created by Dreamweaver as i knew zero about php, and it basically used a MySQL table to check user credentials. Dreamweaver also included the deny code on direct URLs too.
So, the answer was to use adLDAP (thanks for that) and swap the old Dreamweaver bit of code that checked the MySQL table, for the adLDAP bit that verified the user against AD - and with a couple of session variable tweaks, would also allow me to keep the deny stuff too.
And that's it. All up and running with AD authentication
By Crowmanuk in forum Internet Related/Filtering/Firewall
Last Post: 1st June 2010, 02:58 PM
By FN-GM in forum Web Development
Last Post: 18th August 2008, 02:03 PM
By plexer in forum How do you do....it?
Last Post: 22nd February 2007, 08:54 AM
Last Post: 29th August 2006, 02:13 PM
Last Post: 28th June 2006, 06:15 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)