Jump to content

ldap_bind with special characters


TheSambassador

Recommended Posts

Hello everyone!

 

I'm working on a PHP employee database that uses the local network's active directory to allow users to log in.

 

Basically, I'm using the ldap_bind command to authenticate and figure out what user is logging in.

 

The main snippet of code is:

 

$username = $_POST['username'];
$password = $_POST['password'];
$convertedPassword = utf8_encode($password);
if (ldap_bind($ds,"health1\\" . $username,$convertedPassword)){do stuff}

 

This works fine for normal username/passwords, but has been getting hung up on special characters.  I added the utf8_encode command, which allowed password with carrot (^) characters, but it still won't allow backslashes ( \ ).  I get

 

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in /var/www/emp/index.php on line 22

 

every time with a password such as "Blabla12\"

 

The utf8_encode command seems to be escaping the \, which I think is what I want.  Has anybody else had any luck with this?

 

-Sam

 

 

Link to comment
https://forums.phpfreaks.com/topic/220857-ldap_bind-with-special-characters/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.