add ldap test if ldap is in use
authorebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 12 Aug 2004 01:16:28 +0000 (01:16 +0000)
committerebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 12 Aug 2004 01:16:28 +0000 (01:16 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7887 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/configtest.php

index a0ff7de413d1e6a486b1dc7c1171e98b7211de0d..0990f3201af847c2fa71ad9931c6db5820ea6454 100644 (file)
@@ -334,6 +334,47 @@ if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) {
 } else {
     echo $IND."not using database functionality.<br />\n";
 }
+
+// LDAP DB tests
+echo "Checking LDAP functions...<br />\n";
+if( empty($ldap_server) ) {
+       echo $IND."not using LDAP functionality.<br />\n";
+} else {
+    if ( !function_exists(ldap_connect) ) {
+        do_err('Required LDAP support is not available.');
+    } else {
+               echo "$IND LDAP support present.<br />\n";
+        foreach ( $ldap_server as $param ) {
+
+            $linkid = ldap_connect($param['host'], (empty($param['port']) ? 389 : $param['port']) );
+
+            if ( $linkid ) {
+                       echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
+                
+                if ( !empty($param['protocol']) &&
+                     !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION, $param['protocol']) ) {
+                    do_err('Unable to set LDAP protocol');
+                }   
+
+                if ( empty($param['binddn']) ) {
+                    $bind = ldap_bind($linkid);    
+                } else {
+                    $bind = ldap_bind($param['binddn'], $param['bindpw']);
+                }
+
+                if ( $bind ) {
+                    echo "$IND LDAP Bind Successful <br />";
+                } else {
+                    do_err('Unable to Bind to LDAP Server');
+                }
+                
+                ldap_close($linkid);
+            } else {
+                do_err('Connection to LDAP failed');
+            }
+        }
+    }
+}
 ?>
 
 <p>Congratulations, your SquirrelMail setup looks fine to me!</p>