Welcome Guest, Not a member yet? Register   Sign In
adLDAP library Question
#1

[eluser]Unknown[/eluser]
Hi @ all!

I'm very new to code igniter and have a question.
I want to build an app which interacts with our internal LDAP server. So I found the adLDAP lib for CodeIgniter. After tweaking a little bit I was able to successfully connect to the LDAP server. But now I don't know how I can retrieve some data from the LDAP.

Here is my code:

Code:
public function create()
    {
        $this->load->library('Adldap');

        $authUser = $this->adldap->authenticate('CN=admin,DC=stewie,DC=com', 'Quagmire');
        if ($authUser == true) {
          echo "User authenticated successfully";
        }
        else {
          echo "User authentication unsuccessful";
        };

        $user = $this->adldap->user()->infoCollection("dmueller", array(*));
        echo $user;        
        $this->adldap->close();        
    }

The connection itself works but I get a blank page instead of the userdata I want to retrieve.

Thank you very much in advance!
#2

[eluser]mraliks[/eluser]
I know this is an old post, but your last bit of code should look more of something like this:

Code:
$user = $this->adldap->user()->info($username, array("*")); //works with the latest version of adldap

We set the user info into an array called $user. Therefore to call up any user data, we either do:
Code:
print_r($user);

or individually, fetch an array item from the user array, for example:
Code:
echo $user[0]['userprincipalname'][0]; //echoes username
echo $user[0]['givenname'][0]; first name
echo $user[0]['sn'][0]; // last name
echo $user[0]['mail'][0]; //email address
echo $user[0]['physicaldeliveryofficename'][0]; //Office location

The full list of active directory attributes that makes up the $user array can be found on the adLDAP website.




Theme © iAndrew 2016 - Forum software by © MyBB