How can I use the email instead of the username in LDAP authentication with PHP?

Mary



Currently, I am able to login using the username and password. I wish to be able to login using email address instead of the username. How do you suggest I do it?

Script:

$ldap['username'] = "domain\user123";
$ldap['password'] = "password123";
$ldap['host']   = 'site.domain.com';
$ldap['port']   = 389;
$ldap['dn'] = "CN=Users, DC=domain, DC=com";

$ldap['conn'] = ldap_connect( $ldap['host'], $ldap['port'] )
or die("Could not connect to {$ldap['host']}" );

$ldap['bind'] = ldap_bind($ldap['conn'], $ldap['username'], $ldap['password']);

if( !$ldap['bind'] )
{
echo "Failed";
}

else if( $ldap['bind'] )
{
echo "Success";
}

Any help would be very much appreciated.

Thanks so much!

heiglandreas

You will have to bind with a user with read-access to the LDAP-server, search for the DN of the user with the email-address in question and then use that DN to do a second bind. If the second bind is successful the user is logged in, if the second bind fails, the login fails.

I've created a gist showing that process at https://gist.github.com/heiglandreas/5689592

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I use the email instead of the username in LDAP authentication with PHP?

From Dev

Username authentication instead of email

From Dev

How can I use ldap authentication with full disk encryption?

From Dev

JWTAuth authentication with username instead of email

From Dev

How can I prevent Git from using an email of the form username@pc-name instead of an empty one?

From Dev

Authentication using username instead of email laravel 5.2

From Dev

Picketlink -How can i implement an authenticating that accept use username or email at same time

From Dev

Can I use Atlassian Crowd to authenticate gerrit instead of ldap?

From Dev

Java LDAP authentication with username

From Dev

Username and Password for LDAP Authentication

From Dev

how can i set username and password for basic http authentication?

From Dev

How to login with "UserName" instead of "Email" in MVC Identity?

From Dev

How to log in by email instead of username in Spring security

From Dev

Authentication using username or email

From Dev

How to change username authentication to email authentication in already buit project?

From Dev

How do I change the ASP.NET MVC default login page to login by username instead of email address?

From Dev

Using Spring, Basic Auth and LDAP, how can I get the supplied username?

From Dev

laravel 5 built in scaffolding tried to use username instead of email error

From Dev

modify laravel 5.1 login to use username instead of email

From Dev

How can I use LDAP as a login server for Linux?

From Dev

How to link to php from xampp installation so i can just use php command instead of full path?

From Dev

How can i use <symbol> instead of <g>?

From Dev

how can i use curl instead of fopen

From Dev

How long can a basic authentication username/password be?

From Dev

How to create Google Calendar event by email-username authentication?

From Dev

how do I configure my RHEL5 or RHEL6 system to use ldap for authentication?

From Dev

Firebase Authentication without email as username?

From Dev

Can i use username instead of user id in wordpress, ignoring wp_users table?

From Dev

Can i use username instead of user id in wordpress, ignoring wp_users table?

Related Related

  1. 1

    How can I use the email instead of the username in LDAP authentication with PHP?

  2. 2

    Username authentication instead of email

  3. 3

    How can I use ldap authentication with full disk encryption?

  4. 4

    JWTAuth authentication with username instead of email

  5. 5

    How can I prevent Git from using an email of the form username@pc-name instead of an empty one?

  6. 6

    Authentication using username instead of email laravel 5.2

  7. 7

    Picketlink -How can i implement an authenticating that accept use username or email at same time

  8. 8

    Can I use Atlassian Crowd to authenticate gerrit instead of ldap?

  9. 9

    Java LDAP authentication with username

  10. 10

    Username and Password for LDAP Authentication

  11. 11

    how can i set username and password for basic http authentication?

  12. 12

    How to login with "UserName" instead of "Email" in MVC Identity?

  13. 13

    How to log in by email instead of username in Spring security

  14. 14

    Authentication using username or email

  15. 15

    How to change username authentication to email authentication in already buit project?

  16. 16

    How do I change the ASP.NET MVC default login page to login by username instead of email address?

  17. 17

    Using Spring, Basic Auth and LDAP, how can I get the supplied username?

  18. 18

    laravel 5 built in scaffolding tried to use username instead of email error

  19. 19

    modify laravel 5.1 login to use username instead of email

  20. 20

    How can I use LDAP as a login server for Linux?

  21. 21

    How to link to php from xampp installation so i can just use php command instead of full path?

  22. 22

    How can i use <symbol> instead of <g>?

  23. 23

    how can i use curl instead of fopen

  24. 24

    How long can a basic authentication username/password be?

  25. 25

    How to create Google Calendar event by email-username authentication?

  26. 26

    how do I configure my RHEL5 or RHEL6 system to use ldap for authentication?

  27. 27

    Firebase Authentication without email as username?

  28. 28

    Can i use username instead of user id in wordpress, ignoring wp_users table?

  29. 29

    Can i use username instead of user id in wordpress, ignoring wp_users table?

HotTag

Archive