Skip to content

Instantly share code, notes, and snippets.

@stefanorossiti
Created September 25, 2018 06:59
Show Gist options
  • Save stefanorossiti/5492046820b41d9698a5d92751d6cf0e to your computer and use it in GitHub Desktop.
Save stefanorossiti/5492046820b41d9698a5d92751d6cf0e to your computer and use it in GitHub Desktop.
LDAP/AD user validation chech example with PHP LDAP plugin
<?php
$ldaphost = "localhost";
$ldabindDN = "cn=admin,dc=local,dc=test";
$ldapassw = "edpplc";
$ldapport = 389;
$ldap = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost");
echo 'Connecting to ' . $ldaphost . '...';
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3) or die("Cannot connect to $ldaphost");
$bind = ldap_bind($ldap, $ldabindDN, $ldapassw);
echo 'Done';
ldap_unbind($ldap);
@stefanorossiti
Copy link
Author

LDAP Container for testing:
github.com/osixia/docker-openldap

Container created:
docker run -p localhost:389:389 --name openldap-local-test -d -e LDAP_ORGANISATION=BBC -e LDAP_DOMAIN=local.test -e LDAP_ADMIN_PASSWORD=edpplc --rm osixia/openldap:1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment