MacGoose Posted June 5, 2010 Share Posted June 5, 2010 Hi!I'm trying to get ldap to work using php. This is my code: <?php echo "<h3>LDAP query test</h3>"; echo "Connecting to...<br />"; $ds = ldap_connect( "ldap.ntnu.no" ); echo "Connect result is ( " . $ds . " )<br />"; if( $ds ) { echo "Binding...<br />"; $r = ldap_bind( $ds ); echo "Bind result is ( " . $r . " )<br />"; if( $r ) { echo "Searching...<br />"; $sr = ldap_search( $ds, "dc=NTNU, dc=no", "ou=*" ); echo "Search result is ( " . $sr . " )<br />"; if( $sr ) { echo "Number of entires returned is " . ldap_count_entries( $ds, $sr ) . "<br />"; }else { echo "<h4>Search returned null!</h4>"; } }else { echo "<h4>Unable to bind to LDAP server!</h4>"; } echo "Closing connection...<br />"; ldap_close( $ds ); echo "Closed!<br />"; }else { echo "<h4>Unable to connect to LDAP server!</h4>"; }?> It takes forever to do the binding and then it returns null. I have the ldap module on my server and it is enabled. To connect and bind to a server seems fairly easy - it's only a few simple functions, but still I can't do it.I've been unsing JXplorer and it have no problem reading the same ldap directory as I try to connect to using php. Using JXplorer I connect anonymously just as I do using php.Any help appreciated as I am so stuck.TIA!, MacGoose Link to comment Share on other sites More sharing options...
Synook Posted June 5, 2010 Share Posted June 5, 2010 Are you sure you are connecting on the right port? Does the LDAP server allow external connections? Link to comment Share on other sites More sharing options...
MacGoose Posted June 5, 2010 Author Share Posted June 5, 2010 Are you sure you are connecting on the right port? Does the LDAP server allow external connections?I'm sure. I even tried specifying the port. But the server is using the standard ldap port so it's not needed really. As I used JXplorer and got full read access the server is open and ready.What really annoys me is that the ldap_bind() function just takes forever to return, and when it does it simply fails. Most likely due to timeout. But since I can connect using JXplorer, which is a very simple program, then there is something wrong with how I do it or set it up in php. But I can't see what I do wrong as the ldap_ functions are very simple..., MacGoose Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.