note 116853 added to function.ldap-connect

From: Date: Tue, 10 Mar 2015 18:07:07 +0000
Subject: note 116853 added to function.ldap-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-201913@lists.php.net to get a copy of this message
To override the ssl ca file can be done by setting an environmental variable within php. I found using saving the ca certificate (and intermediate ca's) to a file called ca.pem and then adding putenv('LDAPTLS_CACERT=./ca.pem'); before ldap_connect works for me. Code example: <?php putenv('LDAPTLS_CACERT=./ca.pem'); ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); $l = ldap_connect("ldaps://ldap/"); ldap_set_option($l, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_bind($l, "cn=apache,dc=example", "xxxxxxx"); echo(ldap_error($l)."\n"); $s = ldap_search($l, "dc=example", "uid=test"); echo(ldap_count_entries($l, $s)."\n"); ?> in the file ca.pem in the same directory we have our ca's: -----BEGIN CERTIFICATE----- <cert here> -----END CERTIFICATE----- ---- Server IP: 72.52.91.14 Probable Submitter: 146.151.212.114 ---- Manual Page -- http://php.net/manual/en/function.ldap-connect.php Edit -- https://master.php.net/note/edit/116853 Del: integrated -- https://master.php.net/note/delete/116853/integrated Del: useless -- https://master.php.net/note/delete/116853/useless Del: bad code -- https://master.php.net/note/delete/116853/bad+code Del: spam -- https://master.php.net/note/delete/116853/spam Del: non-english -- https://master.php.net/note/delete/116853/non-english Del: in docs -- https://master.php.net/note/delete/116853/in+docs Del: other reasons-- https://master.php.net/note/delete/116853 Reject -- https://master.php.net/note/reject/116853 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201913) next »