Freigeben über


How to enable PHP LDAP in Azure Web Apps

PHP LDAP extension is not enabled by default in Azure Web App, you need the following steps:

How to enable extensions in the default PHP runtime

  1. Go to https://portal.azure.com
  2. Select your web app and go to App Settings
  3. Add an app setting called PHP_INI_SCAN_DIR with value d:\home\site\inildap-php1
  4. Go to Kudu Console https://<yourwebappname>.scm.azurewebsites.net/DebugConsole
  5. Navigate to site and create a new folder called ini with mkdir ini command.ldap-php2
  6. Create the file extensions.ini inside this folder with touch extensions.ini command.ldap-php3
  7. Write the following line: extension=php_ldap.dll
  8. Restart the web app and test.

 

You can check LDAP Documentation for more information: https://php.net/manual/en/function.ldap-bind.php

 
// Authentication example
$ldaprdn  = 'uname';     // ldap rdn or dn
$ldappass = 'password';  // associated password

// Connection to LDAP server
$ldapconn = ldap_connect("ldap.example.com")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    if ($ldapbind) {
        echo "LDAP bind successful...";
    } else {
        echo "LDAP bind failed...";
    }
}