Jump to content

Basic LDAP / PHP question


blirette

Recommended Posts

Hey guys,

 

I've been working with PHP/MySQL for a long time but never had a chance of trying to use it in conjonction with LDAP. So, here I am.

 

I've tried to found the basics of it on the Net but now I seem so close to solving it, I thought maybe someone here could figure out it in secs.

 

I'm trying to retrieve informations with LDAP. The problem is I have no clue how to tell which info I want.

 

Here's the code I have atm :


// Connecting
$ds=ldap_connect("ldaps://uldc1.ulaval.ca");  // must be a valid LDAP server!

// Checkingif the connection worked
if ($ds)
{ 
// Binding
$r = ldap_bind($ds, "[email protected]", "password");

// Search entry
$sr = ldap_search($ds, "dc=ulaval,dc=ca,ou=comptes,ou=idul", "cn=_MAC01");

// Show the number of entries
echo "Number of entires returned is ".ldap_count_entries($r, $sr)."<br />";

// Getting entries
$info = ldap_get_entries($ds, $sr);

// Show data
echo "Data for ".$info["count"]." items returned:<br />";

for ($i=0; $i<$info["count"]; $i++)
	{
	echo "dn is: " . $info[$i]["dn"] . "<br />";
	echo "first cn entry is: " . $info[$i]["cn"][0] . "<br />";
	echo "first email entry is: " . $info[$i]["mail"][0] . "<br /><hr />";
	}

// Close the connection
ldap_close($ds);
}
else
{
echo "<h4>Unable to connect to LDAP server</h4>";
}

 

I'd like to get the info "logonCount" as shown in the screenshot.

 

Thanks for the tip!

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/198782-basic-ldap-php-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.