blirette Posted April 16, 2010 Share Posted April 16, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/198782-basic-ldap-php-question/ Share on other sites More sharing options...
blirette Posted April 16, 2010 Author Share Posted April 16, 2010 Finally found it : $sr = ldap_search($ds, "ou=idul,ou=comptes,dc=ulaval,dc=ca", "cn=belir") or die('search error'); If it can help someone... Quote Link to comment https://forums.phpfreaks.com/topic/198782-basic-ldap-php-question/#findComment-1043302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.