Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-29-2006, 10:45 AM   #1
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
Compare LDAP password with php crypt password


I want to authenticate users on my LDAP server through a PHP script. To start with, I am just trying to match the passwords of LDAP with PHP. But when I try to bind to the ldap server with the dn uid=$user,ou=Users,dc=mydomain,dc=com - authentication fails because the crypt password generated in LDAP dosent match the password generated by the crypt () function in PHP.

I have searched a bit on crypt() function usage in php and tried few algorithms on the plain-text password, but none of the generated password hash matches the password stored in my LDAP database. I am using smbldap-tools in my implementation of LDAP, SAMBA PDC.

The password in LDAP database is 13 characters while php generates a 34 character crypted password string. I am confused on how to match the stored LDAP password with the php password.

Any help here will be appreciated..


Old 01-30-2006, 05:35 AM   #2
Senior Member
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 50
to verify a password, you do something like
if (crypt($user_input, $password_hash) == $password_hash) {
   echo "Password verified!";
because hashes are salted, so you need to give the salt in the original hash to generate the same hash; also, crypt() in PHP supports different algorithms (the 34 character one was probably MD5) and giving it the original hash will tell it to use the proper algorithm to use (the 13 character one is probably traditional DES)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
sync ldap and samba password with ldappasswd paul_mat Linux - Networking 2 11-21-2005 10:55 PM
deleting LDAP user...password? blink_00 SUSE / openSUSE 3 02-21-2005 11:24 AM
using a random file as password to dm-crypt qwijibow Linux - Security 6 11-08-2004 11:57 AM
How can I change e-mail password(or linux account password) with php in website?? yusuf Programming 1 05-28-2004 09:39 AM
change password at slave ldap u4113072 Linux - Software 0 11-12-2002 02:50 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration