CSS: Providing seven essential vitamins and minerals since 1996.
Have a steaming hot, delicious slice of Standards.

Active Directory Authentication from PHP on Linux via Winbind

Active Directory Authentication from PHP on Linux via Winbind

September 22, 2007 by Richard

Now that you have Active Directory integration on Linux, you can authenticate against Active Directory from any application via a simple shell script. One I'm working on intergrates Active Directory authentication from PHP, without all the hassle of installing and using PHP's LDAP extension. Since I'm already configured to authenticate with winbind, I use a command that winbind provides to authenticate AD users, which makes the code required to do an authentication pretty simple.

# ntlm_auth --username='User' --password='password'

In the preceding code, I use the ntlm_auth (NT LAN Man Authentication) command to authenticate an AD user. The output from that command will tell me whether or not the authentication was successful, whether or not the username was correct, but the password wrong, or whether or not the user exists at all. From PHP, I'd get the results of that command like this:

<?php $result = shell_exec("ntlm_auth --username='User' --password='password'"); ?>

So, instead of a complicated LDAP script, I can just write a simple call to the shell and be done with it.

Comments

  • September 24, 2008 Bill says:

    I don't see the "results of that command like this:" It is just a blank space. I am interested in this blog about "Active Directory Authentication from PHP on Linux via Winbind" can you tell me more? Please.
  • April 22, 2009 Postman says:

    The result just return hex number, so you use that result for compare with your expression.
  • September 3, 2010 Jan Declercq says:

    Result on succes: NT_STATUS_OK: Succes (0x0) Result on fail: NT_STATUS_NO_SUCH_USER: No such user (0xc0000064) or: NT_STATUS_WRONG_PASSWORD: Wrong Password (0xc00006a)

Leave a Comment

Simple HTML is allowed: <code>, <b>, <i>, <u>, <var>, <strong>, <em>, <blockquote>, <ul>, <ol>, <li>, <p> (no attributes). All spacing and line breaks in your comment will be preserved.

Archive

PHP Powered XHTML 1.0 CSS
Copyright © 1998-2012 Richard York, All Rights Reserved.