20130320 ldaps with php - plembo/onemoretech GitHub Wiki

title: ldaps with php link: https://onemoretech.wordpress.com/2013/03/20/ldaps-with-php/ author: phil2nc description: post_id: 4507 created: 2013/03/20 03:37:40 created_gmt: 2013/03/20 07:37:40 comment_status: closed post_name: ldaps-with-php status: publish post_type: post

ldaps with php

Just a simple example script showing how to connect to a directory server over LDAPS using php. Here's the code: [code language="php"] [/code] Note that before doing this I edited my local /etc/openldap/ldap.conf, commenting out everything that was already there and adding:

TLS_REQCERT never
TLS_CACERTDIR /etc/pki/tls/certs

This allows me to connect to servers with self-signed certs, as php's LDAP module suffers from 2 shortcomings: (1) dependence on openldap's local config; (2) abysmal handling of SSL certificates. Server certs are stored in the common /etc/pki/tls/certs directory. Perl's Net::LDAP module is significantly more sophisticated and flexible than the corresponding php module, so much so that I've considered using php only for the presentation layer while relying on perl for the backend functions when writing new web applications.

Copyright 2004-2019 Phil Lembo