jueves, 28 de junio de 2012

PHP: logueo con LDAP

<?php

function authLDAP($username, $password){
    $ldap_domain = 'midominio';

    $adServer = "miservidor";
    $ldapconn = ldap_connect($adServer) or die("Could not connect to LDAP server.");

    $ldaprdn = $username;    

    # Descomentar si la App corre bajo Apache2 sobre Windows Server
    #ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3)

    $ldapbind = ldap_bind($ldapconn, "$ldaprdn@$ldap_domain", $password);

    if($ldapbind)
        return true;
    else
        return false;
}

authLDAP("sad", "asd");

?>

1 comentario: