+ Post New Thread
Results 1 to 5 of 5
Web Development Thread, LDAP, Apache in Coding and Web Development; Hey Guys an Girls I am trying to write a PHP page to connect to one of my DC's to ...
  1. #1
    wiggum123's Avatar
    Join Date
    May 2010
    Location
    Bristol
    Posts
    58
    Thank Post
    13
    Thanked 2 Times in 2 Posts
    Rep Power
    9

    LDAP, Apache

    Hey Guys an Girls

    I am trying to write a PHP page to connect to one of my DC's to authenticate users. I havnt played with LDAP before and my knowledge of PHP is limited, so I'm a bit lost in the dark at the moment...
    I have a Ubuntu server for the site, with the latest PHP, and I have told it to install LDAP, I wasnt sure if I had to do anything after installing it....
    I have patched together a PHP script which connects to my server and binds successfully, apparantly. I then want to search for a user called ben and display his details, just to check everything is working.
    It tells me I have connected using this;
    PHP Code:
    // LDAP variables
    $ldaphost "ldap://myserver/";  // your ldap servers
    $ldapport myport;            // your ldap server's port number


    // Connecting to LDAP
    $ldapconn ldap_connect($ldaphost$ldapport)
              or die(
    "Could not connect to $ldaphost");

    if (
    $ldapconn) {

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

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


    When I add the following code the page stops working and just goes white...

    PHP Code:
    $ds=dc2
    $person 
    "ben"
    $dn "dc=mydomain, dc=local";
    $filter="(|(sn=$person*)(givenname=$person*))";
    $justthese = array("ou""sn""givenname""mail");

    $sr=ldap_search($ds$dn$filter$justthese);

    $info ldap_get_entries($ds$sr);

    echo 
    $info["count"]." entries returned\n"
    What have I forgotten to configure? Is there another setting on the DC I need to enable??? Im Pulling my hair out and dont want to leave it unfixed on a Friday!

  2. #2
    danbuntu's Avatar
    Join Date
    Dec 2009
    Location
    Maidstone, Kent
    Posts
    295
    Thank Post
    0
    Thanked 53 Times in 50 Posts
    Rep Power
    19
    turn php error reporting on and use a proper browser like firefox and that will show you the error rather than a white screen.

  3. #3

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,661
    Thank Post
    901
    Thanked 1,317 Times in 800 Posts
    Blog Entries
    1
    Rep Power
    444
    Also if you use IIS + php you can use native integrate auth.

  4. #4


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    apache has a native ldap authentication module:
    mod_auth_ldap - Apache HTTP Server

  5. #5

    Join Date
    Jan 2007
    Location
    Lowestoft, Suffolk
    Posts
    84
    Thank Post
    6
    Thanked 4 Times in 4 Posts
    Rep Power
    16
    The first two lines of that second block of code look wrong to me.

    $ds=dc2

    Should that be $ds="dc2"; ?
    I expect that line to be giving you a syntax error.

    And the second line is missing it's semi-colon, which will also generate a syntax error.

    Add
    error_reporting['E_ALL'];
    to the top of the code and run the it again.

    Take the reporting line out when you're happy it's working.

SHARE:
+ Post New Thread

Similar Threads

  1. apache htaccess ldap > server 2003
    By browolf in forum Windows Server 2000/2003
    Replies: 1
    Last Post: 2nd July 2010, 02:23 PM
  2. Moodle, Apache help
    By Quackers in forum Virtual Learning Platforms
    Replies: 1
    Last Post: 1st March 2010, 11:46 AM
  3. [Ubuntu] Apache question
    By Batman in forum *nix
    Replies: 7
    Last Post: 13th May 2009, 01:28 PM
  4. Apache realms...again
    By HodgeHi in forum Mac
    Replies: 1
    Last Post: 28th January 2008, 04:16 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •