note 94893 added to function.ldap-start-tls
| From: | jcarlos at dsi dot uclm dot es | Date: | Tue, 01 Dec 2009 13:10:54 +0000 |
| Subject: | note 94893 added to function.ldap-start-tls | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163447@lists.php.net to get a copy of this message | ||
Tested in Linux, ubuntu 9.10, PHP/5.2.10-2 and Apache/2.2.1.2
INTEGRATING ACTIVE DIRECTORY WITH PHP-LDAP AND TLS IN LINUX
=============================================================
I'm not an expert, but it works.
1)I have installed ubuntu 9.10 desktop
2)Packages:
apt-get install apache2
apt-get install libapache2-mod-php5
apt-get install libldap-2.4-2
apt-get install ldap-utils
apt-get install libsasl2-modules-ldap
apt-get install openssl
apt-get install libsasl2-2
apt-get install libkrb5-3
apt-get install php5-ldap
apt-get install php5-sasl
apt-get install php5-auth-pam
3)Put the PEM certificate.
cd /etc/ldap
mkdir certs
copy /myhome/mycert.pem /etc/ldap/certs/mycert.pem
NOTE:webcert.crt rename to mycert.pem. It's the same
4)Edit the file /etc/ldap/ldap.conf and Add:
TLS_REQCERT never
TLS_CACERT /etc/ldap/certs/mycert.pem
5)Create file /var/www/ldaptlstest.php:
<?php
$ldap="ldap.myDomain.com";
$usr="user@myDomain.com";
$pwd="mypassword";
$ds=ldap_connect($ldap);
$ldapbind=false;
if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
if(ldap_set_option($ds, LDAP_OPT_REFERRALS, 0))
if(ldap_start_tls($ds))
$ldapbind = @ldap_bind($ds, $usr, $pwd);
ldap_close($ds);
if(!$ldapbind)
echo "ERROR";
else
echo "OK";
?>
6)Restart the server: /etc/init.d/apache2 restart
7)Open Firefox and write: http://localhost/ldaptlstest.php
;)
----
Server IP: 80.64.47.13
Probable Submitter: 161.67.132.13
----
Manual Page -- http://www.php.net/manual/en/function.ldap-start-tls.php
Edit -- https://master.php.net/note/edit/94893
Del: integrated -- https://master.php.net/note/delete/94893/integrated
Del: useless -- https://master.php.net/note/delete/94893/useless
Del: bad code -- https://master.php.net/note/delete/94893/bad+code
Del: spam -- https://master.php.net/note/delete/94893/spam
Del: non-english -- https://master.php.net/note/delete/94893/non-english
Del: in docs -- https://master.php.net/note/delete/94893/in+docs
Del: other reasons-- https://master.php.net/note/delete/94893
Reject -- https://master.php.net/note/reject/94893
Search -- https://master.php.net/manage/user-notes.php