I have a .ldif file and want to import it using php script to my ldap. So, i'm using that code:
$comm = "ldapadd -h 'localhost' -p 389 -D 'cn=admin,dc=example,dc=com' -w 'password' -f /var/www/html/test/ldap.ldif";
system($comm,$return);
echo $return;
I'm always getting error code 13 which is:
LDAP_CONFIDENTIALITY_REQUIRED: Indicates that the session is not protected by a protocol such as Transport Layer Security (TLS), which provides session confidentiality.
Looking at ldapadd sintax found these options
-W: Wallet location for one- or two-way SSL authentication
-P Wallet password
-U SSL authentication mode: 1 for no authentication; 2 for one-way authentication; 3 for two-way authentication
But I don't know how or when I have to use them. My .ldif file contain a lot of new entrys and through php code I couldn't use the:
$info["dn"] = $test;
Always getting errors about that $info["dn"] syntax, so then I gave up and start trying with terminal command.
Would really appreciate some help about it and sorry about my english. Thank you.
A friend of mine found the answer. About the code 13 error was missing an option at the end of the command which allows the TLS connection, so, the correct command line is:
ldapadd -h 'localhost' -p 389 -D 'cn=admin,dc=example,dc=com' -w 'password' -f /var/www/html/test/ldap.ldif -Z
So, the option -Z
or -ZZ
at the end enables the TLS and the error is gone, so it's working the input on ldap with my .ldif file
Thank you all.