Voting

: eight minus four?
(Example: nine)

The Note You're Voting On

marnijt at LIKEHAM dot gmail dot com
13 years ago
After a lot of trail and error i've found the way to authenticate to apple's Opendirectory (snow leopard server) and thought it maybe useful to share.

<?php
// using ldap bind
$ldaprdn = 'uid=USERNAME,cn=users,dc=HOSTNAME,dc=DOMAIN,dc=com'; // ldap rdn or dn
$ldappass = 'PASSWORD'; // associated password

// connect to ldap server
$ldapconn = ldap_connect("HOSTNAME.DOMAIN.com")
or die(
"Could not connect to LDAP server.");

// Set some ldap options for talking to
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);

if (
$ldapconn) {

// binding to ldap server
$ldapbind = @ldap_bind($ldapconn, $ldaprdn, $ldappass);

// verify binding
if ($ldapbind) {
echo
"LDAP bind successful...\n";
} else {
echo
"LDAP bind failed...\n";
}

}

?>

<< Back to user notes page

To Top