Is it possible (I am trying) to connect to Mac OS X 10.6 server via php? My LDAP service is running.
Here is what I have tried:
// using ldap bind
$ldaprdn = 'diradmin'; // ldap rdn or dn
$ldappass = 'password'; // associated password
// connect to ldap server
$ldapconn = ldap_connect("server.example.com")
or die("Could not connect to LDAP server.");
ldap_set_option( $ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3 );
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}
ERROR MESSAGE: Message: ldap_bind(): Unable to bind to server: Invalid DN syntax
Try making the following change in your code. This works for me with Mac OS X 10.5 Server. As far as I know 10.6 didn't really change much with regards to LDAP.
$ldaprdn="uid=diradmin,cn=users,dc=server,dc=example,dc=com";
// assumes ldap server is server.example.com
I highly recommend using LDAP Manager (for Mac) to view your OS X Server's LDAP Directory tree. LDAP Manager