#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    PHP - Trying to search the AD without sucess


    Hello,

    I'm new using LDAP with PHP.
    I can connect to the server. But I'm trying to look for users at AD without sucess.

    My users are not in Users folders. They're organized as follows:
    "DC=dc01,DC=com";

    The list of users are only inside NORMAL.

    I'm trying an anonymous users, but even if try to connect via bind, I have no sucess trying to bind.

    That's the php code:


    $dn = "DC=dc01,DC=com,OU=CITY,OU=USERS,OU=NORMAL";




    $conexao = ldap_connect("ldap://ip_server", 389) or die("Couldn't connect to AD!");
    if (!$conexao) {
    echo "Problemas ao Conectar";
    exit;
    }


    $bind = ldap_bind($conexao);
    if (!$bind) {
    echo "Problemas ao fazer o bind";
    }


    $result = ldap_search($conexao, $dn, "cn=*");

    $entries = ldap_get_entries($conexao, $result);
    echo "O numero eh: " . $entries["count"];

    for ($i=0; $i<$entries["count"]; $i++)
    {
    echo $entries[$i]["displayname"]
    [0]."(".$entries[$i]["l"][0].")<br />";
    }

    ldap_unbind($bind);
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Location
    Charlotte, NC
    Posts
    111
    Rep Power
    10
    First AD does not support anonymous BINDs unless explicitly setup to do so.
    Second, the DN you have is incorrect
    $dn = "DC=dc01,DC=com,OU=CITY,OU=USERS,OU=NORMAL";
    should be
    $dn = "OU=NORMAL,OU=USERS,OU=CITY,DC=dc01,DC=com";

IMN logo majestic logo threadwatch logo seochat tools logo