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

    Join Date
    Jul 2006
    Posts
    1
    Rep Power
    0

    Extacting jpegPhotos from LDAP - advice needed


    Hello
    I am trying to get a script, see below, to ouput all the images from our LDAP.
    I've found the script below from the forums here. However it does not output the image but rather large chunks of letters, number and strange symbols instead. The binary perhaps.

    I think I might be missing something to convert the data into a jpeg. can anyone point me in the right direction please?

    Thanks
    J

    PHP Code:
    <?php

    $ip 
    "ldap.domain.com";
    $dn "dc=domain,dc=com";

    // always returns true so no need to check it
    $ds ldap_connect($ip);

    // this sets your server to use VERSION 3 instead of 2 (which is default)
    if (!ldap_set_option($dsLDAP_OPT_PROTOCOL_VERSION3))
    {
        exit(
    'Failed to set protocol version to 3');
    }
    // do an anonymous bind this is just to verify that the server is really there
    // this can be left out I just use it in my class normally
    if (ldap_bind($ds) === false || ldap_errno($ds) !== 0)
    {
        exit(
    'Could not connect to LDAP server');
    }
    print 
    'connected to <b>'.$ip.'</b><br/>';

    // you have to put the dn in the bind to bind to that dn
    // may need a password
    if (ldap_bind($ds$dn) === false)
    {
        exit(
    'Could not bind to '.$dn);
    }
    print 
    'user <b>'.$dn.'</b> authenticated.<br/>';

    $result ldap_search($ds$dn"uid=*", array("jpegphoto")) or die("Error in search query");

    $entry ldap_first_entry($ds$result);

    echo 
    $entry["count"]." posts for this entry.<br />";

    $entry ldap_first_entry($ds$result);
    $counter=1;
    do
    {

        print 
    "<br><strong>COunter is:".$counter."</strong>";
        if (!
    is_resource($entry))
        {
            break;
        }
        
    $values ldap_get_values_len($ds$entry'jpegphoto');
        
    // this should show you whatever is retrived
        
    print '<pre>';
        
    print_r($values);
        print 
    '</pre>';
        
    // loop to the next entry
        
    $entry ldap_next_entry($ds$entry);

        
    $counter++;
    }
    while (
    $entry !== false);

    ldap_unbind($ds);  


    ?>
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Posts
    26
    Rep Power
    0
    Check out the 8th post down on this page:

    http://www.wowwebdesigns.com/wowbb/forum12/1672.html

    It has a good example of how to display an image from a DB, which would be similiar to what you are doing.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0
    You don't have to cover your iPhone 4 with boring cases, when you have so many choices from leather, animal skin, bling or the Bieber. These are all available from today's iPhone accessory retailers.Whether you're worried about accidental drops, throwing it across the room, scratches, dings or dents - a protective case is critical for your iPhone 4.

IMN logo majestic logo threadwatch logo seochat tools logo