MetalSmith Posted July 1, 2009 Share Posted July 1, 2009 OK I have some questions here if anyone can help! First is, all I want to do is a LDAP query to tell me what user has dial up set to Allow or Deny in their user account. The problem is when I run it, if the attribute is missing like the "sn" was not typed in when the account was made the script errors out. Or if the dial setting is neither set for allow or deny it errors out. How can I get the script to over look an empty or null attribute. Or better yet why does in not retrieve and say nothing is there for that attribute? Second is and I don't know why. Why does the $i variable change based on the ldap_get_values function when in the loop I said $i = 0. When I echo the results in the end of the script it gives me the first, lastname and the dial setting. I can't understand why though. Shouldn't $i be the same value? I wrote this by trial and error looking at how to do it online. Still new to this! Anyone? Thanks! <?php $ldap = ldap_connect("192.168.xxx.xxx"); ldap_bind($ldap,"username","password"); $filter="(givenname=*)"; $attributes = array("givenname","sn","msnpallowdialin"); $search_result =ldap_search($ldap,"DC=example,DC=com",$filter,$attributes); for ($entryID=ldap_first_entry($ldap,$search_result); $entryID!=false; $entryID=ldap_next_entry($ldap,$entryID)) { $first_name = ldap_get_values($ldap,$entryID,"givenname"); $last_name = ldap_get_values($ldap,$entryID,"sn"); $dial_status = ldap_get_values($ldap,$entryID,"msnpallowdialin"); for ($i=0;$i<$first_name["count"];$i++) { echo "$last_name[$i], "; echo "$first_name[$i] => "; echo $dial_status[$i]; echo "\n"; } } ldap_unbind($ldap); ?> Link to comment https://forums.phpfreaks.com/topic/164322-ldap-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.